(meters)
- list - List Meters
- create - Create Meter
- get - Get Meter
- update - Update Meter
- events - Get Meter Events
- quantities - Get Meter Quantities
List meters.
Scopes: meters:read
meters:write
from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.meters.list(organization_id=[
"1dbfc517-0bbf-4301-9ba8-555ca42b9737",
])
while res is not None:
# Handle items
res = res.next()
Parameter | Type | Required | Description |
---|---|---|---|
organization_id |
OptionalNullable[models.MetersListQueryParamOrganizationIDFilter] | ➖ | Filter by organization ID. |
query |
OptionalNullable[str] | ➖ | Filter by name. |
page |
Optional[int] | ➖ | Page number, defaults to 1. |
limit |
Optional[int] | ➖ | Size of a page, defaults to 10. Maximum is 100. |
sorting |
List[models.MeterSortProperty] | ➖ | Sorting criterion. Several criteria can be used simultaneously and will be applied in order. Add a minus sign - before the criteria name to sort by descending order. |
metadata |
Dict[str, models.MetadataQuery] | ➖ | Filter by metadata key-value pairs. It uses the deepObject style, e.g. ?metadata[key]=value . |
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 | */* |
Create a meter.
Scopes: meters:write
import polar_sdk
from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.meters.create(request={
"name": "<value>",
"filter_": {
"conjunction": polar_sdk.FilterConjunction.AND,
"clauses": [
],
},
"aggregation": {
"func": polar_sdk.Func.SUM,
"property": "<value>",
},
"organization_id": "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
})
# Handle response
print(res)
Parameter | Type | Required | Description |
---|---|---|---|
request |
models.MeterCreate | ✔️ | 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 meter by ID.
Scopes: meters:read
meters:write
from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.meters.get(id="<value>")
# Handle response
print(res)
Parameter | Type | Required | Description |
---|---|---|---|
id |
str | ✔️ | The meter ID. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
Error Type | Status Code | Content Type |
---|---|---|
models.ResourceNotFound | 404 | application/json |
models.HTTPValidationError | 422 | application/json |
models.SDKError | 4XX, 5XX | */* |
Update a meter.
Scopes: meters:write
from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.meters.update(id="<value>", meter_update={})
# Handle response
print(res)
Parameter | Type | Required | Description |
---|---|---|---|
id |
str | ✔️ | The meter ID. |
meter_update |
models.MeterUpdate | ✔️ | N/A |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
Error Type | Status Code | Content Type |
---|---|---|
models.ResourceNotFound | 404 | application/json |
models.HTTPValidationError | 422 | application/json |
models.SDKError | 4XX, 5XX | */* |
Get events matching the filter of a meter.
Scopes: meters:read
meters:write
from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.meters.events(id="<value>")
while res is not None:
# Handle items
res = res.next()
Parameter | Type | Required | Description |
---|---|---|---|
id |
str | ✔️ | The meter ID. |
page |
Optional[int] | ➖ | Page number, defaults to 1. |
limit |
Optional[int] | ➖ | Size of a page, defaults to 10. Maximum is 100. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
Error Type | Status Code | Content Type |
---|---|---|
models.ResourceNotFound | 404 | application/json |
models.HTTPValidationError | 422 | application/json |
models.SDKError | 4XX, 5XX | */* |
Get quantities of a meter over a time period.
Scopes: meters:read
meters:write
import dateutil.parser
import polar_sdk
from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.meters.quantities(id="<value>", start_timestamp=dateutil.parser.isoparse("2023-09-17T00:45:34.608Z"), end_timestamp=dateutil.parser.isoparse("2023-07-21T18:11:39.069Z"), interval=polar_sdk.TimeInterval.HOUR)
# Handle response
print(res)
Parameter | Type | Required | Description |
---|---|---|---|
id |
str | ✔️ | The meter ID. |
start_timestamp |
date | ✔️ | Start timestamp. |
end_timestamp |
date | ✔️ | End timestamp. |
interval |
models.TimeInterval | ✔️ | Interval between two timestamps. |
customer_id |
OptionalNullable[models.MetersQuantitiesQueryParamCustomerIDFilter] | ➖ | Filter by customer ID. |
external_customer_id |
OptionalNullable[models.QueryParamExternalCustomerIDFilter] | ➖ | Filter by external customer ID. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
Error Type | Status Code | Content Type |
---|---|---|
models.ResourceNotFound | 404 | application/json |
models.HTTPValidationError | 422 | application/json |
models.SDKError | 4XX, 5XX | */* |