Route Cost Calculator API for Trucking - Complete Documentation
Route Cost Calculator API for Trucking
The most accurate route cost API for the Iberian Peninsula
Calculate the real cost of any trucking route across Spain and Portugal. Our API combines real-time fuel prices, comprehensive toll data, vehicle depreciation models, and IPMA weather forecasts to give you precise cost estimates.
Proven accuracy: 92% cost prediction accuracy in pilot testing with 50+ transport companies. Average cost reduction of 25% for optimized routes.
API Features
🛣️ Complete Iberian Toll Coverage
Full coverage of toll systems in Spain and Portugal:
Spain - Autopistas de Peaje:
- AP-6, AP-7, AP-9, AP-46, AP-51, AP-61, AP-68, AP-71 - All major toll operators: Abertis, Itinere, Audiper - Accurate pricing by vehicle class (2-5+ axles)
Portugal - Via Verde System:
- A1, A2, A3, A4, A5, A6, A13, A23 - Complete Via Verde electronic toll coverage - Automatic tag/identifier pricing
⛽ Real-Time Fuel Prices
Daily updated fuel prices from official sources:
| Country | Source | Update Frequency | Coverage | | ------------ | ------ | ---------------- | ------------- | | Spain | MITECO | Daily | All provinces | | Portugal | DGEG | Weekly | All districts |
Fuel types supported:
- Diesel A (professional transport) - Diesel B (agriculture) - Diesel C (industrial) - Biofuels and alternatives
🌦️ IPMA Weather Integration
Unique weather-aware routing powered by IPMA (Portuguese Institute for Sea and Atmosphere):
- Weather forecasts by route segment - ETA adjustments for adverse conditions - Route alternatives during severe weather - Wind impact on fuel consumption
📊 Vehicle Depreciation Model
Sophisticated depreciation calculations based on:
- Vehicle make and model (Scania, Mercedes, Volvo, MAN, DAF, Iveco, Renault) - Age and mileage - Euro emission class - Residual value curves
Quick Start
1. Get your API key
Sign up for free at transcend.cargoffer.com
curl -X POST https://api.transcend.cargoffer.com/v1/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "your@email.com",
"company": "Your Transport Company"
}'
2. Make your first request
curl -X POST https://api.transcend.cargoffer.com/v1/route-cost \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"origin": {
"address": "Madrid, Spain"
},
"destination": {
"address": "Barcelona, Spain"
},
"vehicle": {
"type": "articulated",
"axles": 5,
"weight": 24000,
"euroClass": "VI"
},
"options": {
"includeTolls": true,
"includeFuel": true,
"includeDepreciation": true
}
}'
3. Response format
{
"route": {
"distance": 621.4,
"duration": "6h 15m",
"polyline": "encoded_polyline_string"
},
"costs": {
"fuel": {
"liters": 186.4,
"cost": 229.15,
"pricePerLiter": 1.229,
"currency": "EUR"
},
"tolls": {
"amount": 127.35,
"currency": "EUR",
"breakdown": [
{
"road": "AP-7",
"section": "Zaragoza-Barcelona",
"cost": 89.2
}
]
},
"depreciation": {
"perKm": 0.092,
"total": 57.17
},
"total": 413.67
},
"weather": {
"conditions": "light rain",
"impact": "+15 minutes",
"riskLevel": "low"
},
"alternatives": [
{
"type": "toll_free",
"distance": 645.2,
"duration": "7h 45m",
"totalCost": 286.42,
"savings": 127.23
}
]
}
Code Examples
JavaScript/Node.js
const axios = require("axios");const client = axios.create({
baseURL: "https://api.transcend.cargoffer.com/v1",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
});async function calculateRouteCost(origin, destination, vehicle) {
try {
const response = await client.post("/route-cost", {
origin: { address: origin },
destination: { address: destination },
vehicle: vehicle,
options: {
includeTolls: true,
includeFuel: true,
includeWeather: true,
},
}); return response.data;
} catch (error) {
console.error("API Error:", error.response?.data || error.message);
throw error;
}
}// Usage
const route = await calculateRouteCost("Lisbon, Portugal", "Porto, Portugal", {
type: "articulated",
axles: 5,
weight: 24000,
});Python
import requestsclass TranscendAPI:
def __init__(self, api_key):
self.api_key = api_key
self.base_url = 'https://api.transcend.cargoffer.com/v1' def calculate_route_cost(self, origin, destination, vehicle):
"""Calculate route cost with full breakdown."""
response = requests.post(
f'{self.base_url}/route-cost',
headers={
'Authorization': f'Bearer {self.api_key}',
'Content-Type': 'application/json'
},
json={
'origin': {'address': origin},
'destination': {'address': destination},
'vehicle': vehicle,
'options': {
'includeTolls': True,
'includeFuel': True,
'includeDepreciation': True
}
}
)
response.raise_for_status()
return response.json()Usage
api = TranscendAPI('YOUR_API_KEY')result = api.calculate_route_cost(
origin='Madrid, Spain',
destination='Seville, Spain',
vehicle={
'type': 'rigid',
'axles': 3,
'weight': 18000
}
)PHP
public function __construct($apiKey) {
$this->apiKey = $apiKey;
} public function calculateRouteCost($origin, $destination, $vehicle) {
$payload = [
'origin' => ['address' => $origin],
'destination' => ['address' => $destination],
'vehicle' => $vehicle,
'options' => [
'includeTolls' => true,
'includeFuel' => true
]
]; $ch = curl_init($this->baseUrl . '/route-cost');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $this->apiKey,
'Content-Type: application/json'
]); $response = curl_exec($ch);
curl_close($ch); return json_decode($response, true);
}
}// Usage
$api = new TranscendAPI('YOUR_API_KEY');
$result = $api->calculateRouteCost(
'Barcelona, Spain',
'Valencia, Spain',
['type' => 'articulated', 'axles' => 5]
);API Reference
Endpoint: POST /v1/route-cost
Calculate the total cost of a route.
Parameters:
| Parameter | Type | Required | Description | | ------------- | ------ | -------- | ------------------------------------------ | | origin | object | Yes | Starting point with address or coordinates | | destination | object | Yes | Ending point with address or coordinates | | vehicle | object | Yes | Vehicle specifications | | options | object | No | Calculation options |
Vehicle Object:
| Field | Type | Required | Description | | ----------- | ------- | -------- | --------------------------------- | | type | string | Yes | rigid, articulated, drawbar | | axles | integer | Yes | Number of axles (2-6) | | weight | integer | No | Total weight in kg | | euroClass | string | No | Euro emission class (III-VI) |
Options Object:
| Field | Type | Default | Description | | --------------------- | ------- | -------- | ---------------------- | | includeTolls | boolean | true | Include toll costs | | includeFuel | boolean | true | Include fuel costs | | includeDepreciation | boolean | false | Include depreciation | | includeWeather | boolean | false | Include weather impact | | fuelType | string | diesel_a | Fuel type code |
Response Codes:
| Code | Meaning | Description | | ---- | ----------------- | ---------------------- | | 200 | OK | Successful calculation | | 400 | Bad Request | Invalid parameters | | 401 | Unauthorized | Invalid API key | | 429 | Too Many Requests | Rate limit exceeded | | 500 | Server Error | Internal error |
Pricing
Free Tier
- 1,000 requests/month - Full API access - Community support - Perfect for development
Growth Tier
- 50,000 requests/month - €99/month - Priority email support - SLA: 99.5% uptime
Enterprise
- Unlimited requests - Custom pricing - Dedicated support - SLA: 99.9% uptime - Custom features
Use Cases
🚛 Fleet Management
Optimize route costs for entire fleets:
// Batch route optimization
const routes = await Promise.all(
deliveries.map((d) => api.calculateRouteCost(depot, d.address, fleetVehicle)),
);📊 TMS Integration
Integrate with Transport Management Systems:
class TranscendTMSAdapter:
def enrich_route(self, route):
"""Enrich TMS route with cost data."""
cost_data = self.api.calculate_route_cost(
origin=route.origin,
destination=route.destination,
vehicle=self.map_vehicle(route.vehicle)
) route.estimated_cost = cost_data['costs']['total']
route.fuel_cost = cost_data['costs']['fuel']['cost']
route.toll_cost = cost_data['costs']['tolls']['amount']🧮 Quote Generation
Generate accurate quotes for customers:
async function generateQuote(customerRoute, vehicleType) {
const cost = await api.calculateRouteCost(
customerRoute.pickup,
customerRoute.delivery,
vehicleType,
); // Add margin
const margin = 1.25; // 25% markup
const quotedPrice = cost.costs.total * margin;Comparison with Alternatives
| Feature | TRANSCEND | Google Maps | TomTom | ViaMichelin | | ---------------------------- | --------- | ----------- | ---------- | ----------- | | Iberian tolls (detailed) | ✅ Full | ⚠️ Basic | ❌ No | ✅ Yes | | Real-time fuel prices | ✅ Yes | ❌ No | ❌ No | ❌ No | | Weather integration | ✅ IPMA | ❌ No | ⚠️ Limited | ❌ No | | Vehicle depreciation | ✅ Yes | ❌ No | ❌ No | ❌ No | | Free tier | ✅ 1k/mo | ✅ Yes | ⚠️ Limited | ❌ No | | HGV constraints | ✅ Yes | ⚠️ Basic | ✅ Yes | ⚠️ Basic |
SDKs and Tools
- JavaScript/Node.js: npm install @transcend/api - Python: pip install transcend-api - PHP: composer require transcend/api - Postman Collection: Download
Support
- 📧 Email: api@transcend.cargoffer.com - 💬 Discord: Join community - 📖 Docs: docs.transcend.cargoffer.com - 🐙 GitHub: github.com/transcend/api-examples
Frequently Asked Questions
What is a route cost calculator API?
A route cost calculator API is a programming interface that automatically calculates the total cost of a trucking route, including fuel consumption, toll fees, vehicle depreciation, and driver costs. TRANSCEND provides the only API specialized for the Iberian market (Spain and Portugal) with real-time data on tolls and fuel prices.
How accurate is the fuel cost calculation?
The fuel cost calculation uses real-time fuel prices updated daily from official government sources (MITECO for Spain, DGEG for Portugal). It considers vehicle type, load weight, topography, and driving conditions to estimate consumption with 92% accuracy based on our pilot testing.
Is the API free to use?
Yes, TRANSCEND offers a free tier with 1,000 API requests per month, perfect for developers and testing. For commercial use and higher volumes, we offer scalable pricing based on your needs. You can start immediately with our interactive sandbox without a credit card.
What countries are supported?
Currently, TRANSCEND fully supports Spain and Portugal with the most detailed toll and fuel data available. We plan to expand to France and other EU countries in Q3 2026.
Can I integrate this with my TMS or ERP?
Absolutely. The API is designed for easy integration with Transport Management Systems (TMS), ERPs, and fleet management platforms. We provide SDKs for JavaScript, Python, and PHP, plus a comprehensive REST API that works with any system capable of making HTTP requests.
How do I handle API errors?
The API uses standard HTTP status codes. Always check the response status:
- 200: Success - 400: Check your request parameters - 401: Verify your API key - 429: Implement rate limiting/backoff - 500: Retry with exponential backoff
See our error handling guide for details.
Ready to start? Try the free sandbox →
No credit card required. 1,000 free requests monthly. Full documentation included.
_Last updated: February 2026. API version: v1.2.0_