Skip to content

Latest commit

 

History

History
101 lines (65 loc) · 9.35 KB

README.md

File metadata and controls

101 lines (65 loc) · 9.35 KB

MetricsSDK

(metrics)

Overview

Available Operations

  • get - Get Metrics
  • limits - Get Metrics Limits

get

Get metrics about your orders and subscriptions.

Currency values are output in cents.

Scopes: metrics:read

Example Usage

import dateutil.parser
import polar_sdk
from polar_sdk import Polar


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

    res = polar.metrics.get(start_date=dateutil.parser.parse("2025-02-06").date(), end_date=dateutil.parser.parse("2024-09-04").date(), interval=polar_sdk.TimeInterval.WEEK, organization_id=[
        "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
    ])

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
start_date datetime ✔️ Start date.
end_date datetime ✔️ End date.
interval models.TimeInterval ✔️ Interval between two timestamps.
organization_id OptionalNullable[models.MetricsGetQueryParamOrganizationIDFilter] Filter by organization ID.
product_id OptionalNullable[models.MetricsGetQueryParamProductIDFilter] Filter by product ID.
billing_type OptionalNullable[models.QueryParamProductBillingTypeFilter] 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_id OptionalNullable[models.MetricsGetQueryParamCustomerIDFilter] Filter by customer ID.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.MetricsResponse

Errors

Error Type Status Code Content Type
models.HTTPValidationError 422 application/json
models.SDKError 4XX, 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

Parameter Type Required Description
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.MetricsLimits

Errors

Error Type Status Code Content Type
models.SDKError 4XX, 5XX */*