CS 193V · Assignment 8 API
Stanford-area routing for your web app
Calling the API
Every request needs your key in a header: Authorization: Bearer cs193v_a8_.... Send JSON with POST. Points are {"lat": ..., "lon": ...} anywhere in the Bay Area. mode is "walk", "bike", or "drive".
Call this API from your server code (a Next.js route handler), never from browser JavaScript. Browsers are blocked on purpose.
POST /v1/route
{"from": {"lat": 37.4246, "lon": -122.1765}, "to": {"lat": 37.4300, "lon": -122.1730}, "mode": "walk"}
Returns distance_km, duration_min, path (a list of [lat, lon]), and turn-by-turn steps.
POST /v1/isochrone
{"center": {"lat": 37.4275, "lon": -122.1700}, "mode": "bike", "minutes": [5, 10, 15]}
Everywhere reachable within each time, as GeoJSON (up to 4 times, 30 minutes max). Pass it straight to Leaflet's L.geoJSON().
POST /v1/matrix
{"sources": [{"lat": 37.4246, "lon": -122.1765}], "targets": [{"lat": 37.4300, "lon": -122.1730}, {"lat": 37.4243, "lon": -122.1708}], "mode": "walk"}
Travel time from every source to every target (up to 10 × 10). durations_min[i][j] is source i to target j.
POST /v1/optimized_route
{"stops": [{"lat": 37.4246, "lon": -122.1765}, {"lat": 37.4243, "lon": -122.1708}, {"lat": 37.4300, "lon": -122.1730}], "mode": "walk"}
Visits every stop (3 to 10). The first is the start, the last is the end, and the middle ones are reordered to be fastest. order gives the visiting order as indexes into stops.
GET /v1/dining
Places to eat on campus, with coordinates.
GET /v1/usage
Your usage log as JSON.
Limits
Each key gets 30 points a minute (bursts up to 20). Route, dining, and usage cost 1 point; isochrone, matrix, and optimized_route cost 3. Going over returns 429 with a Retry-After header.
Base URL: https://api.cs193v-api.dev