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

PART 1: GET YOUR API KEY FROM AFTERSHIP

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

There will be a pre-generated API key you can use just fine, otherwise you can generate a new one if you fancy.

aftership-img2

PART 2: CREATE AN AFTERSHIP API REQUEST URL FOR COURIER DATA

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

Combine these 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

PART 3: PULL FULL COURIER LIST INTO SHEETS

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.

2 thoughts on “Import AfterShip Data to Google Sheets”

Leave a Comment