Skip to content

Latest commit

 

History

History
216 lines (134 loc) · 14.4 KB

README.md

File metadata and controls

216 lines (134 loc) · 14.4 KB

Metrics

(metrics)

Overview

Operations related to metrics api

Available Operations

get_realtime_viewership

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

Example Usage

from livepeer import Livepeer

s = Livepeer(
    api_key="<YOUR_BEARER_TOKEN_HERE>",
)

res = s.metrics.get_realtime_viewership()

if res.data is not None:
    # handle response
    pass

Parameters

Parameter Type Required Description
playback_id Optional[str] 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
creator_id Optional[str] The creator ID to filter the query results
breakdown_by List[operations.BreakdownBy] The list of fields to break down the query results. Specify this
query-string multiple times to break down by multiple fields.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.GetRealtimeViewershipNowResponse

Errors

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

get_viewership

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

Example Usage

from livepeer import Livepeer

s = Livepeer(
    api_key="<YOUR_BEARER_TOKEN_HERE>",
)

res = s.metrics.get_viewership(request={})

if res.data is not None:
    # handle response
    pass

Parameters

Parameter Type Required Description
request operations.GetViewershipMetricsRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.GetViewershipMetricsResponse

Errors

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

get_creator_viewership

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

from livepeer import Livepeer

s = Livepeer(
    api_key="<YOUR_BEARER_TOKEN_HERE>",
)

res = s.metrics.get_creator_viewership(request={})

if res.data is not None:
    # handle response
    pass

Parameters

Parameter Type Required Description
request operations.GetCreatorViewershipMetricsRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.GetCreatorViewershipMetricsResponse

Errors

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

get_public_viewership

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

from livepeer import Livepeer

s = Livepeer(
    api_key="<YOUR_BEARER_TOKEN_HERE>",
)

res = s.metrics.get_public_viewership(playback_id="<value>")

if res.data is not None:
    # handle response
    pass

Parameters

Parameter Type Required Description
playback_id str ✔️ 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
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.GetPublicViewershipMetricsResponse

Errors

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

get_usage

Query usage metrics

Example Usage

from livepeer import Livepeer

s = Livepeer(
    api_key="<YOUR_BEARER_TOKEN_HERE>",
)

res = s.metrics.get_usage(request={})

if res.usage_metric is not None:
    # handle response
    pass

Parameters

Parameter Type Required Description
request operations.GetUsageMetricsRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.GetUsageMetricsResponse

Errors

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