MetricsSDK

July 20, 2026 ยท View on GitHub

(metrics)

Overview

Available Operations

get

Get metrics about your orders and subscriptions.

Currency values are output in cents.

Scopes: metrics:read

Example Usage

from datetime import date
import polar_sdk
from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.metrics.get(start_date=date.fromisoformat("2025-03-14"), end_date=date.fromisoformat("2025-03-18"), interval=polar_sdk.TimeInterval.HOUR, timezone="UTC", organization_id=None)

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
start_datedatetime:heavy_check_mark:Start date.
end_datedatetime:heavy_check_mark:End date.
intervalmodels.TimeInterval:heavy_check_mark:Interval between two timestamps.
timezoneOptional[str]:heavy_minus_sign:Timezone to use for the timestamps. Default is UTC.
organization_idOptionalNullable[models.MetricsGetQueryParamOrganizationIDFilter]:heavy_minus_sign:Filter by organization ID.
product_idOptionalNullable[models.MetricsGetQueryParamProductIDFilter]:heavy_minus_sign:Filter by product ID.
billing_typeOptionalNullable[models.QueryParamProductBillingTypeFilter]:heavy_minus_sign:Filter by billing type. recurring will filter data corresponding to subscriptions creations or renewals. one_time will filter data corresponding to one-time purchases.
customer_idOptionalNullable[models.MetricsGetQueryParamCustomerIDFilter]:heavy_minus_sign:Filter by customer ID.
metricsList[str]:heavy_minus_sign:List of metric slugs to focus on. When provided, only the queries needed for these metrics will be executed, improving performance. If not provided, all metrics are returned.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.MetricsResponse

Errors

Error TypeStatus CodeContent Type
models.HTTPValidationError422application/json
models.SDKError4XX, 5XX*/*

export

Export metrics as a CSV file.

Scopes: metrics:read

Example Usage

from datetime import date
import polar_sdk
from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.metrics.export(start_date=date.fromisoformat("2026-07-17"), end_date=date.fromisoformat("2024-05-06"), interval=polar_sdk.TimeInterval.YEAR, timezone="UTC", organization_id="1dbfc517-0bbf-4301-9ba8-555ca42b9737")

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
start_datedatetime:heavy_check_mark:Start date.
end_datedatetime:heavy_check_mark:End date.
intervalmodels.TimeInterval:heavy_check_mark:Interval between two timestamps.
timezoneOptional[str]:heavy_minus_sign:Timezone to use for the timestamps. Default is UTC.
organization_idOptionalNullable[models.MetricsExportQueryParamOrganizationIDFilter]:heavy_minus_sign:Filter by organization ID.
product_idOptionalNullable[models.MetricsExportQueryParamProductIDFilter]:heavy_minus_sign:Filter by product ID.
billing_typeOptionalNullable[models.MetricsExportQueryParamProductBillingTypeFilter]:heavy_minus_sign:Filter by billing type. recurring will filter data corresponding to subscriptions creations or renewals. one_time will filter data corresponding to one-time purchases.
customer_idOptionalNullable[models.MetricsExportQueryParamCustomerIDFilter]:heavy_minus_sign:Filter by customer ID.
metricsList[str]:heavy_minus_sign:List of metric slugs to include in the export. If not provided, all metrics are exported.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

str

Errors

Error TypeStatus CodeContent Type
models.HTTPValidationError422application/json
models.SDKError4XX, 5XX*/*

limits

Get the interval limits for the metrics endpoint.

Scopes: metrics:read

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.metrics.limits()

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.MetricsLimits

Errors

Error TypeStatus CodeContent Type
models.SDKError4XX, 5XX*/*

list_dashboards

List user-defined metric dashboards.

Scopes: metrics:read

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.metrics.list_dashboards(organization_id="1dbfc517-0bbf-4301-9ba8-555ca42b9737")

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
organization_idOptionalNullable[models.MetricsListDashboardsQueryParamOrganizationIDFilter]:heavy_minus_sign:Filter by organization ID.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

List[models.MetricDashboardSchema]

Errors

Error TypeStatus CodeContent Type
models.HTTPValidationError422application/json
models.SDKError4XX, 5XX*/*

create_dashboard

Create a user-defined metric dashboard.

Scopes: metrics:write

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.metrics.create_dashboard(request={
        "name": "<value>",
        "organization_id": "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
    })

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
requestmodels.MetricDashboardCreate:heavy_check_mark:The request object to use for the request.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.MetricDashboardSchema

Errors

Error TypeStatus CodeContent Type
models.HTTPValidationError422application/json
models.SDKError4XX, 5XX*/*

get_dashboard

Get a user-defined metric dashboard by ID.

Scopes: metrics:read

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.metrics.get_dashboard(id="<value>")

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
idstr:heavy_check_mark:The metric dashboard ID.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.MetricDashboardSchema

Errors

Error TypeStatus CodeContent Type
models.HTTPValidationError422application/json
models.SDKError4XX, 5XX*/*

update_dashboard

Update a user-defined metric dashboard.

Scopes: metrics:write

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    res = polar.metrics.update_dashboard(id="<value>", metric_dashboard_update={})

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
idstr:heavy_check_mark:The metric dashboard ID.
metric_dashboard_updatemodels.MetricDashboardUpdate:heavy_check_mark:N/A
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.MetricDashboardSchema

Errors

Error TypeStatus CodeContent Type
models.HTTPValidationError422application/json
models.SDKError4XX, 5XX*/*

delete_dashboard

Delete a user-defined metric dashboard.

Scopes: metrics:write

Example Usage

from polar_sdk import Polar


with Polar(
    access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:

    polar.metrics.delete_dashboard(id="<value>")

    # Use the SDK ...

Parameters

ParameterTypeRequiredDescription
idstr:heavy_check_mark:The metric dashboard ID.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Errors

Error TypeStatus CodeContent Type
models.HTTPValidationError422application/json
models.SDKError4XX, 5XX*/*