AfterShip to BigQuery

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

About Aftership

AfterShip is a tracking service platform that helps businesses track shipments. AfterShip supports more than 400 carriers, and offers a free tier to businesses that make no more than 100 shipments per month.

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 all of 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 AfterShip

Before you can extract data from AfterShip, you need to obtain an API key. Sign into your AfterShip account, go to Settings > API, specify a name for your API key, then click Generate.

Once you have an API key, you can visit the URL https://api.aftership.com/ to connect to an API endpoint and extract data. An API call must include this header:

aftership-api-key: YOUR_API_KEY
Content-Type: application/json

AfterShip limits you to no more than 600 requests per minute per account./p>

Preparing AfterShip for Redshift

The result of every API call is contained in an envelope, in the format:

{
    "meta": {
        "code": 200
    },
    "data": {}
}

The meta key provides information about the response. A value of 200 indicates success. If something goes wrong, you’ll get a difference numeric code, along with message and type objects that provide additional information. The data key contains the data objects that you ask for in your API call.

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.

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