(products)
- list - List Products
- create - Create Product
- get - Get Product
- update - Update Product
- update_benefits - Update Product Benefits
List products.
Scopes: products:read products:write
from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.products.list(organization_id=None, page=1, limit=10)
while res is not None:
# Handle items
res = res.next()| Parameter | Type | Required | Description |
|---|---|---|---|
id |
OptionalNullable[models.QueryParamProductIDFilter] | ➖ | Filter by product ID. |
organization_id |
OptionalNullable[models.ProductsListQueryParamOrganizationIDFilter] | ➖ | Filter by organization ID. |
query |
OptionalNullable[str] | ➖ | Filter by product name. |
is_archived |
OptionalNullable[bool] | ➖ | Filter on archived products. |
is_recurring |
OptionalNullable[bool] | ➖ | Filter on recurring products. If true, only subscriptions tiers are returned. If false, only one-time purchase products are returned. |
benefit_id |
OptionalNullable[models.BenefitIDFilter] | ➖ | Filter products granting specific benefit. |
visibility |
List[models.ProductVisibility] | ➖ | Filter by visibility. |
page |
Optional[int] | ➖ | Page number, defaults to 1. |
limit |
Optional[int] | ➖ | Size of a page, defaults to 10. Maximum is 100. |
sorting |
List[models.ProductSortProperty] | ➖ | 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 product.
Scopes: products:write
from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.products.create(request={
"name": "<value>",
"prices": [],
"organization_id": "1dbfc517-0bbf-4301-9ba8-555ca42b9737",
"recurring_interval": "year",
})
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
request |
models.ProductCreate | ✔️ | 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 product by ID.
Scopes: products:read products:write
from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.products.get(id="<value>")
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
id |
str | ✔️ | 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 | */* |
Update a product.
Scopes: products:write
from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.products.update(id="<value>", product_update={})
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
id |
str | ✔️ | N/A |
product_update |
models.ProductUpdate | ✔️ | N/A |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| models.NotPermitted | 403 | application/json |
| models.ResourceNotFound | 404 | application/json |
| models.HTTPValidationError | 422 | application/json |
| models.SDKError | 4XX, 5XX | */* |
Update benefits granted by a product.
Scopes: products:write
from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.products.update_benefits(id="<value>", product_benefits_update={
"benefits": [
"<value 1>",
"<value 2>",
"<value 3>",
],
})
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
id |
str | ✔️ | N/A |
product_benefits_update |
models.ProductBenefitsUpdate | ✔️ | N/A |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| models.NotPermitted | 403 | application/json |
| models.ResourceNotFound | 404 | application/json |
| models.HTTPValidationError | 422 | application/json |
| models.SDKError | 4XX, 5XX | */* |