Modemix API / Docs
Everything POST /v1/directions takes and returns: step-by-step directions that combine biking, bikeshare or walking with public transit.
POST https://api.modemix.io/v1/directions
x-api-key: mmx_your_key_here
Content-Type: application/jsonBilled per request, pay as you go. Usage is summed monthly across all API keys linked to your account.
| Monthly volume | Per 1,000 |
|---|---|
| 0 – 100,000 | $5.00 |
| 100,001 – 500,000 | $4.00 |
| 500,001 – 1,000,000 | $3.00 |
| 1,000,001 – 5,000,000 | $1.50 |
| 5,000,001+ | $0.40 |
Tiered like tax brackets: each request is billed at the rate of the band it falls into. 200,000 requests in a month cost 100,000 × $5.00/1k + 100,000 × $4.00/1k = $900.00.
Every request needs an API key in the x-api-key header.
curl -X POST https://api.modemix.io/v1/directions \
-H "x-api-key: mmx_your_key_here" \
-H "Content-Type: application/json" \
-d '{ ... }'Plan routes between two points. Times and speeds are in seconds, meters and meters per second throughout.
mode and transit together pick the kind of trip:
| mode | transit | The trip |
|---|---|---|
| bike | true | Ride to transit and from it. The default. |
| bike | false | Ride the whole way. |
| walk | true | Walk to transit and from it. |
| walk | false | Walk the whole way. |
| bikeshare | true | Rent a bike or scooter to transit and from it, and walk between transit legs. |
| bikeshare | false | Rent a bike or scooter the whole way. |
A trip without transit has at most one route, and ignores the transit options: exclude_transit, max_transfers, max_seconds_to_station, bike_type and max_results.
{
"origin": { "latitude": 37.7596, "longitude": -122.4269 },
"destination": { "latitude": 37.8053, "longitude": -122.2725 },
"depart_at": 1795537800,
"mode": "bike"
}bay_area. Left out, it is the region that contains the origin.depart_at or arrive_by, not both.bikeshare rents a bike or scooter for the ends of the trip and walks between transit legs.mode: "bike". A full-size bike boards only the vehicles that carry bikes and avoids stations with stairs. A folding bike rides anything.false returns at most one route, which rides or walks the whole way.bus, train, subway, tram, ferry, monorail, funicular_gondola.0 allows one vehicle only.mode: "bikeshare". vehicles: ["bike", "scooter"] or either one. exclude_brands: brand ids from bikeshare_brands. end_at_dock: end rides on docked systems at a dock, default true. electric_speed_mps: the speed of electric rentals, 6.7 unless set and at most 8.9. Rentals without a motor ride at 4.5.{
"region": "bay_area",
"routes": [
{
"departure": "2026-11-24T08:31:09-08:00",
"arrival": "2026-11-24T09:03:27-08:00",
"duration_seconds": 1938,
"distance_meters": 17405,
"transfers": 0,
"fare": null,
"legs": [
{
"type": "bike",
"departure": "2026-11-24T08:31:09-08:00",
"arrival": "2026-11-24T08:42:00-08:00",
"duration_seconds": 651,
"distance_meters": 1237,
"from": { "name": null, "latitude": 37.7596, "longitude": -122.4269 },
"to": { "name": "16th St/Mission", "latitude": 37.76518, "longitude": -122.41968 },
"moving_seconds": 483,
"moving_meters": 1210,
"station_exit_seconds": 0,
"station_entry_seconds": 168,
"polyline": "a}meFdofjVIwB?QA..."
},
{
"type": "transit",
"departure": "2026-11-24T08:42:00-08:00",
"arrival": "2026-11-24T09:00:00-08:00",
"duration_seconds": 1080,
"distance_meters": 15859,
"from": { "name": "16th St/Mission", ... },
"to": { "name": "12th Street/Oakland City Center", ... },
"vehicle": "subway",
"line": {
"name": "Red-N",
"long_name": "Millbrae/SF Int'l Airport SFO to Richmond",
"agency": "BART",
"color": "#FF0000",
"text_color": "#FFFFFF",
"logo_url": "https://api.modemix.io/assets/route_logos/bart-red.svg",
"mark": null
},
"headsign": "Richmond",
"scheduled_departure": "2026-11-24T08:42:00-08:00",
"scheduled_arrival": "2026-11-24T09:00:00-08:00",
"realtime": false,
"stays_on_board": false,
"fare": null,
"stops": [{ "name": "Civic Center/UN Plaza", ... }, ...],
"polyline": "i_oeFfbejVcADkBH..."
},
{
"type": "bike",
"departure": "2026-11-24T09:00:00-08:00",
"arrival": "2026-11-24T09:03:27-08:00",
"duration_seconds": 207,
"distance_meters": 309,
"from": { "name": "12th Street/Oakland City Center", ... },
"to": { "name": null, "latitude": 37.8053, "longitude": -122.2725 },
"moving_seconds": 104,
"moving_meters": 189,
"station_exit_seconds": 103,
"station_entry_seconds": 0,
"polyline": "snveFxdhiVCDCDSK..."
}
]
}
],
"no_route_reason": null,
"searched_from": "2026-11-24T08:30:00-08:00",
"searched_until": "2026-11-24T09:50:00-08:00"
}mode: "bikeshare": the brands with vehicles near either end of the trip, each with id, name, color, logo, its app, and whether it is docked and rents scooters.bike, scooter, walk, transit, or transfer: a change of vehicles inside a station or across a short footpath.name is the station or dock, and null at the trip's own ends and anywhere on the street.brand, electric, pick_up and drop_off. Each is a dock, { type: "dock", name, vehicles_available, spaces_available }. A free-floating pick-up is { type: "vehicle" }, and a ride left on the street ends at { type: "street" }.bus, coach, trolleybus, train, subway, tram, cable_car, ferry, monorail, funicular, gondola, and a few rarer kinds.name, long_name, agency, and color and text_color as #RRGGBB. See Line badges for logo_url and mark.realtime is true when departure and arrival are live estimates.transfer is true when an earlier leg's ticket covers it.Every transit leg's line carries what it takes to draw the badge the Modemix apps show for it. Use the first of these the line has:
text, the name to set next to it. style says how: plain sets the name in the line's color on a light background, box sets it in text_color on a rounded rectangle of color, and capsule does the same on a pill.Logos and marks are SVG files on https://api.modemix.io, free to load without an API key. Agencies draw them for light backgrounds, so on a dark background set a logo on a white plate. Bikeshare brands follow the same idea: logo.url for light backgrounds, logo.dark_url for dark ones where the brand has one, logo.kind wordmark standing in for the name and symbol drawn beside it, and logo.padding the share of the row's height to leave clear above and below.
A trip with no route answers 200 with an empty routes array and a no_route_reason:
| outside_coverage | An end of the trip is off the streets Modemix covers. |
| no_stations_in_reach | No station is within reach of an end of the trip. |
| no_transit_service | No transit connects the two ends around this time. |
| street_route_is_better | Riding or walking the whole way beats every transit route. Ask again with transit: false. |
| no_street_route | No street route connects the two ends. |
| no_bikeshare_nearby | No bikeshare brand has a vehicle near either end. |
| renting_does_not_help | Walking to and from transit beats renting on every route found. Ask again with mode: "walk". |
| no_route | Anything else. |
API keys may have a per-client request rate limit. Past it, the API returns 429 Too Many Requests. Back off and retry after a short delay.
| 400 | Unknown region, or an origin outside every Modemix region |
| 401 | Missing or invalid API key |
| 422 | The body doesn't match the request schema. detail names the field |
| 429 | Rate limit exceeded |
| 502 | Routing failed. Retry shortly |
| 503 | Routing is unavailable in this region right now |
| 504 | The search timed out |
Error bodies are { "detail": ... }.
Street data © OpenStreetMap contributors. Schedules and live times come from the transit agencies that publish them.
Create an account, set up billing, and make keys in the API console. You pay only for the requests you make.
Get an API key