Expanding Responses
Many objects allow you to request additional information as an expanded response by using the expand request parameter. This parameter is available on all API requests, and applies to the response of that request only. You can expand responses in two ways.
In many cases, an object contains the ID of a related object in its response properties. For example, a Price contains the ID of its Product in the product property. You can expand these objects in line with the expand request parameter. The expandable label in this documentation indicates ID fields that you can expand into objects.
Some available fields aren't included in the responses by default. You can request these fields as an expanded response by using the expand request parameter.
You can expand recursively by specifying nested fields after a dot (.). For example, requesting product.default_price on a price expands the product property into a full Product object, then expands the default_price property on that product into a full Price object.
You can use the expand parameter on any endpoint that returns expandable fields, including list, create, and update endpoints.
Expansions on list requests start with the data property. For example, you can expand data.product on a request to list prices and their associated products. Performing deep expansions on numerous list requests might result in slower processing times.
Expansions have a maximum depth of four levels (for example, data.product.default_price when listing prices).
You can expand multiple objects at the same time by identifying multiple items in the expand array.
- API reference: Prices API
- API reference: Products API
/v1/prices/:idimport { Zoneless } from '@zoneless/node';
const zoneless = new Zoneless('sk_live_z_YOUR_API_KEY', 'https://api.zoneless.com');
const price = await zoneless.prices.retrieve(
'price_z_yXmLn04Bpw9Wbjx2',
{
expand: ['product', 'product.default_price'],
}
);{
"id": "price_z_yXmLn04Bpw9Wbjx2",
"object": "price",
"active": true,
"currency": "usdc",
"unit_amount": 1000,
"product": {
"id": "prod_z_oJaYlHpf6YmRzCMm",
"object": "product",
"name": "Pro Plan",
"default_price": {
"id": "price_z_yXmLn04Bpw9Wbjx2",
"object": "price"
// ...
}
// ...
}
// ...
}