(metrics)
- get - Get Metrics
- export - Export Metrics
- limits - Get Metrics Limits
- list_dashboards - List Metric Dashboards
- create_dashboard - Create Metric Dashboard
- get_dashboard - Get Metric Dashboard
- update_dashboard - Update Metric Dashboard
- delete_dashboard - Delete Metric Dashboard
Get metrics about your orders and subscriptions.
Currency values are output in cents.
Scopes: metrics:read
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)| Parameter | Type | Required | Description |
|---|---|---|---|
start_date |
datetime | ✔️ | Start date. |
end_date |
datetime | ✔️ | End date. |
interval |
models.TimeInterval | ✔️ | Interval between two timestamps. |
timezone |
Optional[str] | ➖ | Timezone to use for the timestamps. Default is UTC. |
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. |
metrics |
List[str] | ➖ | 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. |
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 | */* |
Export metrics as a CSV file.
Scopes: metrics:read
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)| Parameter | Type | Required | Description |
|---|---|---|---|
start_date |
datetime | ✔️ | Start date. |
end_date |
datetime | ✔️ | End date. |
interval |
models.TimeInterval | ✔️ | Interval between two timestamps. |
timezone |
Optional[str] | ➖ | Timezone to use for the timestamps. Default is UTC. |
organization_id |
OptionalNullable[models.MetricsExportQueryParamOrganizationIDFilter] | ➖ | Filter by organization ID. |
product_id |
OptionalNullable[models.MetricsExportQueryParamProductIDFilter] | ➖ | Filter by product ID. |
billing_type |
OptionalNullable[models.MetricsExportQueryParamProductBillingTypeFilter] | ➖ | 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.MetricsExportQueryParamCustomerIDFilter] | ➖ | Filter by customer ID. |
metrics |
List[str] | ➖ | List of metric slugs to include in the export. If not provided, all metrics are exported. |
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 | */* |
List user-defined metric dashboards.
Scopes: metrics:read
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)| Parameter | Type | Required | Description |
|---|---|---|---|
organization_id |
OptionalNullable[models.MetricsListDashboardsQueryParamOrganizationIDFilter] | ➖ | Filter by organization ID. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
List[models.MetricDashboardSchema]
| Error Type | Status Code | Content Type |
|---|---|---|
| models.HTTPValidationError | 422 | application/json |
| models.SDKError | 4XX, 5XX | */* |
Create a user-defined metric dashboard.
Scopes: metrics:write
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)| Parameter | Type | Required | Description |
|---|---|---|---|
request |
models.MetricDashboardCreate | ✔️ | The request object to use for the request. |
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 a user-defined metric dashboard by ID.
Scopes: metrics:read
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)| Parameter | Type | Required | Description |
|---|---|---|---|
id |
str | ✔️ | The metric dashboard 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 | */* |
Update a user-defined metric dashboard.
Scopes: metrics:write
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)| Parameter | Type | Required | Description |
|---|---|---|---|
id |
str | ✔️ | The metric dashboard ID. |
metric_dashboard_update |
models.MetricDashboardUpdate | ✔️ | N/A |
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 | */* |
Delete a user-defined metric dashboard.
Scopes: metrics:write
from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
polar.metrics.delete_dashboard(id="<value>")
# Use the SDK ...| Parameter | Type | Required | Description |
|---|---|---|---|
id |
str | ✔️ | The metric dashboard 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 | */* |