Skip to content

Latest commit

 

History

History
90 lines (59 loc) · 8.71 KB

README.md

File metadata and controls

90 lines (59 loc) · 8.71 KB

MetricsSDK

(metrics)

Overview

Available Operations

  • get - Get Metrics
  • limits - Get Metrics Limits

get

Get metrics about your orders and subscriptions.

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("2024-02-07").date(), end_date=dateutil.parser.parse("2022-04-09").date(), interval=polar_sdk.Interval.WEEK)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
start_date datetime ✔️ Start date.
end_date datetime ✔️ End date.
interval models.Interval ✔️ Interval between two timestamps.
organization_id OptionalNullable[models.MetricsGetQueryParamOrganizationIDFilter] Filter by organization ID.
product_id OptionalNullable[models.MetricsGetQueryParamProductIDFilter] Filter by product ID.
product_price_type OptionalNullable[models.QueryParamProductPriceTypeFilter] Filter by product price type. recurring will filter data corresponding to subscriptions creations or renewals. one_time will filter data corresponding to one-time purchases.
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.

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 */*