Close.io to Snowflake

This page provides you with instructions on how to extract data from Close.io 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 Close.io?

Close.io provides an inside sales SaaS and CRM platform that bundles calling, SMS, and email in a single platform. Users can make and receive calls and take business notes without getting on a phone or leaving the application. The software provides a single automated sales workflow system.

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 Close.io

You can use Close.io's REST API to get data about contacts, leads, opportunities, and many more objects into your data warehouse. For example, to get a lead, you could GET /lead/{id}/.

Sample Close.io data

Here's an example of the kind of response you might see when querying a lead.

{
    "status_id": "stat_1ZdiZqcSIkoGVnNOyxiEY58eTGQmFNG3LPlEVQ4V7Nk",
    "status_label": "Potential",
    "tasks": [],
    "display_name": "Wayne Enterprises (Sample Lead)",
    "addresses": [],
    "name": "Wayne Enterprises (Sample Lead)",
    "contacts": [
        {
            "name": "Bruce Wayne",
            "title": "The Dark Knight",
            "date_updated": "2019-01-06T20:53:01.954000+00:00",
            "phones": [
                {
                    "phone": "+16503334444",
                    "phone_formatted": "+1 650-333-4444",
                    "type": "office"
                }
            ],
            "created_by": null,
            "id": "cont_o0kP3Nqyq0wxr5DLWIEm8mVr6ZpI0AhonKLDG0V5Qjh",
            "organization_id": "orga_bwwWG475zqWiQGur0thQshwVXo8rIYecQHDWFanqhen",
            "date_created": "2019-01-01T00:54:51.331000+00:00",
            "emails": [
                {
                    "type": "office",
                    "email_lower": "thedarkknight@close.io",
                    "email": "thedarkknight@close.io"
                }
            ],
            "updated_by": "user_04EJPREurd0b3KDozVFqXSRbt2uBjw3QfeYa7ZaGTwI"
        }
    ],
    "custom.lcf_ORxgoOQ5YH1p7lDQzFJ88b4z0j7PLLTRaG66m8bmcKv": "Website contact form",
    "date_updated": "2019-01-06T20:53:01.977000+00:00",
    "html_url": "https://app.close.io/lead/lead_IIDHIStmFcFQZZP0BRe99V1MCoXWz2PGCm6EDmR9v2O/",
    "created_by": null,
    "organization_id": "orga_bwwWG475zqWiQGur0thQshwVXo8rIYecQHDWFanqhen",
    "url": null,
    "opportunities": [
        {
            "status_id": "stat_4ZdiZqcSIkoGVnNOyxiEY58eTGQmFNG3LPlEVQ4V7Nk",
            "status_label": "Active",
            "status_type": "active",
            "date_won": null,
            "confidence": 75,
            "user_id": "user_scOgjLAQD6aBSJYBVhIeNr6FJDp8iDTug8Mv6VqYoFn",
            "contact_id": null,
            "updated_by": null,
            "date_updated": "2019-01-01T00:54:51.337000+00:00",
            "value_period": "one_time",
            "created_by": null,
            "note": "Bruce needs new software for the Bat Cave.",
            "value": 50000,
            "value_formatted": "$500",
            "value_currency": "USD",
            "lead_name": "Wayne Enterprises (Sample Lead)",
            "organization_id": "orga_bwwWG475zqWiQGur0thQshwVXo8rIYecQHDWFanqhen",
            "date_created": "2019-01-01T00:54:51.337000+00:00",
            "user_name": "P F",
            "id": "oppo_8eB77gAdf8FMy6GsNHEy84f7uoeEWv55slvUjKQZpJt",
            "lead_id": "lead_IIDHIStmFcFQZZP0BRe99V1MCoXWz2PGCm6EDmR9v2O"
        },
        {
            "id": "oppo_klajsdflf8FMy6GsNHEy84f7uoeEWv55slvUjKQZpJt",
            "organization_id": "orga_bwwWG475zqWiQGur0thQshwVXo8rIYecQHDWFanqhen",
            "lead_id": "lead_IIDHIStmFcFQZZP0BRe99V1MCoXWz2PGCm6EDmR9v2O",
            "lead_name": "Wayne Enterprises (Sample Lead)",
            "status_id": "stat_4ZdiZqcSIkoGVnNOyxiEY58eTGQmFNG3LPlEVQ4V7Nk",
            "status_label": "Active",
            "status_type": "active",
            "value": 5000,
            "value_period": "monthly",
            "value_formatted": "$50 monthly",
            "value_currency": "USD",
            "date_won": null,
            "confidence": 75,
            "note": "Bat Cave monthly maintenance cost",
            "user_id": "user_scOgjLAQD6aBSJYBVhIeNr6FJDp8iDTug8Mv6VqYoFn",
            "user_name": "P F",
            "contact_id": null,
            "created_by": null,
            "updated_by": null,
            "date_created": "2019-01-01T00:54:51.337000+00:00",
            "date_updated": "2019-01-01T00:54:51.337000+00:00"
        }
    ],
    "updated_by": "user_04EJPREurd0b3KDozVFqXSRbt2uBjw3QfeYa7ZaGTwI",
    "date_created": "2019-01-01T00:54:51.333000+00:00",
    "id": "lead_IIDHIStmFcFQZZP0BRe99V1MCoXWz2PGCm6EDmR9v2O",
    "description": ""
}

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 Close.io data up to data

Now what? You've built a script that pulls data from Close.io and loads it into your data warehouse, but what happens tomorrow when you have new transactions?

The key is to build your script in such a way that it can identify incremental updates to your data. Thankfully, Close.io's API results include fields like date_created 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 Close.io data via the API, structuring it in a way that is optimized for analysis, and inserting that data into your Snowflake data warehouse.