Close.io to BigQuery

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

Close.io is a CRM tool aimed at startups and small and medium-sized businesses (SMB). It's easy to set up and easy to administer, and provides integrated calling along with built-in email automation.

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

For starters, you need to get your data out of Close.io. That can be done by making calls to the Close.io REST API. The full documentation for the API can be found here.

To use the Close.io REST API, your script needs to make HTTP requests, and parse the response. The API uses JSON as its communication format. The standard HTTP methods like GET, PUT, POST and DELETE are going to be your major tools here.

Close.io’s API offers access to leads, which is the main building block for Close.io data. Using methods outlined in the API documentation, you can retrieve the data you’d like to move to your data warehouse.

Sample Close.io data

When you query the Close.io API, it will return JSON formatted data. Below is an example response from the leads endpoint.

{
    "has_more": false,
    "data": [
        {
            "id": "stat_1ZdiZqcSIkoGVnNOyxiEY58eTGQmFNG3LPlEVQ4V7Nk",
            "label": "Potential"
        },
        {
            "id": "stat_2ZdiZqcSIkoGVnNOyxiEY58eTGQmFNG3LPlEVQ4V7Nk",
            "label": "Bad Fit"
        },
        {
            "id": "stat_3ZdiZqcSIkoGVnNOyxiEY58eTGQmFNG3LPlEVQ4V7Nk",
            "label": "Qualified"
        },
        {
            "id": "stat_8ZdiZqcSIkoGVnNOyxiEY58eTGQmFNG3LPlEVQ4V7Nk",
            "label": "Not Serious"
        }
    ]
}

Preparing Close.io data

Now that you’ve got JSON, you need to map all those data fields into a schema that can be inserted into your destination database. This means that, for each value in the response, you need to identify a predefined data type (i.e. INTEGER, DATETIME, etc.) and build a table that can receive them.

Check out the Stitch Close.io Documentation to get a good sense of what fields and data types will be provided by each endpoint. Once you have identified all of the columns you will want to insert, go ahead and build a destination table that will receive all of this data.

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

Ok, you’ve built a script that requests data from Close.io and moves it into your data warehouse. What happens next week when you need to access the most recent leads? It’s also important to consider the situation where an entry in your destination needs to be updated to a new value. This functionality is crucial to your script actually being useful down the line. The last thing to do is set your script up as a cron job or continuous loop to keep pulling new data as it appears.

Other data warehouse options

BigQuery is really great, but sometimes you need to optimize for different things when you're choosing a data warehouse. Some folks choose to go with Postgres or Redshift, which are two RDBMSes that use similar SQL syntax. If you're interested in seeing the relevant steps for loading this data into Postgres or Redshift, check out To Redshift and 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 Close.io data via the API, structuring it in a way that is optimized for analysis, and inserting that data into your Google BigQuery data warehouse.