Endpoint
The endpoint is served from
https://api.terratwin.com/api/v1/transportation and needs your API key in the x-api-key header.
Same routing as the Emissions API
A Distance API request is routed exactly as the Emissions API routes the same request: the same location matching, transport modes, fallback modes, airports, stopovers, harbors, ferries, and rail yards. So the routes and distances it returns are the ones an emissions calculation of that shipment is based on.The Distance API returns the routed distances as they are. The Emissions API applies distance adjustment factors to some modes when calculating emissions, so the distance used in an emissions calculation can be slightly longer than the Distance API’s.
The request
The request has the same structure as an emissions request:
Each transport operation is one of
ROAD, RAIL, WATER, AIR, or UNKNOWN.
Operation properties that affect the route – such as the vessel and navigation constraints of a WATER leg, or the aircraft of an AIR leg – work as described in each mode’s guide.
Compared with the Emissions API, a Distance API request doesn’t take:
WEIGHTED_MODESoperationsfirstMileandlastMileonAIR,RAIL, andWATERoperations – connecting road journeys are still routed and included in the distanceshubTypeon aHUB– a hub only needs atypeand alocation, and marks where one leg ends and the next begins- The emissions-only options
storeResult,hubInsertion, anddefaultHubTypes
Options
The response
Each leg in
transportChain has:
type– the mode of the leg. For anUNKNOWNoperation, it’s the fallback mode that was used.startandend– the resolved locations where the leg begins and ends.distanceKm– the distance of the leg, including its connecting road journeys.elements– the operations that make up the leg, in order. AWATERleg from an address, for example, is aROADjourney to the departure harbor followed by theWATERvoyage.AIRelements show the aircraft, andWATERelements the vessel and its capacity band.subOperationson aROADelement – roll-on/roll-off ferry (WATER) and train (RAIL) crossings, such as the Channel Tunnel shuttle.
Credits
Distance API requests are charged to your account’s Distance API credits, counted in the same way as for the Emissions API – one credit per transport operation – see Credits & usage. If your account has no Distance API credits left, requests are rejected with403 and error code 42, “Your account has no remaining route credits”. Emissions API credits are never used for Distance API requests.
Related
Emissions API
Need the emissions of the journey as well? The Emissions API takes the same transport chain and calculates its emissions.
API reference
Every request field, response object, and error code of the Distance API.