Response Structure – Independent Endpoint
In this example, we have a simple route that passes through the Itaquaquecetuba tollbooth. We will use the independent endpoint to calculate the tolls.
Request
The parameter legs
is an array of objects where each object represents a section of the route. In each leg
, define the parameter points
, which contains the coordinates that make up the route. In this case, we only have one leg
which corresponds to the entire route.
At vehicleType
we’ve decided that we want to do the route with a double-axle truck, TRUCK_WITH_TWO_DOUBLE_AXLES
. In condition
, we will inform billingType
as NORMAL
and period
as NORMAL
.
If you use the Trip API, the response obtained from Trip can be used as a request to the Toll API, simply by adding the parameter vehicleType
to each leg
.
Note: The independent endpoint is only recommended if you use third-party routers. If you use the Trip API, you can get the tolls in the same request.
Below is the full request:
{ "legs": [ { "points": [ { "latitude": -23.465395, "longitude": -46.375007 }, { "latitude": -23.465957, "longitude": -46.371015 }, { "latitude": -23.467154, "longitude": -46.36559 } ], "vehicleType": "TRUCK_WITH_TWO_DOUBLE_AXLES", "condition": { "period": "NORMAL", "billingType": "NORMAL" } } ] }
Response
In the response, we will have the following fields:
totalCost
– Total toll value on the entire route;legs
– Array of objects where each object represents a section of the route. Each leg of the response corresponds to a leg of the request. The following fields will be returned in each object:tolls
– Object with the values and information for each toll in the corresponding section. Each object returned in tolls represents a toll and will contain the following information:name
– Toll name;address
– Toll address;city
– Toll city;state
– Object containing the name of the state (name
) and its acronym (code
);country
– Toll country;concession
– Concessionaire responsible for the toll;coordinates
– Coordinates (latitude and longitude) of the tollbooth;price
– Price per toll;serviceTypes
– Array with codes for integration with automatic payment systems. Currently only available in Brazil:serviceId
– Code for integration;name
– Description of the service code.
legTotalCost
– Total toll value for the section;vehicleType
– Type of vehicle considered for the section;calculationDate
– Date and time considered for the section, in timestamp format;condition
– If the parametercondition
is used in the request, this object will be returned containing which billingType and period were considered for the leg.
The full response can be found below:
{ "legs": [ { "tolls": [ { "id": "17", "name": "Pedágio - Itaquaquecetuba Leste", "address": "SP 070 - Rod. Ayrton Senna - Km 32,9", "city": "Itaquaquecetuba", "state": { "name": "São Paulo", "code": "SP" }, "country": "Brasil", "concession": "Ecopistas", "direction": "EAST", "coordinates": { "latitude": -23.4656821, "longitude": -46.3727036 }, "serviceTypes": [ { "serviceId": "80", "name": "Via Facil" }, { "serviceId": "35350700329000103", "name": "ANTTCODE" } ], "price": 10.80 } ], "legTotalCost": 10.80, "vehicleType": "TRUCK_WITH_TWO_DOUBLE_AXLES", "condition": { "billingType": "NORMAL", "period": "NORMAL" }, "calculationDate": 1738852668146 } ], "totalCost": 10.80 }