(metrics)
Get metrics about your orders and subscriptions.
Currency values are output in cents.
Scopes: metrics:read
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)
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. |
Error Type | Status Code | Content Type |
---|---|---|
models.HTTPValidationError | 422 | application/json |
models.SDKError | 4XX, 5XX | */* |
Get the interval limits for the metrics endpoint.
Scopes: metrics:read
from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.metrics.limits()
# Handle response
print(res)
Parameter | Type | Required | Description |
---|---|---|---|
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
Error Type | Status Code | Content Type |
---|---|---|
models.SDKError | 4XX, 5XX | */* |