Toll Calculations¶
Toll Calculations computes the toll costs along the route and displays them in different currencies.
What are Toll Calculations?¶
The Toll Calculations feature calculates the toll stations and their costs along the route. It is used for budget planning and cost analysis.
Basic Usage¶
Toll Calculation in the Request Body¶
{
"origin": {"latitude": 41.0082, "longitude": 28.9784},
"destination": {"latitude": 41.0150, "longitude": 28.9850},
"tolls": true,
"currency": "TRY"
}
Toll Parameters¶
| Field | Type | Required | Description |
|---|---|---|---|
tolls |
Boolean | Optional | Enables toll cost calculation (default: false) |
currency |
Currency | Optional | Toll currency: "USD", "EUR", "TRY" |
Use Cases¶
1. Cost Analysis¶
{
"origin": {"latitude": 41.0082, "longitude": 28.9784},
"destination": {"latitude": 41.0150, "longitude": 28.9850},
"tolls": true,
"currency": "TRY"
}
2. Currency Conversion¶
{
"origin": {"latitude": 41.0082, "longitude": 28.9784},
"destination": {"latitude": 41.0150, "longitude": 28.9850},
"tolls": true,
"currency": "EUR"
}
3. Truck Route with Toll¶
{
"origin": {"latitude": 41.0082, "longitude": 28.9784},
"destination": {"latitude": 41.0150, "longitude": 28.9850},
"vehicle": {"vehicle_type": "truck"},
"tolls": true,
"currency": "USD"
}
Response Format¶
Toll Response Structure¶
The route endpoint returns a top-level JSON array. The following abridged example focuses on toll-related fields; unrelated route and section fields are omitted.
[
{
"summary": {
"distance": 15000,
"duration": 1200,
"cost": 45.5
},
"sections": [
{
"tolls": {
"summary": {
"total": 45.5,
"currency": "TRY"
},
"toll_systems": [
{
"id": 1,
"name": "Kuzey Marmara Otoyolu"
}
],
"toll_costs": [
{
"toll_system": "1",
"toll_system_names": ["Kuzey Marmara Otoyolu"],
"country_code": "TUR",
"fares": [
{
"id": "fare_1",
"name": "Class 1 Vehicle",
"price": 45.5,
"currency": "TRY",
"estimated": false,
"reason": "Standard toll rate"
}
]
}
]
}
}
]
}
]
Python Example¶
import requests
API_BASE_URL = "https://api.flio.ai"
API_KEY = "YOUR-API-KEY"
payload = {
"origin": {"latitude": 41.0082, "longitude": 28.9784},
"destination": {"latitude": 41.0150, "longitude": 28.9850},
"tolls": True,
"currency": "TRY",
}
url = f"{API_BASE_URL}/solver/route?api_key={API_KEY}"
response = requests.post(url, json=payload)
response.raise_for_status()
routes = response.json()
toll_cost = routes[0]["summary"]["cost"]
print(f"Total Toll Cost: {toll_cost} TRY")
Toll Calculations — Flio.ai