Import Stripe Data to Google Sheets

Import Stripe Data to Google Sheets

Last Updated On October 23, 2019

Stripe is a popular payment processor known for its fantastic APIs. In this guide, we’ll walk through how to pull transactions from the Stripe API directly into Google Sheets, using the free API Connector add-on for Google Sheets. We’ll first get an API key from Stripe, and then set up a request to pull in metrics from Stripe to your spreadsheet.

PART 1: GET YOUR STRIPE API KEY

  1. Log in to Stripe and click Developers > API keys from the left-hand menu
    stripe-img1
  2. 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:
    stripe-img2
  3. Once you have your key, copy it to your clipboard as we’ll need it shortly.

PART 2: CREATE YOUR 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={number of records}
    Parameters Example: ?limit=100

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

PART 3: ENTER VALUES INTO API CONNECTOR

We can now enter all our values into API Connector to start importing Stripe data into Google Sheets.

  1. Open up Google Sheets and click Add-ons > API Connector > Create New API Request.
  2. In the Create Request interface, enter the Request URL we just created
    stripe-img3
  3. Under headers, enter a key-value pair like this:
    Authorization Bearer {Secret Token}

    Replace {Secret Token} with the secret token you got above in step 3 above.
    stripe-img4

  4. Create a new tab. You can call it whatever you like, but here we’ll call it ‘Stripe Charges’. While still in that tab, click ‘Set’ to use that tab as your data destination.
  5. Name your request. Again we’ll call it ‘Stripe Charges’
  6. Click Run and a moment later you’ll see sales data populate the Stripe Charges tab in your Google Sheet:
    stripe-img5

PART 4: NOTES AND EXPANSIONS

  1. 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
  2. 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, e.g. 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.
  3. If the request returns more than 100 records, it will likely help to build requests based off the value in a cell. Then, if the first 100 rows get returned to a sheet called ‘Stripe’, dynamically retrieve the second page of results by adding a variable to the URL like this: https://api.stripe.com/v1/charges?limit=100&starting_after=+++Stripe!B101+++. Cell B101 contains the 100th object ID, so this approach lets you automatically pull in additional pages of records without needing to update your request.

    Once all the records have been returned, you can consolidate these API responses into a single sheet using a Sheets formula like this: =query({Stripe!A1:DB101;Stripe2!A2:DB101})

Comments:0

Leave a Reply

Your email address will not be published.