Skip to content

Latest commit

 

History

History
274 lines (197 loc) · 18.1 KB

README.md

File metadata and controls

274 lines (197 loc) · 18.1 KB

Metrics

(Metrics)

Overview

Operations related to metrics api

Available Operations

GetRealtimeViewership

Requires a private (non-CORS) API key to be used.

Example Usage

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
    }
}

Parameters

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.

Response

*operations.GetRealtimeViewershipNowResponse, error

Errors

Error Object Status Code Content Type
sdkerrors.SDKError 4xx-5xx /

GetViewership

Requires a private (non-CORS) API key to be used.

Example Usage

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
    }
}

Parameters

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.

Response

*operations.GetViewershipMetricsResponse, error

Errors

Error Object Status Code Content Type
sdkerrors.SDKError 4xx-5xx /

GetCreatorViewership

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).

Example Usage

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
    }
}

Parameters

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.

Response

*operations.GetCreatorViewershipMetricsResponse, error

Errors

Error Object Status Code Content Type
sdkerrors.SDKError 4xx-5xx /

GetPublicViewership

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.

Example Usage

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
    }
}

Parameters

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.

Response

*operations.GetPublicViewershipMetricsResponse, error

Errors

Error Object Status Code Content Type
sdkerrors.SDKError 4xx-5xx /

GetUsage

Query usage metrics

Example Usage

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
    }
}

Parameters

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.

Response

*operations.GetUsageMetricsResponse, error

Errors

Error Object Status Code Content Type
sdkerrors.SDKError 4xx-5xx /