Typeform to Snowflake

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

Snowflake is a cloud-based data warehouse implemented as a managed service. It runs on the Amazon Web Services architecture using EC2 and S3 instances. Snowflake is designed to be fast, flexible, and easy to work with. For instance, for query processing, Snowflake creates virtual warehouses that run on separate compute clusters, so querying one virtual warehouse doesn't slow down the others.

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.

Preparing data for Snowflake

Depending on the structure of your data, you may need to prepare it for loading. Look at the supported data types for Snowflake and make sure that the data you've got will map neatly to them.

Note that you don't need to define a schema in advance when loading JSON data into Snowflake.

Loading data into Snowflake

The Snowflake documentation's Data Loading Overview section can help you with the task of loading your data. If you're not loading a lot of data, you might be able to use the data loading wizard in the Snowflake web UI, but chances are the limitations on that tool will make it a non-starter as a reliable ETL solution. Alternatively, there are two main steps for getting data into Snowflake:

  • Use the PUT command to stage files.
  • Use the COPY INTO table command to load prepared data into an awaiting table.

You’ll have the option of copying from your local drive or from Amazon S3. One of Snowflake's slick features lets you make a virtual warehouse that can power the insertion process.

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

Snowflake 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, Google BigQuery, PostgreSQL, or Microsoft Azure SQL Data Warehouse, which are RDBMSes that use similar SQL syntax, or Panoply, which works with Redshift instances. If you're interested in seeing the relevant steps for loading data into one of these platforms, check out To Redshift, To BigQuery, To Postgres, To Panoply, and To Azure SQL Data Warehouse.

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 Typeform data via the API, structuring it in a way that is optimized for analysis, and inserting that data into your Snowflake data warehouse.