Curated from 511 Data Exchange Specification — Transit, v1.35 (Nov 16, 2022), Metropolitan Transportation Commission. This is a working subset covering the endpoints this app uses — see the full PDF for the complete spec (Operator/Line/Stop/StopPlace/Pattern/Timetable, GTFS & GTFS-RT, SIRI data structures).
- Base URL:
http://api.511.org/transit - Method: HTTP
GET(Open511 uses GET rather than the SIRI-standard POST). - Auth: every request needs
api_key=<your key>(mandatory). A missing/invalid key returns 401 Unauthorized. - Format:
format=json(orxml). Default is JSON when omitted. - Operator / agency code for SF Muni is
SF. (Other examples in the spec:ACAC Transit,BABART,GGGolden Gate,SFMuni.) - ⚠ Responses are UTF-8 with a BOM. The JSON body begins with a byte-order mark
(
/EF BB BF). Strip it beforejson.Unmarshal, or parsing fails. (Confirmed on every live endpoint.) - ⚠ Responses are gzip-compressed. Use a client that sends
Accept-Encoding: gzipand decompresses transparently (Go'snet/httpdoes this by default;curlneeds--compressed). - ⚠ Spec vs. reality (verified against the live API, June 2026):
StopMonitoringreturnsServiceDeliveryat the top level — there is noSiriwrapper, despite the spec's §B.1.10 example. (Accept both to be safe.)MonitoredVehicleJourney.LineRefis the short route code ("N","14R");PublishedLineNameis the descriptive name ("JUDAH","MARINA EXPRESS"). UseLineReffor route-code/badge matching.- Stop
Location.Longitude/Latitudeare JSON strings, not numbers. linesobjects also includeFromDate/ToDate;stopsScheduledStopPointobjects includeExtensions,Url, andStopType.- Captured sample responses live in
internal/transit/testdata/live_*.json.
- Rate limit: 60 requests per 3600 seconds per API key, shared across all endpoints. Polling once per 60s sits exactly at the limit — keep the combined request rate (incl. setup calls) below it.
- Common errors:
401invalid key,404resource not found,500server error.
List transit operators in the jurisdiction.
| Parameter | Req | Description |
|---|---|---|
api_key |
✔ | API key |
operator_id |
Filter to one operator code | |
format |
json (default) / xml |
Example: http://api.511.org/transit/operators?api_key=KEY&format=json
Each operator: Id, Name, ShortName, Monitored (real-time enabled?),
PrimaryMode, Locale.TimeZone, contact details.
List the routes for an operator. Used at first-run to build the line picker (cached).
| Parameter | Req | Description |
|---|---|---|
api_key |
✔ | API key |
operator_id |
✔ | Operator code, e.g. SF |
line_id |
Filter to a single line | |
format |
json (default) / xml |
Example: http://api.511.org/transit/lines?api_key=KEY&operator_id=SF
Line fields: Id (unique route id), Name, TransportMode, PublicCode
(public route identifier, e.g. N, 14R), SiriLineRef, OperatorRef,
Monitored (real-time available?).
List the stops served by an operator. Filter by line_id to get only that route's stops
(used after a line is picked). Cached.
| Parameter | Req | Description |
|---|---|---|
api_key |
✔ | API key |
operator_id |
✔ | Operator code, e.g. SF |
line_id |
Restrict to stops on a line | |
direction_id, pattern_id |
Further filters | |
include_stop_areas |
Also return stop groupings | |
format |
json (default) / xml |
Example: http://api.511.org/transit/stops?api_key=KEY&operator_id=SF&line_id=N
Returned as NeTEx ServiceFrame.scheduledStopPoints[]. Each ScheduledStopPoint:
id (this is the stop code used by StopMonitoring), Name, StopType,
Location{ Longitude, Latitude }, optional Extensions.PlatformCode / ParentStation.
SIRI Stop Monitoring: current and forthcoming arrivals/departures at a stop. This is the endpoint the app polls (once per 60s).
| Parameter | Req | Description |
|---|---|---|
api_key |
✔ | API key |
agency |
✔ | Agency/operator code, e.g. SF |
stopcode |
Numeric stop code. If omitted, returns all stops (slow) | |
format |
json (default) / xml |
Example: http://api.511.org/transit/StopMonitoring?api_key=KEY&agency=SF&stopcode=15553&format=json
Siri
└─ ServiceDelivery
├─ ResponseTimestamp
├─ ProducerRef
└─ StopMonitoringDelivery
└─ MonitoredStopVisit[] # array (single object if only one)
├─ RecordedAtTime
├─ MonitoringRef # the stop code
└─ MonitoredVehicleJourney
├─ LineRef # route id
├─ DirectionRef # e.g. "E" / "W" / "IB" / "OB"
├─ PublishedLineName # public route name -> badge lookup
├─ OperatorRef
├─ OriginName
├─ DestinationName # headsign
├─ Monitored
└─ MonitoredCall
├─ StopPointRef
├─ StopPointName
├─ AimedArrivalTime # scheduled (RFC3339)
├─ ExpectedArrivalTime # predicted (RFC3339) <-- countdown source
├─ AimedDepartureTime
└─ ExpectedDepartureTime
Minutes to arrival = ExpectedArrivalTime − now (fall back to
ExpectedDepartureTime, then the Aimed* equivalents, if a field is absent). Timestamps
are RFC3339 with a numeric offset, e.g. 2022-03-22T15:55:51-07:00.
Note:
MonitoredStopVisitmay be a single object rather than an array when only one visit is returned — decode defensively.
{
"Siri": {
"ServiceDelivery": {
"ResponseTimestamp": "2004-12-17T09:30:46-05:00",
"ProducerRef": "BA",
"Status": true,
"StopMonitoringDelivery": {
"version": 1.4,
"ResponseTimestamp": "2004-12-17T09:30:47-05:00",
"Status": true,
"MonitoredStopVisit": {
"RecordedAtTime": "2004-12-17T09:25:46-05:00",
"MonitoringRef": "EMBR",
"MonitoredVehicleJourney": {
"LineRef": "Warm Springs/South Fremont - Daly City",
"DirectionRef": "E",
"PublishedLineName": "Warm Springs/South Fremont - Daly City",
"OperatorRef": "BA",
"DestinationName": "Warm Springs/South Fremont",
"Monitored": true,
"MonitoredCall": {
"StopPointRef": "EMBR",
"StopPointName": "Embarcadero BART Station",
"AimedArrivalTime": "2004-12-17T09:40:46-05:00",
"ExpectedArrivalTime": "2004-12-17T09:40:46-05:00",
"AimedDepartureTime": "2004-12-17T09:42:47-05:00",
"ExpectedDepartureTime": "2004-12-17T09:40:47-05:00"
}
}
}
}
}
}
}Not used by this app, included for completeness.
| Parameter | Req | Description |
|---|---|---|
api_key |
✔ | API key |
agency |
✔ | Agency code |
vehicleID |
Filter to one vehicle | |
format |
json (default) / xml |
Returns Siri.ServiceDelivery.VehicleMonitoringDelivery.VehicleActivity[] with
MonitoredVehicleJourney (incl. VehicleLocation{Longitude,Latitude}, Bearing,
Occupancy, MonitoredCall, OnwardCalls).