Emissions API
Calculate the greenhouse gas emissions of moving cargo along a transport chain, by road, rail, water, and air, including logistics hubs.
POST /emissions/calculateDistance API
Calculate the routes and distances of a transport chain, with the resolved locations, airports, harbors, and rail yards, without calculating emissions.
POST /routes/calculateChoose an API
Both APIs route a shipment the same way – the same locations, transport modes, airports, harbors, rail yards, ferries, and fallbacks – so the routes and distances from the Distance API match those used by the Emissions API for the same request.
Before you begin
You need:- A TerraTwin account
- An API key from Manage API Keys
- Credits for the API you want to use – see Credits & usage
- A way to send an HTTP request, such as
curlor the HTTP client of your programming language
What every API has in common
Base URL
All transport APIs are served from:
https://api.terratwin.com/api/v1/transportationAuthentication
Send your API key in the
x-api-key header of every request. The same key works for every API.See API keys.Credits
Each API has its own credit balance on your account, and a request only ever uses the balance of the API it calls.See Credits & usage.
Rate limits
Each account can send up to 5 requests per second, across all APIs. Requests above this are rejected with
429 Too Many Requests; retry after a short delay.The same request, two answers
Both APIs take a shipment described as anorigin, a destination, and an ordered transportChain of transport operations.
This request moves cargo from Berlin to London by road:
your-api-key with your TerraTwin API key and save the request above as request.json:
- Emissions API
- Distance API
totalEmissions.co2eGrams, along with the distance and the vehicle defaults TerraTwin used.Errors and troubleshooting
All TerraTwin APIs report errors in the same way. Error responses includetitle, status, code, details, and recommendation properties. Start with details, which normally identifies the field, location, or operation that failed, and then follow recommendation.
When the error was caused by the content of the request, the response also includes an errors array, following RFC 9457. Each entry has a pointer, a JSON Pointer to the request property at fault, and a short detail. Use the pointer to find the property in your request programmatically, for example to highlight the field or the source data it came from.
#/transportChain/0/location is the location of the first transport chain element. A pointer can refer to an object rather than a single property when the problem concerns the object as a whole, as in this example.
For field level validation rules and the complete error code list, see the API reference for the Emissions API or the Distance API.