Stripe to Redshift

This page provides you with instructions on how to extract data from Stripe’s backend and load it into Amazon Redshift. (If this manual process is a bit more involved than you’d prefer, check out Stitch, which can do all the heavy lifting for you in just a few clicks.)

Pulling Data Out of Stripe

Getting your Stripe data into AWS Redshift starts with pulling that data off of Stripe’s servers. You can do this using the Stripe API, and that documentation can be accessed here. Stripe’s API uses REST to allow customers to retrieve information on transactions and more.

Sample Stripe Data

The Stripe API returns JSON-formatted data. Below is an example of the kind of response you might see when querying for a transaction.

Stripe\Charge JSON: {
  "id": "ch_1743p92eZvKYlo2Cw2JNErfI",
  "object": "charge",
  "amount": 10400,
  "amount_refunded": 0,
  "application_fee": null,
  "balance_transaction": "txn_1728rq2eZvKYlo2C91cyTIf5",
  "captured": true,
  "created": 1446791747,
  "currency": "usd",
  "customer": "cus_3nkNHu4SYjMlBC",
  "description": null,
  "destination": null,
  "dispute": null,
  "failure_code": null,
  "failure_message": null,
  "fraud_details": {
  "invoice": "in_1742qw2eZvKYlo2C4zE3pp4a",
  "livemode": false,
  "metadata": {
  "paid": true,
  "receipt_email": null,
  "receipt_number": null,
  "refunded": false,
  "refunds": {
    "object": "list",
    "data": [

    "has_more": false,
    "total_count": 0,
    "url": "/v1/charges/ch_1743p92eZvKYlo2Cw2JNErfI/refunds"
  "shipping": null,
  "source": {
    "id": "card_103nkN2eZvKYlo2CzNg6Clei",
    "object": "card",
    "address_city": null,
    "address_country": null,
    "address_line1": null,
    "address_line1_check": null,
    "address_line2": null,
    "address_state": null,
    "address_zip": null,
    "address_zip_check": null,
    "brand": "Visa",
    "country": "US",
    "customer": "cus_3nkNHu4SYjMlBC",
    "cvc_check": null,
    "dynamic_last4": null,
    "exp_month": 12,
    "exp_year": 2023,
    "funding": "credit",
    "last4": "4242",
    "metadata": {
    "name": null,
    "tokenization_method": null
  "statement_descriptor": null,
  "status": "succeeded"

Preparing Stripe Data for Redshift

Here’s the tricky part: you need to map the data that comes out of each Stripe API endpoint into a schema that can be inserted into a Redshift database. This means that, for each value in the response, you need to identify a predefined datatype (i.e. INTEGER, DATETIME, etc.) and build a table that can receive them. The Stripe API documentation can give you a good sense of what fields will be provided by each endpoint, along with their corresponding datatypes.

Inserting Stripe Data into Redshift

Once you have identified all of the columns you will want to insert, you can use the CREATE TABLE statement in Redshift to create a table that can receive all of this data.

With a table built, it may seem like the easiest way to add your data (especially if there isn’t much of it), is to build INSERT statements to add data to your Redshift table row-by-row. If you have any experience with SQL, this will be your gut reaction. But beware! Redshift isn’t optimized for inserting data one row at a time, and if you have any kind of high-volume data being inserted, you would be much better off loading the data into Amazon S3 and then using the COPY command to load it into Redshift.

Keeping Data Up-To-Date

So, now what? You’ve built a script that pulls data from Stripe and loads it into Redshift, but what happens tomorrow when you have hundreds of new transactions?

The key is to build your script in such a way that it can also identify incremental updates to your data. Thankfully, Stripe’s API results include fields like “created” that allow you to quickly identify records that are new since your last update (or since the newest record you’ve copied into Redshift). You can set your script up as a cron job or continuous loop to keep pulling down new data as it appears.

Other Data Warehouse Options

Redshift is totally awesome, but sometimes you need to start smaller or optimize for different things. In this case, many people choose to get started with Postgres, which is an open source RDBMS that uses nearly identical SQL syntax to Redshift. If you’re interested in seeing the relevant steps for loading this data into Postgres, check out Stripe to Postgres

Easier and Faster Alternatives

If all this sounds a bit overwhelming, don’t be alarmed. If you have all the skills necessary to go through this process, chances are building and maintaining a script like this isn’t a very high-leverage use of your time.

Thankfully, products like Stitch were built to solve this problem automatically. With just a few clicks, Stitch starts extracting your Stripe data via the API, structuring it in a way that is optimized for analysis, and inserting that data into your Amazon Redshift data warehouse.