This minimal library pulls the products from Stripe in JSON format using STRIPE_API_KEY as input, loaded from environment.
Install the package via
PIP
$ pip install python-stripeUsage in code
from stripe_python import get_products STRIPE_KEY = 'YOUR_key_here' # mandatory parameter OUTPUT_FILE = 'products.json' # optional get_products( STRIPE_KEY, OUTPUT_FILE ) All products associated with the account are pulled in products.json. Here is a sample output using an account with one product (multiple prices):
{ "data": [ { "id": "prod_L3QBiEdGWquAHl", "name": "Django Datta Able PRO", "description": "Premium Django Seed project", "images": [ "https://files.stripe.com/links/MDB8YWNjdF8xSGxXdEdHTExkMVgwN1ZVfGZsX3Rlc3RfZjNtOGxwZTRFdGp1MGp1N2ZUeFlENU9Q008T4Zyl6Z" ], "price_dfault": { "price_1KNJKmGLLd1X07VUqu1kDHO2": 99.0 }, "prices": { "price_1LuEz0GLLd1X07VUpsvuNCT8": 119.0, "price_1KNJKmGLLd1X07VUqu1kDHO2": 99.0 } } ] }Image pulled from Stripe
Step 1 - Create
.envusing providedenv.sample
Add .env file in your projects root directory and add the following credentials
STRIPE_API_KEY=<REAL_VALUE_HERE> Step 2 - Install
dependencies
$ python -m venv env $ source env/bin/activate $ pip install -r requirements.txtStep 3 - Pull the products from Stripe dashboard
$ python run.pyThe products are saved in products.json (current working directory). Available props:
idnamedescriptionimagesprice(all)
- Free support via Email & Discord
- Stripe Dev Tools - official docs
Simple Python Wrapper for Stripe - Free library provided by AppSeed.