Skip to content
Documentation menu
docs / api / post-v1-ev-plan
EV charging

POST/v1/ev/plan

Access and price

AuthAn API key, as Authorization: Bearer snk_… or ?api_key=snk_…. Metered. Needs a full key; a browser (maps) key is refused.
PriceA flat 10 calls. Class: standard, or premium for truck and ADR work. Published as unit_rules.ev_plan in /pricing.json.
PremiumWhen the body asks for truck routing: "costing": "truck", a top-level adr object or "hazmat": true

What it does

The algorithm

  1. Base route. One auto route over origin + waypoints + destination, with the request's costing_options verbatim.
  2. Leg sampling. Each manoeuvre of that route becomes one sn_ev::LegSample: its length and its own average speed, which is finer than a leg summary and so makes the steady-state assumption in sn_ev::consumption_over_legs better. Manoeuvre-free routes fall back to one sample per leg, and a route with more than MAX_LEG_SAMPLES manoeuvres has consecutive ones coalesced.
  3. Elevation, or an honest absence. When elevation is enabled the gateway's own height service is asked for the elevation at every leg boundary, and each leg's gain and loss come from its two ends. When it is not enabled, or the DEM has no coverage, the legs are built with sn_ev::LegSample::without_gradient, the consumption model runs flat (the only thing it can do) and the response says gradient_data: "absent". A gradient is never silently assumed to be zero.
  4. Direct plan. sn_ev::consumption_over_legs over the whole route from start_soc. If the arrival state of charge is at or above min_arrival_soc and the reserve was never breached, that is the plan: no charger work and no matrix call happen at all.
  5. Candidates. Otherwise, charge points from the store are projected onto the route (corridor::nearest_on_route), filtered to those the vehicle can plug into at a rated power inside the corridor budget, and capped at MAX_PLAN_CANDIDATES spread along the route rather than clustered; the /v1/charging/along corridor machinery, with a spread instead of a power ranking, because a planner needs reach and a search needs kilowatts.
  6. One matrix. Origin + candidates → candidates + destination, one (n+1)² matrix through the gateway's own engine with the request's costing options, giving every hop a real driving time and distance: never a crow-flies guess. The caller's waypoints are matrix nodes too, and a hop that spans one is costed through it, because that is the drive the journey makes.
  7. Greedy with lookahead. crate::ev::plan_stops walks the route choosing stops so the state of charge never breaches reserve_soc, preferring a stop that finishes the journey, then the furthest one (fewer stops), then the cheapest by driving plus charging time. A charger from which nothing further can be reached even on a full battery is refused rather than taken. At most eight passes.
  8. Final geometry. The chosen stops are merged with the waypoints in route order and the route is recomputed through them, so the geometry returned is the journey actually described.
  9. Or an honest no. When no plan exists (a charger desert, a connector mismatch, a gap wider than the vehicle's range), the answer is a 200 with feasible: false, the named cause, and the furthest point on the route the vehicle can actually reach. Never a fabricated plan.

Stated limitations

A hop's energy is sliced out of the base route's legs and the detour surplus charged as one gradient-unknown leg (see crate::ev::hop_legs); matrix cells are upper bounds on route cost, not route costs; the consumption model's own ±15 % motorway bound and its urban bias are stated in sn_ev; charging curves are best-case, measured on a warm pack. The plan is a plan, not a promise.

Call it

bash
curl -fsS -X POST "https://api.mapmap.ai/v1/ev/plan" \
  -H "Authorization: Bearer $MAPMAP_KEY" \
  -H "Content-Type: application/json" \
  -d '{"connectors":["ccs"],"destination":{"lat":55.95,"lon":-3.19},"min_arrival_soc":0.2,"min_kw":50,"origin":{"lat":51.5,"lon":-0.12},"profile":"small_hatch","reserve_soc":0.15,"start_soc":0.9}'

Request body

application/json

EV journey plan: origin + destination (+ optional waypoints), a vehicle (profile: "small_hatch" | "saloon" | "suv" | "van", or an inline object of EvProfile fields over a base), start_soc (default 0.9), min_arrival_soc (default 0.1), reserve_soc (default 0.1, the mid-route floor), a connectors filter, min_kw, ambient_temperature_c, max_detour_minutes (default 15, max 120) and Valhalla costing_options (the costing is always auto)

Example: From website/public/docs/analysis.md:1737

json
{
  "connectors": [
    "ccs"
  ],
  "destination": {
    "lat": 55.95,
    "lon": -3.19
  },
  "min_arrival_soc": 0.2,
  "min_kw": 50,
  "origin": {
    "lat": 51.5,
    "lon": -0.12
  },
  "profile": "small_hatch",
  "reserve_soc": 0.15,
  "start_soc": 0.9
}

Responses

200The plan, feasible or honestly not: {feasible, plan: {stops, total_drive_s, total_charge_s, total_duration_s, total_distance_m, start_soc, arrival_soc, min_arrival_soc, reserve_soc, energy_kwh}, stops[]: {charger_id, name, operator, source, lat, lon, connector: {standard, power_kw, dc, power_kw_source; derived when the feed did not publish the rating}, charger_kw, arrive_soc, depart_soc, charge_s, detour_s, along_route_position, off_route_m, status, status_live}, legs[]: {from, to, duration_s, distance_m, start_soc, end_soc, min_soc, consumed_wh, regen_wh}, soc_trace[], gradient_data: "complete" | "partial" | "absent", gradient: {legs_total, legs_with_gradient, fraction}, route: {duration_s, distance_m, length_m}, geometry_polyline6, coverage_note (ALWAYS present), sources[], availability: {live, note}, provenance: {profile, availability, consumption_model, charge_model}, charging_attribution}. When feasible is false the answer carries reason: {code, message} and furthest_reachable, never a fabricated stop list
FieldTypeRequiredDescription
availabilityobjectnoWhether statuses are live.
candidatesobjectnoCharge points considered in the corridor, usable and costed.
costingstringnoThe costing used.
coverage_notestringnoWhich operators are covered.
eta_calibrationobjectnoWhether a typical-delay calibration applies to the drive times.
feasiblebooleannoWhether the journey can be made. When not, the plan names the cause and the furthest reachable point.
geometry_polyline6stringnoThe route shape, precision-6 encoded polyline.
gradientobjectnoHow much of the route had gradient data for the consumption model.
gradient_datastringnocomplete, partial or none.
legsobject[]noDrive legs between stops: distance_m, duration_s, consumed_wh and the state of charge at each end.
planobjectnoThe plan: arrival_soc, energy_kwh, the floors applied and the totals.
provenanceobjectnoThe models behind the plan: consumption, charge curve and data.
routeobjectnoThe whole route: distance_m, duration_s and length_m.
soc_traceobject[]noState of charge at the origin, each stop and the destination.
sourcesobject[]noEach charger data source with its count and coverage note.
stopsobject[]noCharge stops in order, with the charger, arrive_soc, depart_soc and charge_s.
vehicleobjectnoThe vehicle profile used: name, usable_kwh and connectors.

Example: Recorded from the hosted gateway on 2026-11-05 with a test key: POST /v1/ev/plan, Trafalgar Square to Brighton in a small hatchback; lists trimmed to their first items

json
{
  "availability": {
    "live": false,
    "note": "No live availability feed is configured, so every status is the value captured when the dataset was last ingested, not what the bay is doing now. Supply your operator's OCPI feed to make these live."
  },
  "candidates": {
    "cap": 20,
    "costed": 0,
    "in_corridor": 0,
    "usable": 0
  },
  "costing": "auto",
  "coverage_note": "Covers 6052 charge point(s) (6054 charging position(s)) from char.gy (on-street lamppost charging). Charge points from any operator not listed are absent from this dataset entirely, so an empty result means \"none from these operators\", never \"no chargers here\".",
  "eta_calibration": {
    "applied": false,
    "method": "gb_typical_delay_v1",
    "note": "The planner's drive times and energy use are on the routing engine's free-flowing speeds. Car times from POST /route in Great Britain include the typical delay on local roads, so in towns the drive can take longer than this plan says; charging times are unaffected.",
    "travel_times": "free_flow"
  },
  "feasible": true,
  "geometry_polyline6": "{swfaBl_yF[gJWuBSsBM_D@sCLuBXyA^}Ap@cBb@aAb@m@^]PGb@C",
  "gradient": {
    "fraction": 1,
    "legs_total": 34,
    "legs_with_gradient": 34
  },
  "gradient_data": "complete",
  "legs": [
    {
      "consumed_wh": 9892.8,
      "distance_m": 85766,
      "duration_s": 5105,
      "end_soc": 0.732,
      "from": "origin",
      "legs_modelled": 35,
      "legs_with_gradient": 34,
      "min_soc": 0.731,
      "regen_wh": 142.9,
      "start_soc": 0.9,
      "to": "destination"
    }
  ],
  "plan": {
    "arrival_soc": 0.732,
    "energy_kwh": 9.75,
    "feasible": true,
    "min_arrival_soc": 0.2,
    "reserve_soc": 0.15,
    "route_duration_s": 5105,
    "start_soc": 0.9,
    "stops": 0,
    "total_charge_s": 0,
    "total_distance_m": 85766,
    "total_drive_s": 5105,
    "total_duration_s": 5105
  },
  "provenance": {
    "availability": "static_snapshot",
    "charge_model": "sn-ev charge-curve integration, capped by the charge point's rated power. Published curves are best case: a cold pack charges more slowly than this.",
    "consumption_model": "sn-ev road-load model (UNECE GTR No. 15 decomposition); ±15 % on constant-speed motorway travel, under-reads in stop-start traffic",
    "planner": "static planner over the operator feeds this deployment ingests; bring your own OCPI feed for live availability",
    "profile": {
      "profile": "small_hatch",
      "source": "default"
    }
  },
  "route": {
    "distance_m": 85766,
    "duration_s": 5105,
    "length_m": 85758
  },
  "soc_trace": [
    {
      "along_route_position": 0,
      "at": "origin",
      "soc": 0.9
    },
    {
      "along_route_position": 1,
      "at": "destination",
      "departing_soc": null,
      "soc": 0.732
    }
  ],
  "sources": [
    {
      "chargers": 6052,
      "coverage_note": "On-street lamppost charging in char.gy's partner boroughs only: no rapid hubs, no forecourts and no other operator's network.",
      "licence": "Public Charge Point Regulations 2023",
      "operator": "char.gy (on-street lamppost charging)",
      "source_id": "chargy"
    }
  ],
  "stops": [],
  "vehicle": {
    "connectors": [
      "type2",
      "ccs2"
    ],
    "name": "small hatchback (Volkswagen ID.3 Pro 58 kWh)",
    "usable_kwh": 58
  }
}
400Invalid request

application/problem+json · Problem

401Missing or invalid API key. Also: No key, or a missing, malformed, unknown, revoked or expired one (unauthorized); the body carries signup, docs and a one-call hint for a free key

application/problem+json · Problem

402Beyond the included volume with no way to pay this call: an x402 body naming how to pay (provisional key past its allowance, prepaid balance below the price, or a rejected X-PAYMENT). Not problem+json

application/json · X402PaymentRequired

403The key may not call this: a browser key outside its scope (scope-insufficient), a request from an origin the key does not allow (origin-not-allowed), or an account restriction (forbidden)

application/problem+json · Problem

413The request declares a body larger than 1048576 bytes (plain text, not problem+json)

text/plain

429Quota or rate limit exceeded. Also: Per-key rate limit (rate-limited, with Retry-After), or monthly quota exhausted with no payment path (quota-exceeded)

application/problem+json · Problem

501The charge-point dataset is not enabled (SN_CHARGE_DIR unset)

application/problem+json · Problem

502Upstream routing engine failed

application/problem+json · Problem

504The request did not finish within the gateway's request deadline (request-timeout)

application/problem+json · Problem

Error bodies follow the shared problem model documented on API conventions.

Also under EV charging

Generated from https://api.mapmap.ai/openapi.json on 2026-11-12 · operationId post_ev_plan