As we mentioned in the first part of the article, today we will “approach” the EasyCargo API more from the practical side. We will use our API client for this. We will also test the operation of the API using the ReqBin online tool. It enables communication with a WWW server, thanks to which we can download data of interest from our EasyCargo container loading calculator. Testing is one thing, but in real life, you might be using a Java plugin for your software or Javascript calls from SAP. More on this, the Make platform and other real-world API use cases in the next post in this series.

 

EasyCargo API Client

See what the above request looks like in the ReqBin tool

 

The image above shows our API client for EasyCargo. To be able to send any API requests to the web server, the client must first be authorized. So the start request is a POST http://go.easycargo3d.com/api/v1/authentication with the username and API key in the content. You will receive an authentication token from the server in the response. Each subsequent (unless otherwise noted) API request should be authenticated by adding the obtained token in its header. It is worth noting here that all API requests made are made on behalf of the token owner. Requests and responses must be created in JSON or XML format.

Now that we’ve been authenticated, let’s finally get to the more interesting fun of the API. Let’s assume that user X has the following shipping loads stored in his account.

 

Saved shipments in EasyCargo load planning tool

We will practice API requests on them because shipping loads are probably the most important part of EasyCargo. Other requests such as user management are formulated in a similar way, so we believe that every reader of this article will be able to handle the creation of other requests. In our API documentation for EasyCargo, every method of the programming interface is described and explained.

If you have any doubts, please contact us at support@easycargo3d.com or use our contact form.

API requests about shipments

As the API documentation informs us, with properly worded requests we are able to get a list of all shipping loads from the server, as well as data about a specific load from the EasyCargo account. We can even create or deleteload from the account.

Getting list of all shipments

 

Get list of shipments

See what the above request looks like in the ReqBin tool

 

Getting data about a specific shipment

 

Getting data about a specific shipment

See what the above request looks like in the ReqBin tool

 

Creating a shipment

 

Creating a shipment

See what the above request looks like in the ReqBin tool

 

Successfully saved shipment via API in EasyCargo

As you can see, the load was successfully saved to your EasyCargo account.

 

Loading created by the API method

You can simply open the loading created by the API method in your application.

 

Deleting a shipment

 

Deleting a shipment

See what the above request looks like in the ReqBin tool

 

Removed shipment from an EasyCargo account

The shipping load was correctly removed from your EasyCargo account with the appropriate request.

A few more words about the API

  • The number of your API requests is limited in time (60 requests per 1 hour). The quotas are checked by moving time frame, so at any given time period is allowed only the specified number of requests.
  • API errors are sent back by common HTTP status codes. In most cases, the response body contains a specific message about what went wrong.
  • The load planning calculation cannot be executed through the API.
  • Your API client has to support accessing and modifying the request and response header and parsing either JSON or XML data format.
  • The API user has to sign into the EasyCargo application so that the calculation of the load plan can be processed.
  • Some API methods support the use of optional parameters, such as from. You will naturally learn the meaning of each of them from the documentation. You can use these parameters, for example, when requesting to get a list of all payloads. Just add them to the resource address after the “?” character, separated by the “&” character in the form name=value, e.g. http://go.easycargo3d.com/api/v1/shipments?from=2020-01-02&offset=0&limit=100.

Coming to the conclusion of this article, API is a very useful service. We hope that this practical description has explained to you more about how a programming interface works. Today’s article is the second in a series about the API for EasyCargo, so if you haven’t seen the first part yet, you can find it here. The programming interface opens a floodgate of possibilities. In the next post, you will find out what benefits you can have from using our API and learn about its real-life use cases.

Anna Melounová | 20. يونيو 2022