Stripe -> List All Products
Readonly
Action summary
This function retrieves a list of products from Stripe with optional pagination parameters.
Inputs
The function accepts the following inputs:
| Name | Type | Description |
|---|---|---|
| starting_after | text | The ID of the last product retrieved (for pagination) |
| limit | integer | The number of products to return (optional) |
| stripe_api_key | registry/text | The API key used to authenticate with Stripe |
Function Stack
The function consists of the following steps:
1. Prepare Body Parameters
- Create Variable:
- Initializes
body_paramsas an empty object{}.
- Initializes
- Update Variable:
- Adds
starting_aftertobody_paramsif provided. - Adds
limittobody_paramsif provided.
- Adds
2. Stripe API Call
- API Request:
- Endpoint:
https://api.stripe.com/v1/products - Method:
GET - Authentication: Uses the
stripe_api_key - Body Parameters:
starting_after: The ID of the last product retrieved (optional).limit: The number of products to return (optional).
- Returns:
stripe_api
- Endpoint:
3. Precondition Check
- Ensures that the API response status is
200before proceeding.
4. Response
- Key:
As Self - Value:
var: stripe_api.response.result - The function returns the list of products received from Stripe if the API call is successful.
How to Get the Stripe API Key
To retrieve your Stripe API key, follow these steps:
- Log in to your Stripe dashboard at https://dashboard.stripe.com.
- Navigate to Developers > API keys.
- Locate the Secret Key under the Standard keys section.
- Click Reveal test key (for testing) or use the live key for production.
- Copy the API key and store it securely.
Note: Never expose your API key in client-side applications.
Usage
- Optionally provide
starting_afterto paginate results. - Optionally provide
limitto specify the number of products to return. - Ensure that
stripe_api_keyis correctly set up in the registry. - Call the function to retrieve the list of products from Stripe.
- If successful, the function returns product information in JSON format.
Example Response
{
"object": "list",
"data": [
{
"id": "prod_12345",
"object": "product",
"name": "Sample Product 1",
"description": "This is a sample product.",
"active": true,
"created": 1672531199,
"updated": 1672531200
},
{
"id": "prod_67890",
"object": "product",
"name": "Sample Product 2",
"description": "This is another sample product.",
"active": true,
"created": 1672531300,
"updated": 1672531400
}
],
"has_more": false
}
Error Handling
- If the API response status is not
200, the function does not proceed. - Ensure valid
starting_afterandlimitvalues to prevent API errors.
Notes
- This function requires an active Stripe account and API key.
- API keys should be kept secure and not exposed in client-side applications.
- Use pagination to fetch large sets of products efficiently.
Version notes
2025-03-03 17:40:48
Current