POST /v1/optimize
The core Nozle endpoint. Takes a route, a list of stations with prices and route-relative positions, and a vehicle. Returns the fuel-cost-optimal sequence of stops along with a baseline comparison showing what a naive strategy would have cost.
Prerequisites: all stations must have price_per_gallon and miles_from_route_start set. Use /v1/stations/enrich-distances to compute distances if you don’t have them. Stations must share a single fuel_type value (or have it unset) — mixed fuel grades in one request are rejected.
Vehicle handling: you can either provide direct specs (mpg, tank_capacity_gallons, current_fuel_gallons) or year/make/model and let us look up the specs. Direct specs are always preferred when available.
Tuning: time_value_dollars_per_minute controls how the optimizer trades cheaper fuel against longer detours. 0.1 = very cost-sensitive, 0.9 = very time-sensitive, 0.5 (default) = balanced.
Baseline comparison: the response includes savings vs. a naive strategy that refuels to full at the next station ahead whenever the tank reaches 25%. This is the dollar value the optimizer is delivering.
/v1/optimize endpoint is the core of the Nozle API. Given a route, stations with prices, and a vehicle, it returns the cost-optimal sequence of fueling stops along with a baseline comparison showing savings vs. naive refueling.
Algorithm
The optimizer uses dynamic programming to search for the stop sequence minimizing the objective function: total_cost = fuel_cost + (time_value_dollars_per_minute × total_detour_minutes) subject to:- Tank capacity constraints (can’t exceed
tank_capacity_gallonsat any stop) - Destination reserve constraint (must arrive with at least
destination_reserve_fraction × tank_capacity_gallons) - Inter-stop buffer constraint (must arrive at each stop with at least
inter_stop_buffer_fraction × tank_capacity_gallons)
Baseline Comparison
The response includes abaseline_comparison object computing what a naive 25%-threshold refueling strategy would cost on the same route and station set. This provides the savings number partners use to demonstrate value to their customers.
For comparing costs fairly, the baseline uses net fuel cost (the dollar value of fuel actually consumed on the trip) rather than pump cost, since naive strategies often refuel to full and end with paid-for fuel in the tank.
Infeasibility
If the optimizer cannot find a feasible plan with the given inputs, it returns a422 INFEASIBLE_ROUTE response with diagnostic details explaining why. Common causes:
- Insufficient
current_fuel_gallonsto reach the first available station - Gap between consecutive stations exceeds vehicle range
- Reserve constraints can’t be satisfied with available stations
details field in error responses includes specific diagnostic information to help debug the issue.Authorizations
Body
Internal route representation. Flat shape — upstream adapters normalize Google/Mapbox responses into this before it hits B2B code.
1 - 5000 elementsVehicle parameters for optimization. Accepts either direct specs (preferred) or year/make/model for lookup. Direct specs override lookup values when both are provided.