Typeform to BigQuery

This page provides you with instructions on how to extract data from Typeform and load it into Google BigQuery. (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.

What is Google BigQuery?

Google BigQuery is a data warehouse that delivers super-fast results from SQL queries, which it accomplishes using a powerful engine dubbed Dremel. With BigQuery, there's no spinning up (and down) clusters of machines as you work with your data. With that said, it's clear why some claim that BigQuery prioritizes querying over administration. It's super fast, and that's the reason why most folks use it.

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 Google BigQuery

Google Cloud Platform offers a helpful guide for loading data into BigQuery. You can use the bq command-line tool to upload the files to your awaiting datasets, adding the correct schema and data type information along the way. The bq load command is your friend here. You can find the syntax in the bq command-line tool quickstart guide. Iterate through this process as many times as it takes to load all of your tables into BigQuery.

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

BigQuery is great, but sometimes you need to optimize for different things when you're choosing a data warehouse. Some folks choose to go with Amazon Redshift, 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 Redshift, 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 Google BigQuery 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 Google BigQuery data warehouse.