(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 main
import(
livepeergo "github.com/livepeer/livepeer-go"
"context"
"log"
)
func main() {
s := livepeergo.New(
livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
ctx := context.Background()
res, err := s.Metrics.GetRealtimeViewership(ctx, nil, nil, nil)
if err != nil {
log.Fatal(err)
}
if res.Data != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
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 |
creatorID |
*string | ➖ | The creator ID to filter the query results |
breakdownBy |
[]operations.BreakdownBy | ➖ | The list of fields to break down the query results. Specify this query-string multiple times to break down by multiple fields. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.GetRealtimeViewershipNowResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
Requires a private (non-CORS) API key to be used.
package main
import(
livepeergo "github.com/livepeer/livepeer-go"
"context"
"github.com/livepeer/livepeer-go/models/operations"
"log"
)
func main() {
s := livepeergo.New(
livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
ctx := context.Background()
res, err := s.Metrics.GetViewership(ctx, operations.GetViewershipMetricsRequest{})
if err != nil {
log.Fatal(err)
}
if res.Data != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.GetViewershipMetricsRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.GetViewershipMetricsResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.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 main
import(
livepeergo "github.com/livepeer/livepeer-go"
"context"
"github.com/livepeer/livepeer-go/models/operations"
"log"
)
func main() {
s := livepeergo.New(
livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
ctx := context.Background()
res, err := s.Metrics.GetCreatorViewership(ctx, operations.GetCreatorViewershipMetricsRequest{})
if err != nil {
log.Fatal(err)
}
if res.Data != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.GetCreatorViewershipMetricsRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.GetCreatorViewershipMetricsResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.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 main
import(
livepeergo "github.com/livepeer/livepeer-go"
"context"
"log"
)
func main() {
s := livepeergo.New(
livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
ctx := context.Background()
res, err := s.Metrics.GetPublicViewership(ctx, "<value>")
if err != nil {
log.Fatal(err)
}
if res.Data != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
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 |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.GetPublicViewershipMetricsResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
Query usage metrics
package main
import(
livepeergo "github.com/livepeer/livepeer-go"
"context"
"github.com/livepeer/livepeer-go/models/operations"
"log"
)
func main() {
s := livepeergo.New(
livepeergo.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
ctx := context.Background()
res, err := s.Metrics.GetUsage(ctx, operations.GetUsageMetricsRequest{})
if err != nil {
log.Fatal(err)
}
if res.UsageMetric != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.GetUsageMetricsRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.GetUsageMetricsResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |