Import Stripe Data to Google Sheets
In this guide, we’ll walk through how to pull transactions from the Stripe API directly into Google Sheets, using the API Connector add-on for Google Sheets. Stripe is a popular payment processor known for its fantastic APIs. We’ll first get an API key from Stripe, and then set up a request to pull in metrics from Stripe to your spreadsheet.
CONTENTS
- Before You Begin
- Step 1: Get your Stripe API Key
- Step 2: Create your API Request URL
- Step 3: Pull Stripe API Data into Sheets
- Step 4: Get More Data
- Step 5: Handle Pagination
BEFORE YOU BEGIN
Click here to install the API Connector add-on from the Google Marketplace.
STEP 1: GET YOUR STRIPE API KEY
- Log in to Stripe and click Developers > API keys from the left-hand menu
- On this page, you’ll see that API keys have already been automatically created for you. You can choose between test data and real data; they work exactly the same way. (If you want to use live data, simply toggle the ‘Viewing Test Data’ option). Click to reveal the secret token:
- Once you have your key, copy it to your clipboard as we’ll need it shortly.
STEP 2: CREATE YOUR STRIPE API REQUEST URL
We’re going to follow the Stripe API documentation to request a list of transactions.
- Base URL: https://api.stripe.com/v1
- Endpoint: /charges
- Parameters: ?limit=#_OF_RECORDS
The ‘limit’ parameter is optional but we’ll include it to show how parameters work. Putting it all together, we get the full API Request URL:
https://api.stripe.com/v1/charges?limit=100
STEP 3: PULL STRIPE API DATA INTO SHEETS
Now let’s enter our URL into API Connector and import Stripe data into Google Sheets!
- Open up Google Sheets and click Add-ons > API Connector > Open.
- In the Create screen, enter the Request URL we just created
- Under headers, enter a key-value pair like this:
Authorization Bearer YOUR_SECRET_TOKEN Replace YOUR_SECRET_TOKEN with the secret token you got above in step 3 above.
- Create a new tab and click ‘Set current’ to use that tab as your data destination.
- Name your request and click Run. A moment later you’ll see sales data populate the Stripe Charges tab in your Google Sheet:
STEP 4: MORE EXAMPLE API URLS
You can check the documentation for the full list of available API requests, but if you just want to jump in, you can play around with the URLs you enter in the API URL path field. Try the following (one at a time):https://api.stripe.com/v1/charges
https://api.stripe.com/v1/products
https://api.stripe.com/v1/customers
https://api.stripe.com/v1/balance
https://api.stripe.com/v1/payouts
https://api.stripe.com/v1/refunds
STEP 5: HANDLE PAGINATION
By default, Stripe will only return 10 records at a time. To retrieve more, use the ‘limit’ and ‘starting_after’ parameters as described in the documentation, like this:
page 1 https://api.stripe.com/v1/charges?limit=100
page 2 https://api.stripe.com/v1/charges?limit=100&starting_after=ch_1F2EjwIdg4lVxlj2DhB3fQ4S
The ‘limit’ value can be between 1 and 100, while the ‘starting_after’ parameter should take the name of an object ID value in your report.
In API Connector, you can run these requests separately, or loop through them automatically using pagination handling (paid feature), like this: