Toll for Maps

Example 1 – Toll for a simple route

In this example, we have a simple toll calculation for a 3-point route on a stretch of the Ayrton Senna Highway in São Paulo, coming from the Google Maps Directions API response, whose original request was as follows:,-46.375007&waypoints=-23.465957,-46.371015&destination=-23.467154, -46.365598&mode=driving&key={API_KEY}

The response from the Directions API will be used as the body in the request to the endpoint, as in the example below:

curl -X POST "" -H "Authorization: Bearer 3O0d0YjOL72Roqp5CrnGwh5yvgKH" -H "Content-Type: application/json" -d @C:\temp\Directions_Response.json


  • vehicleType – Type of vehicle calculating the toll;
  • Directions_Response.json – Directions API response containing the route.

The response will come in JSON format.

The tolls for each route will be obtained from results.

If the Directions API is processed with alternative routes, it will return 3 results, with 1 result for each route.

Within each results an object legs will be returned which corresponds to the route itself. The object will contain the total value of the route at totalCost and an object tolls with the values and information for each toll on the route. The field vehicleType will also be returned, indicating the vehicle used on that stretch.

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 com códigos para integração com sistemas de pagamento automático. Atualmente disponível apenas no Brasil;
    • serviceId – Code for integration;
    • name – Description of the service code.

The full response can be found below:

    "results": [
            "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",
                            "coordinates": {
                                "latitude": -23.4656821,
                                "longitude": -46.3727036
                            "serviceTypes": [
                                    "serviceId": "80",
                                    "name": "Via Facil"
                                    "serviceId": "35350700329000103",
                                    "name": "ANTTCODE"
                            "price": 7.8
                    "legTotalCost": 7.8
                    "tolls": [],
                    "legTotalCost": 0
            "totalCost": 7.8