Search API Connector Documentation

Print

Import AfterShip Data to Google Sheets

In this guide, we’ll pull AfterShip data into Google Sheets, using the API Connector add-on for Sheets. AfterShip is an eCommerce shipping tracking service that allows you to get shipping data for over 697 couriers around the world! Let’s jump in and start exploring what kind of data we can pull into Google Sheets.

CONTENTS

BEFORE YOU BEGIN

Click here to install the API Connector add-on from the Google Marketplace.

PART 1: GET YOUR API KEY FROM AFTERSHIP

  1. After signing up or logging in, you will need to fetch your API key. From the admin website, head to Settings -> API Keys.
    aftership-img1
  2. There will be a pre-generated API key you can use just fine, otherwise you can generate a new one if you fancy. That’s it, you now have access to the Aftership API!
    aftership-img2

PART 2: CREATE YOUR API REQUEST URL

The API Request URL we will put into API Connector will consist of the base URL and an endpoint. Let’s setup an endpoint to GET all the couriers supported by AfterShip.

  • Base URL: https://api.aftership.com/v4
  • Endpoint: /couriers/all

Putting it together, we get the full API request URL:

https://api.aftership.com/v4/couriers/all

PART 3: PULL AFTERSHIP API DATA INTO SHEETS

We can now enter this URL into API Connector and import Aftership data into Google Sheets.

In API Connector, enter your URL along with your aftership-api-key as the key and YOUR_API_KEY as the value under headers. You should have something like the following picture:

aftership-img3

Save and Run your API Request. Congratulations! You should now have a list of 711 or more couriers that are supported by AfterShip, something like below:

aftership-img4

Part 4: Create an AfterShip API Request URL To Get Courier Based On Tracking Number

Contrary to what this section header says, you will actually need to make a POST request in order to get back this data.

What data is that you say?

Say you have a shipping number, like “906587618687” for example, and you need to figure out which courier service it is, then this part is for you!

Just like earlier, you will need to setup a base URL along with the appropriate end point. Let’s set that up below:

  • Base URL: https://api.aftership.com/v4
  • Endpoint: /couriers/detect

Combine these along with your aftership-api-key as the key and YOUR_API_KEY as the value under headers. You will need to manually add another key and value pair of content-type and application/json respectively.

Next, because this is a POST request, you will need to add some text to the “POST body”. For this particular service, it will need to have the following format (you may copy and paste the below code for demonstration sake):

{
"tracking": {
"tracking_number": "906587618687"
}
}

That should be everything. Let’s check real quick and make sure everything is filled in correctly:

aftership-img5

PART 5: POST YOUR REQUEST TO GET COURIER SERVICE

After saving and running your POST command, you should get back an entry that says which courier service is/was responsible for this tracking number. In our example case, it’s FedEx!

aftership-img6

PART 6: OTHER AVAILABLE ENDPOINTS

There are loads more endpoints you can mess around with over in the documentation. I’ve done some digging for you and found a few that may be interesting:

  • https://api.aftership.com/v4/last_checkpoint/:slug/:tracking_number
  • https://api.aftership.com/v4/notifications/:slug/:tracking_number

Note: “:slug” refers to the slug for the courier service. You can see what these are from the results in Part 3.

PART 7: HANDLE PAGINATION

By default, Aftership will send through a limited number of tracking records unless you add the page and limit parameters as shown in their documentation.

You can run through these request URLs manually, or use API Connector’s pagination handling function to loop through these pages automatically, like this:

  • API URL: https://api.aftership.com/v4/trackings?page=1&limit=200
  • Pagination type: page parameter
  • Page parameter: page
  • Number of pages: enter the number of pages you’d like to fetch
    aftership-img8

2 thoughts on “Import AfterShip Data to Google Sheets”

Leave a Comment