(metrics())
Operations related to metrics api
- getRealtimeViewership - Query realtime viewership
- getViewership - Query viewership metrics
- getCreatorViewership - Query creator viewership metrics
- getPublicViewership - Query public total views metrics
- getUsage - Query usage metrics
Requires a private (non-CORS) API key to be used.
package hello.world;
import java.lang.Exception;
import java.util.List;
import studio.livepeer.livepeer.Livepeer;
import studio.livepeer.livepeer.models.errors.SDKError;
import studio.livepeer.livepeer.models.operations.BreakdownBy;
import studio.livepeer.livepeer.models.operations.GetRealtimeViewershipNowResponse;
public class Application {
public static void main(String[] args) throws Exception {
try {
Livepeer sdk = Livepeer.builder()
.apiKey("<YOUR_BEARER_TOKEN_HERE>")
.build();
GetRealtimeViewershipNowResponse res = sdk.metrics().getRealtimeViewership()
.playbackId("<value>")
.creatorId("<value>")
.breakdownBy(List.of(
BreakdownBy.PLAYBACK_ID))
.call();
if (res.data().isPresent()) {
// handle response
}
} catch (SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Parameter | Type | Required | Description |
---|---|---|---|
playbackId |
Optional | ➖ | The playback ID to filter the query results. This can be a canonical playback ID from Livepeer assets or streams, or dStorage identifiers for assets |
creatorId |
Optional | ➖ | The creator ID to filter the query results |
breakdownBy |
List<BreakdownBy> | ➖ | The list of fields to break down the query results. Specify this query-string multiple times to break down by multiple fields. |
GetRealtimeViewershipNowResponse
Error Object | Status Code | Content Type |
---|---|---|
models/errors/SDKError | 4xx-5xx | */* |
Requires a private (non-CORS) API key to be used.
package hello.world;
import java.lang.Exception;
import studio.livepeer.livepeer.Livepeer;
import studio.livepeer.livepeer.models.errors.SDKError;
import studio.livepeer.livepeer.models.operations.GetViewershipMetricsRequest;
import studio.livepeer.livepeer.models.operations.GetViewershipMetricsResponse;
public class Application {
public static void main(String[] args) throws Exception {
try {
Livepeer sdk = Livepeer.builder()
.apiKey("<YOUR_BEARER_TOKEN_HERE>")
.build();
GetViewershipMetricsRequest req = GetViewershipMetricsRequest.builder()
.build();
GetViewershipMetricsResponse res = sdk.metrics().getViewership()
.request(req)
.call();
if (res.data().isPresent()) {
// handle response
}
} catch (SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Parameter | Type | Required | Description |
---|---|---|---|
request |
GetViewershipMetricsRequest | ✔️ | The request object to use for the request. |
Error Object | Status Code | Content Type |
---|---|---|
models/errors/SDKError | 4xx-5xx | */* |
Requires a proof of ownership to be sent in the request, which for now is just the assetId or streamId parameters (1 of those must be in the query-string).
package hello.world;
import java.lang.Exception;
import studio.livepeer.livepeer.Livepeer;
import studio.livepeer.livepeer.models.errors.SDKError;
import studio.livepeer.livepeer.models.operations.GetCreatorViewershipMetricsRequest;
import studio.livepeer.livepeer.models.operations.GetCreatorViewershipMetricsResponse;
public class Application {
public static void main(String[] args) throws Exception {
try {
Livepeer sdk = Livepeer.builder()
.apiKey("<YOUR_BEARER_TOKEN_HERE>")
.build();
GetCreatorViewershipMetricsRequest req = GetCreatorViewershipMetricsRequest.builder()
.build();
GetCreatorViewershipMetricsResponse res = sdk.metrics().getCreatorViewership()
.request(req)
.call();
if (res.data().isPresent()) {
// handle response
}
} catch (SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Parameter | Type | Required | Description |
---|---|---|---|
request |
GetCreatorViewershipMetricsRequest | ✔️ | The request object to use for the request. |
GetCreatorViewershipMetricsResponse
Error Object | Status Code | Content Type |
---|---|---|
models/errors/SDKError | 4xx-5xx | */* |
Allows querying for the public metrics for viewership about a video. This can be called from the frontend with a CORS key, or even unauthenticated.
package hello.world;
import java.lang.Exception;
import studio.livepeer.livepeer.Livepeer;
import studio.livepeer.livepeer.models.errors.SDKError;
import studio.livepeer.livepeer.models.operations.GetPublicViewershipMetricsResponse;
public class Application {
public static void main(String[] args) throws Exception {
try {
Livepeer sdk = Livepeer.builder()
.apiKey("<YOUR_BEARER_TOKEN_HERE>")
.build();
GetPublicViewershipMetricsResponse res = sdk.metrics().getPublicViewership()
.playbackId("<value>")
.call();
if (res.data().isPresent()) {
// handle response
}
} catch (SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Parameter | Type | Required | Description |
---|---|---|---|
playbackId |
String | ✔️ | The playback ID to filter the query results. This can be a canonical playback ID from Livepeer assets or streams, or dStorage identifiers for assets |
GetPublicViewershipMetricsResponse
Error Object | Status Code | Content Type |
---|---|---|
models/errors/SDKError | 4xx-5xx | */* |
Query usage metrics
package hello.world;
import java.lang.Exception;
import studio.livepeer.livepeer.Livepeer;
import studio.livepeer.livepeer.models.errors.SDKError;
import studio.livepeer.livepeer.models.operations.GetUsageMetricsRequest;
import studio.livepeer.livepeer.models.operations.GetUsageMetricsResponse;
public class Application {
public static void main(String[] args) throws Exception {
try {
Livepeer sdk = Livepeer.builder()
.apiKey("<YOUR_BEARER_TOKEN_HERE>")
.build();
GetUsageMetricsRequest req = GetUsageMetricsRequest.builder()
.build();
GetUsageMetricsResponse res = sdk.metrics().getUsage()
.request(req)
.call();
if (res.usageMetric().isPresent()) {
// handle response
}
} catch (SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Parameter | Type | Required | Description |
---|---|---|---|
request |
GetUsageMetricsRequest | ✔️ | The request object to use for the request. |
Error Object | Status Code | Content Type |
---|---|---|
models/errors/SDKError | 4xx-5xx | */* |