Stops and departures
Two routes answer "what leaves from near here, and when". GET /v1/stops finds the stops near a point and the routes that call at each. GET /v1/departures lists the next departures from one stop, from the timetable, with live delays where an operator applies a realtime feed. Both read GTFS feeds — the format transit agencies publish timetables in — and answer only where a feed for the area is loaded; without any, they are a400, no transit layer loaded. Most examples here are from BART, in the San Francisco Bay Area; one is from Guadalajara.
Stops near a point
curl -G "https://api.oslew.com/v1/stops" \
-H "Authorization: Bearer $GEO_API_KEY" \
--data-urlencode 'at=37.7929,-122.3971' \
--data-urlencode 'radius_m=300' \
--data-urlencode 'limit=3'from oslew import Client
# The key is read from GEO_API_KEY.
client = Client(base_url="https://api.oslew.com")
answer = client.stops("37.7929,-122.3971", radius_m=300, limit=3)import { Client } from "@oslew/client";
// The key is read from GEO_API_KEY.
const client = new Client({ baseUrl: "https://api.oslew.com" });
const answer = await client.stops("37.7929,-122.3971", { radius_m: 300, limit: 3 });HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 293
ratelimit-reset: 1
{
"at": [
37.7929,
-122.3971
],
"results": [
{
"stop": {
"id": "M16-1",
"name": "Embarcadero",
"lat": 37.792789,
"lon": -122.39708,
"parent": 109,
"platform": "1",
"boarding": true
},
"distance_m": 12.467138822531075,
"routes": [
{
"id": "1",
"short_name": "Yellow-S",
"long_name": "Antioch to SF Int'l Airport SFO/Millbrae",
"kind": 1
},
{
"id": "5",
"short_name": "Green-S",
"long_name": "Berryessa/North San Jose to Daly City",
"kind": 1
},
{
"id": "7",
"short_name": "Red-S",
"long_name": "Richmond to SF Int'l Airport SFO/Millbrae",
"kind": 1
},
{
"id": "11",
"short_name": "Blue-S",
"long_name": "Dublin/Pleasanton to Daly City",
"kind": 1
}
],
"provenance": {
"name": "bart",
"release": "2026-08-19.0",
"license": "BART developer terms"
}
},
{
"stop": {
"id": "M16-2",
"name": "Embarcadero",
"lat": 37.792741,
"lon": -122.397019,
"parent": 109,
"platform": "2",
"boarding": true
},
"distance_m": 19.05888977190873,
"routes": [
{
"id": "2",
"short_name": "Yellow-N",
"long_name": "Millbrae/SF Int'l SFO to Antioch",
"kind": 1
},
{
"id": "6",
"short_name": "Green-N",
"long_name": "Daly City to Berryessa/North San Jose",
"kind": 1
},
{
"id": "8",
"short_name": "Red-N",
"long_name": "Millbrae/SF Int'l Airport SFO to Richmond",
"kind": 1
},
{
"id": "12",
"short_name": "Blue-N",
"long_name": "Daly City to Dublin/Pleasanton",
"kind": 1
}
],
"provenance": {
"name": "bart",
"release": "2026-08-19.0",
"license": "BART developer terms"
}
}
],
"took_us": 9
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
Embarcadero station has two platforms, 12 m and 19 m from the point, and each is its own stop: platform 1 (M16-1) is where the four southbound lines call, the ones whose names end -S, and platform 2 (M16-2) the four northbound. The request asked for three and got two, because only two are within 300 m — limit is a ceiling, not a promise.
| Parameter | Default | Is |
|---|---|---|
at | required | The point, lat,lon. |
radius_m | 1000 | Only stops within this many metres, straight line. Clamped to 0–5,000. |
limit | 5 | At most this many stops, nearest first. Clamped to 1–50. |
Stops from every loaded feed are merged, nearest first, and each result carries its own feed'sprovenance — a feed's licence is often its agency's own terms, as BART's is here.
Field of stop | Is |
|---|---|
id | The feed's stop_id. This is what /v1/departures takes as stop. |
name | The feed's stop_name. Platforms of one station usually share it. |
lat, lon | Where the feed puts the stop. |
parent | The station the stop belongs to, as an index into the feed's stops — not a stop_id. Stops with the same parent are platforms of one station; null when the feed gives none. |
platform | The feed's platform_code, when it has one. |
boarding | Whether riders board here. Only boarding stops are listed — platforms and street stops, not the stations that group them — unless a feed has no boarding stops at all. |
The same request near Guadalajara's cathedral answers from Jalisco's feed. Its three nearest stops are a light-rail station and two bus stops, each with the routes that call there:
HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 291
ratelimit-reset: 1
{
"at": [
20.6767,
-103.3475
],
"results": [
{
"stop": {
"id": "S00000724",
"name": "Guadalajara Centro",
"lat": 20.67571,
"lon": -103.347372,
"parent": null,
"platform": null,
"boarding": true
},
"distance_m": 110.88560550525033,
"routes": [
{
"id": "MT_L3",
"short_name": "TL-3",
"long_name": "",
"kind": 1
}
],
"provenance": {
"name": "Secretaría de Transporte del Estado de Jalisco (SETRAN)",
"release": "2026-11-23",
"license": "see feed terms"
}
},
{
"stop": {
"id": "LM-V02_r1_77",
"name": "Plaza Guadalajara",
"lat": 20.677277,
"lon": -103.348437,
"parent": null,
"platform": null,
"boarding": true
},
"distance_m": 116.6983607796165,
"routes": [
{
"id": "LM-V02",
"short_name": "LM-V02",
"long_name": "",
"kind": 3
},
{
"id": "R-03",
"short_name": "R-03",
"long_name": "",
"kind": 3
}
],
"provenance": {
"name": "Secretaría de Transporte del Estado de Jalisco (SETRAN)",
"release": "2026-11-23",
"license": "see feed terms"
}
},
{
"stop": {
"id": "moovit_81208255",
"name": "Independencia",
"lat": 20.677937,
"lon": -103.346583,
"parent": null,
"platform": null,
"boarding": true
},
"distance_m": 167.39249957203404,
"routes": [
{
"id": "T14B-C02 Benito Juarez",
"short_name": "T14B-C02",
"long_name": "Benito Juarez",
"kind": 3
}
],
"provenance": {
"name": "Secretaría de Transporte del Estado de Jalisco (SETRAN)",
"release": "2026-11-23",
"license": "see feed terms"
}
}
],
"took_us": 1392
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
Guadalajara Centro, 110 m away, is a station of the city's Line 3 (TL-3,kind 1, metro); Plaza Guadalajara and Independencia are bus stops (kind 3). The licence comes back as see feed terms: read the feed's own terms before you republish its timetable.
Each result's routes are the routes with a trip calling there: id (the feed'sroute_id), short_name, long_name, and kind, the GTFSroute_type:
kind | 0 | 1 | 2 | 3 | 4 |
|---|---|---|---|---|---|
| Mode | Tram, light rail | Metro, subway | Rail | Bus | Ferry |
Those are the common ones; a feed may use any value the GTFS specification defines — 5 for a cable tram, 7 for a funicular, 11 for a trolleybus, and the extended values in the hundreds some agencies use — and kindcarries it as given. Map unknown values to a generic icon rather than failing.
Departures from a stop
| Parameter | Default | Is |
|---|---|---|
stop | — | A stop_id, as /v1/stops gives it. Exactly one of stop and at. |
at | — | A point, lat,lon: the answer is for the single nearest boarding stop within 1 km. |
time | now | Unix seconds. Departures at or after this instant. |
limit | 5 | At most this many departures. Clamped to 1–50. |
Both or neither of stop and at is a 400, exactly one of stop or at. An id no feed has is no stop `…` in any feed; a point with no stop within 1 km is no stop within 1 km of ….
curl -G "https://api.oslew.com/v1/departures" \
-H "Authorization: Bearer $GEO_API_KEY" \
--data-urlencode 'stop=M16-1' \
--data-urlencode 'time=1787756400' \
--data-urlencode 'limit=3'from oslew import Client
# The key is read from GEO_API_KEY.
client = Client(base_url="https://api.oslew.com")
answer = client.departures(stop="M16-1", time=1787756400, limit=3)import { Client } from "@oslew/client";
// The key is read from GEO_API_KEY.
const client = new Client({ baseUrl: "https://api.oslew.com" });
const answer = await client.departures({ stop: "M16-1", time: 1787756400, limit: 3 });HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 292
ratelimit-reset: 1
{
"stop": {
"id": "M16-1",
"name": "Embarcadero",
"lat": 37.792789,
"lon": -122.39708,
"parent": 109,
"platform": "1",
"boarding": true
},
"distance_m": null,
"time": 1787756400,
"timezone": "America/Los_Angeles",
"live": null,
"departures": [
{
"time": 1787756400,
"route": 0,
"route_short_name": "Yellow-S",
"route_long_name": "Antioch to SF Int'l Airport SFO/Millbrae",
"headsign": "San Francisco International Airport",
"trip_id": "1965170",
"direction": 1,
"scheduled": 1787756400,
"delay_s": 0
},
{
"time": 1787756700,
"route": 4,
"route_short_name": "Green-S",
"route_long_name": "Berryessa/North San Jose to Daly City",
"headsign": "OAK Airport / SF / Daly City",
"trip_id": "1965492",
"direction": 1,
"scheduled": 1787756700,
"delay_s": 0
},
{
"time": 1787756880,
"route": 6,
"route_short_name": "Red-S",
"route_long_name": "Richmond to SF Int'l Airport SFO/Millbrae",
"headsign": "SF / SFO Airport / Millbrae",
"trip_id": "1965631",
"direction": 1,
"scheduled": 1787756880,
"delay_s": 0
}
],
"provenance": {
"name": "bart",
"release": "2026-08-19.0",
"license": "BART developer terms"
},
"took_us": 9
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
The next three trains from Embarcadero's platform 1 at 08:00 on a Wednesday morning, Pacific time: a Yellow-S train to San Francisco International Airport at 08:00 exactly — "at or after" includes the instant asked for — then a Green-S at 08:05 and a Red-S at 08:08. live is null: no realtime feed is applied, so every delay_s is 0 and every time is its scheduled.
| Field of each departure | Is |
|---|---|
time | When it leaves, unix seconds — the live time when a realtime feed says the trip is late or early. |
scheduled | The timetable's time. |
delay_s | time − scheduled: seconds late, negative when early, 0 without a feed. |
route_short_name, route_long_name | The route, as its riders know it. |
route | An index into the feed's routes — not its route_id. Use route_short_name to match a departure to one of /v1/stops' routes. |
headsign | Where the trip says it is going, as shown on the train. |
trip_id | The feed's trip_id: the id realtime updates name the trip by, and the one journeys give for each ride. |
direction | The feed's direction_id, 0 or 1. What each means is the agency's choice. |
Departures come in order of time, then route, then trip.
By point: one stop, one direction
With at, the answer is for the nearest boarding stop and nothing else, and says how far it is indistance_m (it is null when you named the stop). At a station with a platform per direction that is one direction: at beside Embarcadero answers for platform 1 or platform 2, whichever is a few metres nearer. For a station board, ask /v1/stops for the platforms and then ask for each one's departures. And ask for a platform's id rather than a station's: trips call at platforms, so a station has no departures of its own.
Times, time zones and service days
Every time is unix seconds, and timezone is the feed's own — the agency's time zone, the one its timetable is written in. Convert with that zone, not the server's and not the viewer's device, or a rider in another zone sees the wrong departure time:
from datetime import datetime
from zoneinfo import ZoneInfo
from oslew import Client
client = Client(base_url="https://api.oslew.com")
board = client.departures(stop="M16-1", limit=5)
tz = ZoneInfo(board["timezone"])
for d in board["departures"]:
at = datetime.fromtimestamp(d["time"], tz).strftime("%H:%M")
late = f" ({d['delay_s'] // 60} min late)" if d["delay_s"] >= 60 else ""
print(f"{at} {d['route_short_name']:<9} {d['headsign']}{late}")import { Client } from "@oslew/client";
const client = new Client({ baseUrl: "https://api.oslew.com" });
const board = await client.departures({ stop: "M16-1", limit: 5 });
const clock = new Intl.DateTimeFormat("en-GB", { timeZone: board.timezone, hour: "2-digit", minute: "2-digit" });
for (const d of board.departures) {
const late = d.delay_s >= 60 ? ` (${Math.floor(d.delay_s / 60)} min late)` : "";
console.log(`${clock.format(d.time * 1000)} ${d.route_short_name.padEnd(9)} ${d.headsign}${late}`);
}A timetable's day is a service day, which does not end at midnight. GTFS writes a train that leaves at 01:10 after a Wednesday evening as 25:10 on Wednesday's service, and that is how it runs: on the dates Wednesday's service runs, per the feed's calendar and its exceptions. A request is answered from the service day oftime and the one before it, so a query at 00:30 on Thursday finds Wednesday's late trains as well as Thursday's.
It does not look into the next service day. After the last train of the night the list is short or empty, not the first trains of the morning; to show those, ask again with a time in the morning.
Live delays
Timetables say when a train should leave; a realtime feed says when it will. Agencies publish GTFS-Realtime trip updates, and an operator applies them to the service — the operator product, on Enterprise, described inoperator feeds. When one is in force for a stop's feed, departures carry it:
The same platform, after a realtime update put trip 1965170 five minutes late
curl -G "https://api.oslew.com/v1/departures" \
-H "Authorization: Bearer $GEO_API_KEY" \
--data-urlencode 'stop=M16-1' \
--data-urlencode 'time=1787756400' \
--data-urlencode 'limit=3'from oslew import Client
# The key is read from GEO_API_KEY.
client = Client(base_url="https://api.oslew.com")
answer = client.departures(stop="M16-1", time=1787756400, limit=3)import { Client } from "@oslew/client";
// The key is read from GEO_API_KEY.
const client = new Client({ baseUrl: "https://api.oslew.com" });
const answer = await client.departures({ stop: "M16-1", time: 1787756400, limit: 3 });HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 299
ratelimit-reset: 1
{
"stop": {
"id": "M16-1",
"name": "Embarcadero",
"lat": 37.792789,
"lon": -122.39708,
"parent": 109,
"platform": "1",
"boarding": true
},
"distance_m": null,
"time": 1787756400,
"timezone": "America/Los_Angeles",
"live": 1787756100,
"departures": [
{
"time": 1787756700,
"route": 0,
"route_short_name": "Yellow-S",
"route_long_name": "Antioch to SF Int'l Airport SFO/Millbrae",
"headsign": "San Francisco International Airport",
"trip_id": "1965170",
"direction": 1,
"scheduled": 1787756400,
"delay_s": 300
},
{
"time": 1787756700,
"route": 4,
"route_short_name": "Green-S",
"route_long_name": "Berryessa/North San Jose to Daly City",
"headsign": "OAK Airport / SF / Daly City",
"trip_id": "1965492",
"direction": 1,
"scheduled": 1787756700,
"delay_s": 0
},
{
"time": 1787756880,
"route": 6,
"route_short_name": "Red-S",
"route_long_name": "Richmond to SF Int'l Airport SFO/Millbrae",
"headsign": "SF / SFO Airport / Millbrae",
"trip_id": "1965631",
"direction": 1,
"scheduled": 1787756880,
"delay_s": 0
}
],
"provenance": {
"name": "bart",
"release": "2026-08-19.0",
"license": "BART developer terms"
},
"took_us": 24
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
Compare it with the one above. The Yellow-S train, trip 1965170, now leaves at 08:05:scheduled is still 08:00, and delay_s is 300. It still comes first, level with the Green-S at 08:05, because equal times order by route. live is now 1787756100 — 07:55 Pacific, the realtime feed's own timestamp, which says how fresh the delays are.
timeisscheduled + delay_s, and the list is ordered by it. A trip running early has a negative delay and moves up.- A trip due before
timebut running late enough to leave after it is in the list; delays of up to three hours are looked for. - A call the feed says is skipped is not in the list at all.
- A delay reported at one stop holds for the trip's later stops until the feed says otherwise, as GTFS-Realtime specifies.
For getting from one place to another by transit — walking to a stop, riding, changing — seejourney planning, which reads the same timetables and the same delays.
Endpoints
/v1/stopsroutingThe transit stops nearest a point, with the routes calling at each, from a GTFS feed.
/v1/departuresroutingThe next scheduled departures from a stop, or from the nearest stop to a point, on the feed's calendar in its own time zone.