Typeform to Redshift

This page provides you with instructions on how to extract data from Typeform and load it into Redshift. (If this manual process sounds onerous, check out Stitch, which can do all the heavy lifting for you in just a few clicks.)

What is Typeform?

Typeform lets companies build online forms, surveys, and quizzes without needing to write any code. Users can fill out forms on any platform, including mobile devices.

Getting data out of Typeform

Typeform has several APIs that you can use to get at information stored in the platform. For example, to retrieve a form response, you would call GET https://api.typeform.com/forms/{form_id}/responses.

Sample Typeform data

Here's an example of the kind of response you might see with a query like the one above.

{
  "total_items": 4,
  "page_count": 1,
  "items": [
    {
      "landing_id": "21085286190ffad1248d17c4135ee56f",
      "token": "21085286190ffad1248d17c4135ee56f",
      "landed_at": "2018-09-14T22:33:59Z",
      "submitted_at": "2018-09-14T22:38:22Z",
      "metadata": {
        "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8",
        "platform": "other",
        "referer": "https://user_id.typeform.com/to/lR6F4j",
        "network_id": "responsdent_network_id",
        "browser": "default"
      },
      "answers": [
        {
          "field": {
            "id": "hVONkQcnSNRj",
            "type": "dropdown",
            "ref": "my_custom_dropdown_reference"
          },
          "type": "text",
          "text": "Job opportunities"
        },
        {
          "field": {
            "id": "RUqkXSeXBXSd",
            "type": "yes_no",
            "ref": "my_custom_yes_no_reference"
          },
          "type": "boolean",
          "boolean": false
        },
        {
          "field": {
            "id": "gFFf3xAkJKsr",
            "type": "legal",
            "ref": "my_custom_legal_reference"
          },
          "type": "boolean",
          "boolean": true
        },
        {
          "field": {
            "id": "JwWggjAKtOkA",
            "type": "short_text",
            "ref": "my_custom_short_text_reference"
          },
          "type": "text",
          "text": "Lian"
        },
        {
          "field": {
            "id": "SMEUb7VJz92Q",
            "type": "email",
            "ref": "my_custom_email_reference"
          },
          "type": "email",
          "email": "lian1078@other.com"
        },
        {
          "field": {
            "id": "pn48RmPazVdM",
            "type": "number",
            "ref": "my_custom_number_reference"
          },
          "type": "number",
          "number": 1
        },
        {
          "field": {
            "id": "Q7M2XAwY04dW",
            "type": "number",
            "ref": "my_custom_number2_reference"
          },
          "type": "number",
          "number": 1
        },
        {
          "field": {
            "id": "WOTdC00F8A3h",
            "type": "rating",
            "ref": "my_custom_rating_reference"
          },
          "type": "number",
          "number": 3
        },
        {
          "field": {
            "id": "DlXFaesGBpoF",
            "type": "long_text",
            "ref": "my_custom_long_text_reference"
          },
          "type": "text",
          "text": "It's a big, busy city. I moved here for a job, but I like it, so I am planning to stay. I have made good friends here."
        },
        {
          "field": {
            "id": "NRsxU591jIW9",
            "type": "opinion_scale",
            "ref": "my_custom_opinion_scale_reference"
          },
          "type": "number",
          "number": 1
        },
        {
          "field": {
            "id": "PNe8ZKBK8C2Q",
            "type": "picture_choice",
            "ref": "my_custom_picture_choice_reference"
          },
          "type": "choices",
          "choices": {
            "labels": [
              "New York",
              "Tokyo"
            ]
          }
        },
        {
          "field": {
            "id": "KoJxDM3c6x8h",
            "type": "date",
            "ref": "my_custom_date_reference"
          },
          "type": "date",
          "date": "2012-03-20T00:00:00Z"
        },
        {
          "field": {
            "id": "ceIXxpbP3t2q",
            "type": "multiple_choice",
            "ref": "my_custom_multiple_choice_reference"
          },
          "type": "choice",
          "choice": {
            "label": "A friend's experience in Sydney"
          }
        },
        {
          "field": {
            "id": "k6TP9oLGgHjl",
            "type": "multiple_choice",
            "ref": "my_custom_multiple_choice2_reference"
          },
          "type": "choice",
          "choice": {
            "label": "Tokyo"
          }
        }
      ],
      "hidden": {},
      "calculated": {
        "score": 2
      }
    },
    {
      "landing_id": "610fc266478b41e4927945e20fe54ad2",
      "token": "610fc266478b41e4927945e20fe54ad2",
      "landed_at": "2018-09-14T22:27:38Z",
      "submitted_at": "2018-09-14T22:33:56Z",
      "metadata": {
        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36",
        "platform": "other",
        "referer": "https://user_id.typeform.com/to/lR6F4j",
        "network_id": "responsdent_network_id",
        "browser": "default"
      },
      "answers": [
        {
          "field": {
            "id": "k6TP9oLGgHjl",
            "type": "multiple_choice",
            "ref": "my_custom_multiple_choice2_reference"
          },
          "type": "choice",
          "choice": {
            "label": "New York"
          }
        },
        {
          "field": {
            "id": "X4BgU2f1K6tG",
            "type": "file_upload",
            "ref": "my_custom_file_upload_reference"
          },
          "type": "file_url",
          "file_url": "https://admin.typeform.com/form/lT9Z2j/field/X4BgU2f1K6tG/results/afd8258fd453-aerial_view_rural_city_latvia_valmiera_urban_district_48132860.jpg/download"
        },
        {
          "field": {
            "id": "ceIXxpbP3t2q",
            "type": "multiple_choice",
            "ref": "my_custom_multiple_choice_reference"
          },
          "type": "choice",
          "choice": {
            "label": "Other"
          }
        },
        {
          "field": {
            "id": "hVONkQcnSNRj",
            "type": "dropdown",
            "ref": "my_custom_dropdown_reference"
          },
          "type": "text",
          "text": "Cost of living"
        },
        {
          "field": {
            "id": "JwWggjAKtOkA",
            "type": "short_text",
            "ref": "my_custom_short_text_reference"
          },
          "type": "text",
          "text": "Sarah"
        },
        {
          "field": {
            "id": "RUqkXSeXBXSd",
            "type": "yes_no",
            "ref": "my_custom_yes_no_reference"
          },
          "type": "boolean",
          "boolean": true
        },
        {
          "field": {
            "id": "Fep7sEoBsnvC",
            "type": "long_text",
            "ref": "my_custom_long_text_reference"
          },
          "type": "text",
          "text": "I read a magazine article about traveling to Sydney"
        },
        {
          "field": {
            "id": "gFFf3xAkJKsr",
            "type": "legal",
            "ref": "my_custom_legal_reference"
          },
          "type": "boolean",
          "boolean": true
        },
        {
          "field": {
            "id": "BFcpoPU5yJPM",
            "type": "short_text",
            "ref": "my_custom_short_text_reference"
          },
          "type": "text",
          "text": "San Francisco"
        },
        {
          "field": {
            "id": "SMEUb7VJz92Q",
            "type": "email",
            "ref": "my_custom_rmail_reference"
          },
          "type": "email",
          "email": "sarahbsmith@example.com"
        },
        {
          "field": {
            "id": "pn48RmPazVdM",
            "type": "number",
            "ref": "my_custom_number_reference"
          },
          "type": "number",
          "number": 1
        },
        {
          "field": {
            "id": "WOTdC00F8A3h",
            "type": "rating",
            "ref": "my_custom_rating_reference"
          },
          "type": "number",
          "number": 3
        },
        {
          "field": {
            "id": "Q7M2XAwY04dW",
            "type": "number",
            "ref": "my_custom_number2_reference"
          },
          "type": "number",
          "number": 3
        },
        {
          "field": {
            "id": "DlXFaesGBpoF",
            "type": "long_text",
            "ref": "my_custom_long_text_reference"
          },
          "type": "text",
          "text": "It's a rural area. Very quiet. There are a lot of farms...farming is the major industry here."
        },
        {
          "field": {
            "id": "NRsxU591jIW9",
            "type": "opinion_scale",
            "ref": "my_custom_opinion_scale_reference"
          },
          "type": "number",
          "number": 1
        },
        {
          "field": {
            "id": "KoJxDM3c6x8h",
            "type": "date",
            "ref": "my_custom_date_reference"
          },
          "type": "date",
          "date": "2016-05-13T00:00:00Z"
        },
        {
          "field": {
            "id": "PNe8ZKBK8C2Q",
            "type": "picture_choice",
            "ref": "my_custom_picture_choice_reference"
          },
          "type": "choices",
          "choices": {
            "labels": [
              "London",
              "New York"
            ]
          }
        }
      ],
      "hidden": {},
      "calculated": {
        "score": 4
      }
    },
    {
      "landing_id": "9ba5db11ec6c63d22f08aade805bd363",
      "token": "9ba5db11ec6c63d22f08aade805bd363",
      "landed_at": "2018-09-14T22:24:49Z",
      "submitted_at": "2018-09-14T22:27:34Z",
      "metadata": {
        "user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 10_2_1 like Mac OS X) AppleWebKit/602.4.6 (KHTML, like Gecko) Version/10.0 Mobile/14D27 Safari/602.1",
        "platform": "other",
        "referer": "https://user_id.typeform.com/to/lR6F4j",
        "network_id": "responsdent_network_id",
        "browser": "default"
      },
      "answers": [
        {
          "field": {
            "id": "RUqkXSeXBXSd",
            "type": "yes_no",
            "ref": "my_custom_yes_no_reference"
          },
          "type": "boolean",
          "boolean": false
        },
        {
          "field": {
            "id": "gFFf3xAkJKsr",
            "type": "legal",
            "ref": "my_custom_legal_reference"
          },
          "type": "boolean",
          "boolean": true
        },
        {
          "field": {
            "id": "JwWggjAKtOkA",
            "type": "short_text",
            "ref": "my_custom_short_text_reference"
          },
          "type": "text",
          "text": "Paolo"
        },
        {
          "field": {
            "id": "pn48RmPazVdM",
            "type": "number",
            "ref": "my_custom_number_reference"
          },
          "type": "number",
          "number": 5
        },
        {
          "field": {
            "id": "Q7M2XAwY04dW",
            "type": "number",
            "ref": "my_custom_number2_reference"
          },
          "type": "number",
          "number": 5
        },
        {
          "field": {
            "id": "PNe8ZKBK8C2Q",
            "type": "picture_choice",
            "ref": "my_custom_picture_choice_reference"
          },
          "type": "choices",
          "choices": {
            "labels": [
              "Barcelona",
              "Sydney"
            ]
          }
        },
        {
          "field": {
            "id": "WOTdC00F8A3h",
            "type": "rating",
            "ref": "my_custom_rating_reference"
          },
          "type": "number",
          "number": 5
        },
        {
          "field": {
            "id": "DlXFaesGBpoF",
            "type": "long_text",
            "ref": "my_custom_long_text_reference"
          },
          "type": "text",
          "text": "I live in a medium-sized European city. It's not too crowded, and the people are nice. I like the weather. It's also easy to travel to many beautiful and interesting vacation destinations from where I live."
        },
        {
          "field": {
            "id": "NRsxU591jIW9",
            "type": "opinion_scale",
            "ref": "my_custom_opinion_scale_reference"
          },
          "type": "number",
          "number": 4
        },
        {
          "field": {
            "id": "KoJxDM3c6x8h",
            "type": "date",
            "ref": "my_custom_date_reference"
          },
          "type": "date",
          "date": "1999-08-01T00:00:00Z"
        },
        {
          "field": {
            "id": "k6TP9oLGgHjl",
            "type": "multiple_choice",
            "ref": "my_custom_multiple_choice_reference"
          },
          "type": "choice",
          "choice": {
            "label": "Barcelona"
          }
        }
      ],
      "hidden": {},
      "calculated": {
        "score": 10
      }
    },
    {
      "landing_id": "5fcb3f9c162e1fcdaadff4405b741080",
      "token": "5fcb3f9c162e1fcdaadff4405b741080",
      "landed_at": "2018-09-15T09:09:30Z",
      "submitted_at": "0001-01-01T00:00:00Z",
      "metadata": {
        "user_agent": "Mozilla/5.0 (Linux; Android 4.1.2; GT-N7000 Build/JZO54K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.91 Mobile Safari/537.36",
        "platform": "other",
        "referer": "https://user_id.typeform.com/to/lR6F4j",
        "network_id": "responsdent_network_id",
        "browser": "default"
      },
      "answers": null,
      "hidden": {},
      "calculated": {
        "score": 0
      }
    }
  ]
}

