Back to APIs (Backend)
    APIs (Backend)Open source2026

    Spotter Fuel Route API

    Backend Engineer

    A Django read endpoint that, given a start and finish in the USA, returns the driving route, the cost-optimal set of fuel stops along it, and the total fuel cost. Built for the Spotter backend engineering assessment under a hard constraint: one external routing call, and it has to be fast.

    The problem

    The supplied fuel dataset has no coordinates, only City, State and highway-exit addresses like 'I-44, EXIT 283 & US-69' that no geocoder will resolve. Knowing which stations lie along a route requires coordinates, so the obvious design geocodes stations per request: thousands of API calls, which breaks both the speed and the single-call constraints.

    How I built it

    • 1Moved geocoding out of the request entirely. Every station is resolved once, offline at import, by joining City and State against a bundled static dataset derived from the free GeoNames US dump. The import makes zero geocoding API calls.
    • 2Made exactly one external call at request time, to OSRM, for route geometry and total distance.
    • 3Kept corridor matching and fuel optimisation as pure in-memory NumPy computation over a few hundred stations: sub-second, with no per-request spatial query and no PostGIS dependency.
    • 4Framed the optimisation correctly: total gallons burned is fixed by distance, so the problem is not how much you burn but where you buy, because prices differ per station.

    Outcome

    A single fast endpoint that plans coast-to-coast routes with cost-optimal fuel stops, holding to one external API call per request.

    Next in APIs (Backend)

    Vidannotate