Skip to content

50,000 free calls a month, card-free. Get an API key →

Documentation menu
docs / examples / cheapest-fuel-along-route
Example

Cheapest fuel along a route

Forecourts on the way, ranked cheapest first, each priced with its real engine-computed detour. A station 3p cheaper is not cheaper if reaching it costs eight minutes, which is why the detour is measured rather than assumed.

bash
export BASE=https://api.mapmap.ai
export API_KEY=snk_...

curl -fsS -X POST "$BASE/v1/fuel/along" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "origin": { "lat": 51.75, "lon": -1.26 },
  "destination": { "lat": 53.48, "lon": -2.24 },
  "fuel": "diesel",
  "max_detour_minutes": 8,
  "fill_litres": 55
}'

# Read the honest bits of the response, not just the top result:
#   stale        the price is not verifiably fresher than 24 hours
#   baseline     the cheapest station within 150 m of the route, kept per
#                currency, and null when nothing sits on the route itself
#   candidates   considered vs costed: an empty results list with a large
#                considered means the cheap ones fell outside your budget,
#                not that there is no fuel on the route
# Displaying fuel_attribution with the prices is a licence obligation.
# The endpoint is 501 (fuel-not-enabled) where no price feed is configured;
# feature-detect on that rather than assuming coverage.