Preparing Typeform data

If you don't already have a data structure in which to store the data you retrieve, you'll have to create a schema for your data tables. Then, for each value in the response, you'll need to identify a predefined datatype (INTEGER, DATETIME, etc.) and build a table that can receive them. Typeform's documentation should tell you what fields are provided by each endpoint, along with their corresponding datatypes.

Complicating things is the fact that the records retrieved from the source may not always be "flat" – some of the objects may actually be lists. In these cases you'll likely have to create additional tables to capture the unpredictable cardinality in each record.

Loading 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 migrate 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. If you have a high volume of data to be inserted, you would be better off loading the data into Amazon S3 and then using the COPY command to load it into Redshift.

Keeping Typeform data up to date

At this point you've coded up a script or written a program to get the data you want and successfully moved it into your data warehouse. But how will you load new or updated data? It's not a good idea to replicate all of your data each time you have updated records. That process would be painfully slow and resource-intensive.

The key is to build your script in such a way that it can identify incremental updates to your data. Thankfully, Typeform's API results include fields like submitted_at that allow you to identify records that are new since your last update (or since the newest record you've copied). Once you've take new data into account, 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 great, but sometimes you need to optimize for different things when you're choosing a data warehouse. Some folks choose to go with Google BigQuery, PostgreSQL, Snowflake, or Microsoft Azure SQL Data Warehouse, which are RDBMSes that use similar SQL syntax, or Panoply, which works with Redshift instances. Others choose a data lake, like Amazon S3. If you're interested in seeing the relevant steps for loading data into one of these platforms, check out To BigQuery, To Postgres, To Snowflake, To Panoply, To Azure SQL Data Warehouse, and To S3.

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 move data from Typeform to Redshift automatically. With just a few clicks, Stitch starts extracting your Typeform data via the API, structuring it in a way that is optimized for analysis, and inserting that data into your Redshift data warehouse.