List products.
Scopes: products:read products:write
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"github.com/polarsource/polar-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New(
polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
)
res, err := s.Products.List(ctx, operations.ProductsListRequest{
OrganizationID: nil,
})
if err != nil {
log.Fatal(err)
}
if res.ListResourceProduct != nil {
for {
// handle items
res, err = res.Next()
if err != nil {
// handle error
}
if res == nil {
break
}
}
}
}{
"items": [
{
"id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"trial_interval": "day",
"trial_interval_count": 123,
"name": "<string>",
"description": "<string>",
"recurring_interval": "day",
"recurring_interval_count": 123,
"is_recurring": true,
"is_archived": true,
"organization_id": "<string>",
"metadata": {},
"prices": [
{
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"source": "catalog",
"amount_type": "<string>",
"is_archived": true,
"product_id": "<string>",
"type": "<string>",
"recurring_interval": "day",
"price_currency": "<string>",
"price_amount": 123,
"legacy": true
}
],
"benefits": [
{
"id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"type": "<string>",
"description": "<string>",
"selectable": true,
"deletable": true,
"organization_id": "<string>",
"metadata": {},
"properties": {
"note": "<string>"
}
}
],
"medias": [
{
"id": "<string>",
"organization_id": "<string>",
"name": "<string>",
"path": "<string>",
"mime_type": "<string>",
"size": 123,
"storage_version": "<string>",
"checksum_etag": "<string>",
"checksum_sha256_base64": "<string>",
"checksum_sha256_hex": "<string>",
"last_modified_at": "2023-11-07T05:31:56Z",
"version": "<string>",
"service": "<string>",
"is_uploaded": true,
"created_at": "2023-11-07T05:31:56Z",
"size_readable": "<string>",
"public_url": "<string>"
}
],
"attached_custom_fields": [
{
"custom_field_id": "<string>",
"custom_field": {
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"metadata": {},
"type": "<string>",
"slug": "<string>",
"name": "<string>",
"organization_id": "<string>",
"properties": {
"form_label": "<string>",
"form_help_text": "<string>",
"form_placeholder": "<string>",
"textarea": true,
"min_length": 1,
"max_length": 1
}
},
"order": 123,
"required": true
}
]
}
],
"pagination": {
"total_count": 123,
"max_page": 123
}
}You can generate an Organization Access Token from your organization's settings.
Filter by product ID.
Filter by organization ID.
"1dbfc517-0bbf-4301-9ba8-555ca42b9737"
Filter by product name.
Filter on archived products.
Filter on recurring products. If true, only subscriptions tiers are returned. If false, only one-time purchase products are returned.
Filter products granting specific benefit.
Page number, defaults to 1.
Size of a page, defaults to 10. Maximum is 100.
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.
created_at, -created_at, name, -name, price_amount_type, -price_amount_type, price_amount, -price_amount Successful Response
Show child attributes
The ID of the object.
Creation timestamp of the object.
Last modification timestamp of the object.
The interval unit for the trial period.
day, week, month, year The number of interval units for the trial period.
The name of the product.
The description of the product.
The recurring interval of the product. If None, the product is a one-time purchase.
day, week, month, year Number of interval units of the subscription. If this is set to 1 the charge will happen every interval (e.g. every month), if set to 2 it will be every other month, and so on. None for one-time products.
Whether the product is a subscription.
Whether the product is archived and no longer available.
The ID of the organization owning the product.
List of prices for this product.
A recurring price for a product, i.e. a subscription.
Deprecated: The recurring interval should be set on the product itself.
Show child attributes
Creation timestamp of the object.
Last modification timestamp of the object.
The ID of the price.
The source of the price . catalog is a predefined price, while ad_hoc is a price created dynamically on a Checkout session.
catalog, ad_hoc "fixed"Whether the price is archived and no longer available.
The ID of the product owning the price.
The type of the price.
"recurring"The recurring interval of the price.
day, week, month, year The currency.
The price in cents.
List of benefits granted by the product.
A benefit of type custom.
Use it to grant any kind of benefit that doesn't fit in the other types.
Show child attributes
The ID of the benefit.
Creation timestamp of the object.
Last modification timestamp of the object.
"custom"The description of the benefit.
Whether the benefit is selectable when creating a product.
Whether the benefit is deletable.
The ID of the organization owning the benefit.
List of medias associated to the product.
Show child attributes
The ID of the object.
"product_media"List of custom fields attached to the product.
Show child attributes
ID of the custom field.
Schema for a custom field of type text.
Show child attributes
Creation timestamp of the object.
Last modification timestamp of the object.
The ID of the object.
"text"Identifier of the custom field. It'll be used as key when storing the value.
Name of the custom field.
The ID of the organization owning the custom field.
Show child attributes
111x >= 0x >= 0Order of the custom field in the resource.
Whether the value is required for this custom field.
Was this page helpful?
package main
import(
"context"
"os"
polargo "github.com/polarsource/polar-go"
"github.com/polarsource/polar-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := polargo.New(
polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
)
res, err := s.Products.List(ctx, operations.ProductsListRequest{
OrganizationID: nil,
})
if err != nil {
log.Fatal(err)
}
if res.ListResourceProduct != nil {
for {
// handle items
res, err = res.Next()
if err != nil {
// handle error
}
if res == nil {
break
}
}
}
}{
"items": [
{
"id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"trial_interval": "day",
"trial_interval_count": 123,
"name": "<string>",
"description": "<string>",
"recurring_interval": "day",
"recurring_interval_count": 123,
"is_recurring": true,
"is_archived": true,
"organization_id": "<string>",
"metadata": {},
"prices": [
{
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"source": "catalog",
"amount_type": "<string>",
"is_archived": true,
"product_id": "<string>",
"type": "<string>",
"recurring_interval": "day",
"price_currency": "<string>",
"price_amount": 123,
"legacy": true
}
],
"benefits": [
{
"id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"type": "<string>",
"description": "<string>",
"selectable": true,
"deletable": true,
"organization_id": "<string>",
"metadata": {},
"properties": {
"note": "<string>"
}
}
],
"medias": [
{
"id": "<string>",
"organization_id": "<string>",
"name": "<string>",
"path": "<string>",
"mime_type": "<string>",
"size": 123,
"storage_version": "<string>",
"checksum_etag": "<string>",
"checksum_sha256_base64": "<string>",
"checksum_sha256_hex": "<string>",
"last_modified_at": "2023-11-07T05:31:56Z",
"version": "<string>",
"service": "<string>",
"is_uploaded": true,
"created_at": "2023-11-07T05:31:56Z",
"size_readable": "<string>",
"public_url": "<string>"
}
],
"attached_custom_fields": [
{
"custom_field_id": "<string>",
"custom_field": {
"created_at": "2023-11-07T05:31:56Z",
"modified_at": "2023-11-07T05:31:56Z",
"id": "<string>",
"metadata": {},
"type": "<string>",
"slug": "<string>",
"name": "<string>",
"organization_id": "<string>",
"properties": {
"form_label": "<string>",
"form_help_text": "<string>",
"form_placeholder": "<string>",
"textarea": true,
"min_length": 1,
"max_length": 1
}
},
"order": 123,
"required": true
}
]
}
],
"pagination": {
"total_count": 123,
"max_page": 123
}
}