Modemix API / Docs

API docs

Everything POST /v1/directions takes and returns: step-by-step directions that combine biking, bikeshare or walking with public transit.

Get an API key

Synopsis

POST https://api.modemix.io/v1/directions
x-api-key: mmx_your_key_here
Content-Type: application/json

Pricing

Billed per request, pay as you go. Usage is summed monthly across all API keys linked to your account.

Monthly volumePer 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.

Authentication

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 '{ ... }'

POST /v1/directions

Plan routes between two points. Times and speeds are in seconds, meters and meters per second throughout.

Trips

mode and transit together pick the kind of trip:

modetransitThe trip
biketrueRide to transit and from it. The default.
bikefalseRide the whole way.
walktrueWalk to transit and from it.
walkfalseWalk the whole way.
bikesharetrueRent a bike or scooter to transit and from it, and walk between transit legs.
bikesharefalseRent 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.

Request

{
  "origin": { "latitude": 37.7596, "longitude": -122.4269 },
  "destination": { "latitude": 37.8053, "longitude": -122.2725 },
  "depart_at": 1795537800,
  "mode": "bike"
}
origin{ latitude, longitude }required
Where the trip starts.
destination{ latitude, longitude }required
Where it ends.
regionstringdefault from origin
The region to route in, such as bay_area. Left out, it is the region that contains the origin.
depart_atunix secondsdefault now
Leave at or after this time.
arrive_byunix secondsdefault null
Arrive by this time instead. Send depart_at or arrive_by, not both.
mode"bike" | "bikeshare" | "walk"default "bike"
How the rider gets to and from transit. bikeshare rents a bike or scooter for the ends of the trip and walks between transit legs.
bike_type"full_size" | "folding"default "full_size"
For mode: "bike". A full-size bike boards only the vehicles that carry bikes and avoids stations with stairs. A folding bike rides anything.
transitbooleandefault true
false returns at most one route, which rides or walks the whole way.
exclude_transitstring[]default []
Transit to leave out: bus, train, subway, tram, ferry, monorail, funicular_gondola.
max_transfersintegerdefault none
The most times a route may change vehicles. 0 allows one vehicle only.
max_seconds_to_stationintegerdefault none
The longest the search lets the rider spend getting to the first station, and from the last. At least 300. Where a one-stop ride near either end saves nothing, Modemix rides on instead, so that ride can run longer.
bike_speed_mpsnumberdefault 4.5
Riding speed on the rider's own bike, rounded to the nearest of 4.5, 6.7, 8.9 and 10.7.
walk_speed_mpsnumberdefault 1.39
Walking speed, rounded to the nearer of 1.39 and 1.88.
bikeshareobjectdefault null
For 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.
max_resultsintegerdefault 6
How many routes to return, at most 6.

Response

{
  "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"
}
regionstring
The region the trip was routed in.
routesRoute[]
Every route found, empty when there is none.
no_route_reasonstring | null
Why routes is empty. Null when it isn't.
searched_from, searched_untilISO 8601
The departures the search covered, so an empty answer can say nothing leaves before a given time.
bikeshare_brandsBrand[]
For 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.

Route

departure, arrivalISO 8601
In the region's local time, with its UTC offset. Live estimates where the agency publishes them.
duration_secondsinteger
Door to door.
distance_metersinteger
Every leg added up.
transfersinteger
How many times the route changes vehicles.
fare{ amount, currency } | null
What an adult pays at the cheapest way to pay, or null when it isn't known.
legsLeg[]
The route, one leg per way of getting around, in order.

Leg

typestring
bike, scooter, walk, transit, or transfer: a change of vehicles inside a station or across a short footpath.
departure, arrivalISO 8601
When the leg starts and ends.
duration_seconds, distance_metersinteger
The whole leg.
from, to{ name, latitude, longitude }
name is the station or dock, and null at the trip's own ends and anywhere on the street.
polylinestring
The leg's path as an encoded polyline, precision 5.

Bike, scooter, walk and transfer legs also have

moving_seconds, moving_metersinteger
The leg on the move, without the time spent inside stations.
station_exit_secondsinteger
Getting out of the station the leg starts at: walking the bike up from the platform, or the walk out to the street.
station_entry_secondsinteger
Getting into the station the leg ends at.
rentalobject
On a rented bike or scooter: 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" }.

Transit legs also have

vehiclestring
bus, coach, trolleybus, train, subway, tram, cable_car, ferry, monorail, funicular, gondola, and a few rarer kinds.
lineobject
name, long_name, agency, and color and text_color as #RRGGBB. See Line badges for logo_url and mark.
headsignstring
Where the vehicle is headed, as signed on it.
scheduled_departure, scheduled_arrivalISO 8601
The timetable. realtime is true when departure and arrival are live estimates.
stays_on_boardboolean
The rider stays on the vehicle from the previous leg.
fare{ amount, currency, transfer } | null
What this leg adds to the fare. transfer is true when an earlier leg's ticket covers it.
stops{ name, latitude, longitude }[]
The stops ridden through, between from and to.

Line badges

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:

logo_urlstring | null
The line's own logo, drawn instead of its name: a BART line's colored bar, a subway bullet.
mark{ url, style, text } | null
A symbol drawn beside 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.
name, color, text_colorstring
Without either, the name in text_color on a rounded rectangle of color.

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.

No route

A trip with no route answers 200 with an empty routes array and a no_route_reason:

outside_coverageAn end of the trip is off the streets Modemix covers.
no_stations_in_reachNo station is within reach of an end of the trip.
no_transit_serviceNo transit connects the two ends around this time.
street_route_is_betterRiding or walking the whole way beats every transit route. Ask again with transit: false.
no_street_routeNo street route connects the two ends.
no_bikeshare_nearbyNo bikeshare brand has a vehicle near either end.
renting_does_not_helpWalking to and from transit beats renting on every route found. Ask again with mode: "walk".
no_routeAnything else.

Rate limiting

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.

Errors

400Unknown region, or an origin outside every Modemix region
401Missing or invalid API key
422The body doesn't match the request schema. detail names the field
429Rate limit exceeded
502Routing failed. Retry shortly
503Routing is unavailable in this region right now
504The search timed out

Error bodies are { "detail": ... }.

Data

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