API Connector Documentation
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 of course a popular payment processor.
We'll first get an API key from Stripe, and then set up a request to pull in Stripe API data to your spreadsheet.
Contents
- Before You Begin
- Part 1: Get your Stripe API Key
- Part 2: Pull Data from Stripe to Sheets
- Part 3: Fetch and Append New Charges
- Part 4: Create a Custom API Request
- Part 5: Handle Pagination
- Part 6: API Documentation
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: Get your Stripe API Key
- Log in to Stripe and click Developers > API keys
- On this page, you'll see that API keys have already been automatically created for you. While you can use these, for added security let's create a restricted key. Click Create restricted key.
- Here you'll be prompted to choose which data points your key should have access to. Most likely you'll want read access to Charges, but you may also want to add access to Balance, Customers, Products, Subscriptions, and so on. Just select what you think you need; you can always change this later.
- Once you've selected your permissions, scroll down and click Create key. Your new key will appear; copy it as you'll need it soon!
Note: When you use this key, enter it with the wordBearer
in front, e.g.Bearer rk_live_11111
Part 2: Pull Data from Stripe to Sheets
The easiest way to get started with the Stripe API is through API Connector’s built-in integration.
- Select Stripe from the drop-down list of applications
- Under Authorization, enter your new API key with the word
Bearer
in front of it. - Under Endpoint, choose
/charges
to get a list of charges for your account. - Optionally set the
created
or other parameters to filter by date or other measures. Pay attention to the limit parameter as Stripe will only send 10 records by default. - Select a destination sheet, name your request, and click Run.
Part 3: Fetch and Append New Charges
Rather than retrieving the entire data set each time you run your request, you can set your request to fetch new data only. There are a few approaches you could take; here's one:
- Create an initial request to the
/charges
endpoint. Use the field editor to select just the fields you want and assign them to specific columns in your report. - Run the request, sending the response to a sheet called Charges.
- Now in a second sheet, get the maximum (i.e. most recent) timestamp from the response data with a formula like
. That will grab the most recent date from the API response (change=max(Charges!F:F)
F:F
to whichever column holds your create date) - Update your request to reference this cell in the
parameter of your request.created[gt]
created[gt]
means 'created greater than', so this will ensure that each request only retrieves new data, and Append mode will add that new data to the end of your existing dataset.- Set your request to run on a schedule. You won't need to update your request again.
Part 4: Create a Custom Request
Alternatively, you can run your own custom requests instead of using API Connector’s pre-built integration, using any of the endpoints and parameters shown in the API documentation. Here's an example request setup, just substitute in your own secret key:
- Application:
Custom
- Method:
GET
- Request URL:
https://api.stripe.com/v1/charges?limit=100
- Headers:
Authorization
:Bearer
your_secret_key
Part 5: Handle Pagination
- By default, Stripe will only return 10 records at a time. To retrieve more, use the
limit
andstarting_after
parameters as described in their documentation. - You can run these request URLs manually, or loop through them automatically using pagination handling, like this:
- Pagination type:
cursor
- Next token parameter:
starting_after
- Next token path:
data.id
- Run until: choose when to stop fetching data
- Pagination type:
Part 6: API Documentation
Official API documentation: https://stripe.com/docs/api
Hi, I used the API connector to get my Stripe charges into a g-sheet. all works fine but the amounts are somehow coming in a wrong format. e.g. a payment of EUR 11,25 is flowing in as 1125,00. Strange enough, it looks as payments >EUR 100,00 are formatted correctly. Does anyone have a hint?
Hi Guy, Stripe reports data in the smallest currency unit, e.g. $10 will be reported as 1000. Can you add a column that divides by 100?
Update: You can now add a formula through the field editor.
Dear Ana,
thank you very much for your great support. I could solve the issue by dividing by 100. Fantastic tool.
Guy
Nice, simple solutions are the best 😀
Hi Ana,
is there an issue with the API "balance". All APIs seem to be working fine but for "balance" I always get this error message, even though I am using the same parameters as for the other requests:
Completed with errors
- Server responded with an error (400) show response{ "error": { "code": "parameter_unknown", "doc_url": "https://stripe.com/docs/error-codes/parameter-unknown", "message": "Received unknown parameter: limit", "param": "limit", "type": "invalid_request_error" } }
Based on the error message, you need to remove the "limit" parameter from your URL, can you try that?
Hi, on my side it works with customers, subscriptions... but not with "https://api.stripe.com/v1/promotion_codes?limit=100" (even if it's listed here : https://stripe.com/docs/api/promotion_codes).
We always have the message "Failed to run requests"
Any help ?
I tested and it worked fine for me, but I only have 2 promotion codes in my account.
"Failed to run request" means that the request timed out, so I suppose you might run into this issue if you have a very large number of promotion codes, do you think that's the case here?
Hi Ana, how can we pull data from the /payouts endpoint using the tool?
I see, it looks like /payouts is missing from our list of integrated endpoints, I'll get that added in. In the meantime, you can run a custom request to
https://api.stripe.com/v1/payouts
.Hi Ana, is there a way to get the date of the transaction ? When i select "list all charges" i get the data and a colunm "data.created" with this kind of number "1704986829" but apparently is not a date.
Thanks for your help
Hey Simon, Stripe returns data using UNIX timestamps. To convert those to a "regular" date, set your data destination to B1 (so you have space to enter formulas in the first column) and then enter the following formula in cell A2:
=arrayformula(if(E2:E<>"",EPOCHTODATE(E2:E,1),""))
You'll need to replace the Es in that formula with whichever column letter holds those UNIX timestamps from Stripe.Let me know how that goes, and for more info please see this article: https://mixedanalytics.com/blog/convert-unix-timestamps-to-google-sheets-dates/
Update: You can now add this formula through the field editor.