Documentation

Overview

How to get your API Key?

Before you started with using our REST API services, you will need to obtain your API key under your own user account.

  1. Login to your AfterShip account. If you don't already have one - Signup. It's FREE
  2. Visit Settings > API
  3. Give your api-key a name and click Generate

API endpoint

Once you've generated your API key, it's easy to start requesting data from AfterShip.

All endpoints are only accessible via https and are located at api.aftership.com.

https://api.aftership.com/v4

Headers

All API call must include this header in order to auth the usage of AfterShip API.

Replace your YOUR_API_KEY with your own key.

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

Body

All the request and response are in JSON string.


Limit

Be nice. If you're sending too many requests too quickly, we'll send back a 429 error code (TooManyRequests).

You are limited to 600 reqs/min per account. Practically, this means you should (when possible) authenticate users so that limits are well outside the reach of a given user.

The API response headers also give you the following X-RateLimit value

HeaderExampleDescription
X-RateLimit-Reset1406096275The unix timestamp when the rate limit will be reset.
X-RateLimit-Limit600The rate limit ceiling for your account per min.
X-RateLimit-Remaining598The number of requests left for the 1 minute window.

The Envelope

Every response is contained by an envelope. That is, each response has a predictable set of keys with which you can expect to interact:

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

META

The meta key is used to communicate extra information about the response to the developer. If all goes well, you'll only ever see a code key with value 200. However, sometimes things go wrong, and in that case you might see a response like:

{
    "meta": {
        "code": 401,
        "message": "Invalid API Key.",
        "type": "Unauthorized"
    },
    "data": {}
}

DATA

The data key is the meat of the response. It may be a list of results, but either way this is where you'll find the data you requested.

Here is the example for GET /couriers

{
    "meta": {
        "code": 200
    },
    "data": {
        "couriers": [
            {},
            {},
            {}
        ]
    }
}