3. List Your Shipments & Containers
Shipment and Container Data in Terminal49
After you’ve successfully made a tracking request, Terminal49 will begin to track shipments and store relevant information about that shipment on your behalf.
The initial tracking request starts this process, collecting available data from Carriers and Terminals. Then, Terminal49 periodically checks for new updates adn pulls data from the carriers and terminals to keep the data we store up to date.
You can access data about shipments and containers on your tracked shipments any time. We will introduce the basics of this method below.
Keep in mind, however, that apart from initialization code, you would not usually access shipment data in this way. You would use Webhooks (described in the next section). A Webhook is another name for a web-based callback URL, or a HTTP Push API. They provide a method for an API to post a notification to your service. Specifically, a webhook is simply a URL that can receive HTTP Post Requests from the Terminal49 API.
List all your Tracked Shipments
If your tracking request was successful, you will now be able to list your tracked shipments.
Try it below. Click “Headers” and replace YOUR_API_KEY with your API key.
Sometimes it may take a while for the tracking request to show up, but usually no more than a few minutes.
If you had trouble adding your first shipment, try adding a few more.
We suggest copy and pasting the response returned into a text editor so you can examine it while continuing the tutorial.
Why so much JSON? (A note on JSON API)
The Terminal49 API is JSON API compliant, which means that there are nifty libraries which can translate JSON into a fully fledged object model that can be used with an ORM. This is very powerful, but it also requires a larger, more structured payload to power the framework. The tradeoff, therefore, is that it’s less convenient if you’re parsing the JSON directly. Ultimately we strongly recommend you set yourself up with a good library to use JSON API to its fullest extent. But for the purposes of understanding the API’s fundamentals and getting your feet wet, we’ll work with the data directly.
Authentication
The API uses HTTP Bearer Token authentication.
This means you send your API Key as your token in every request.
Webhooks are associated with API tokens, and this is how the Terminal49 knows who to return relevant shipment information to.
Anatomy of Shipments JSON Response
Here’s what you’ll see come back after you get the /shipments endpoint.
Note that for clarity I’ve deleted some of the data that is less useful right now, and replaced them with ellipses (…). Bolded areas are also mine to point out important data.
The Data attribute contains an array of objects. Each object is of type “shipment” and includes attributes such as bill of lading number, the port of lading, and so forth. Each Shipment object also has Relationships to structured data objects, for example, Ports and Terminals, as well as a list of Containers which are on this shipment.
You can write code to access these structured elements from the API. The advantage of this approach is that Terminal49 cleans and enhances the data that is provided from the steamship line, meaning that you can access a pre-defined object definition for a specific port in Los Angeles.
Sample Code: Listing Tracked Shipment into a Google Sheet
Below is code written in Google App Script that lists the current shipments into the current sheet of a spreadsheet. App Script is very similar to Javascript.
Because Google App Script does not have native JSON API support, we need to parse the JSON directly, making this example an ideal real world application of the API.
List all your Tracked Containers
You can also list out all of your Containers. Container data includes Terminal availability, last free day, and other logistical information that you might use for drayage operations at port.
Try it below. Click “Headers” and replace YOUR_API_KEY with your API key.
We suggest copy and pasting the response returned into a text editor so you can examine it while continuing the tutorial.
Anatomy of Containers JSON Response
Now that you’ve got a list of containers, let’s examine the response you’ve received.
Was this page helpful?