Skip to content
PithLab

↑↓ to move · Enter to open · Esc to close

Fuel Cost Calculator API

Fuel needed and cost of a trip from distance, fuel efficiency (L/100 km, km/L, US or UK MPG) and fuel price, optionally round trip and split between people.

POST /api/v1/tools/fuel-cost-calculatorMCP fuel_cost_calculatorCalculators

Work out how much fuel a journey needs and what it costs, using MPG (US or UK), L/100 km or km/L, with round trips and splitting the cost between passengers.

Input

Send these as a JSON object. Unknown fields are rejected.

distance
One-way distance, in distanceUnit. (number, 0 to …, required)
distanceUnit
km or mi. (string, one of km, mi, default "km")
efficiency
Fuel efficiency, in efficiencyUnit. (number, 0 to …, required)
efficiencyUnit
l-100km (litres per 100 km), km-l (km per litre), mpg-us or mpg-uk (miles per US or UK gallon). (string, one of l-100km, km-l, mpg-us, mpg-uk, default "l-100km")
price
Fuel price per priceUnit, in currency units. (number, 0 to …, required)
priceUnit
What the price is for: litre, us-gallon or uk-gallon. (string, one of litre, us-gallon, uk-gallon, default "litre")
roundTrip
Double the distance for a return journey. (boolean, default false)
people
People sharing the cost, 1 to 100. (integer, 1 to 100, default 1)
curl https://pithlab.com/api/v1/tools/fuel-cost-calculator \n  -H "Authorization: Bearer $PITHLAB_KEY" \n  -H "Content-Type: application/json" \n  -d '{"distance":350,"distanceUnit":"km","efficiency":6.5,"efficiencyUnit":"l-100km","price":1.75,"priceUnit":"litre","roundTrip":true,"people":2}'
Example response
{
  "ok": true,
  "result": {
    "distance": 700,
    "litres": 45.5,
    "usGallons": 12.019828382295753,
    "ukGallons": 10.008600797608494,
    "cost": 79.625,
    "perPerson": 39.8125,
    "people": 2,
    "costPerDistance": 0.11375,
    "text": "Round trip of 700 km at 6.5 L/100 km uses 45.5 L of fuel, costing 79.63 (39.81 each for 2 people)."
  }
}