I'm new to using this API and I have some beginner questions I'm sure many of you can help me with.
I'm building an LED sign showing part of the Redline subway and I would like to display trains on the LEDs.
I'm using a very resource-constrained microcontroller, so this project has been on hold for a few years since I could not parse the old PROTOBUF-style responses.
I'm VERY happy to see the new JSON-style API. I think I will be able to now query for train locations on the Redline and display them appropriately on my sign.
I am trying to understand the structure of the queries and responses and I'm a little lost as a beginner.
I see that I can query the location of all the Redline trains using this:
QueryThat's AWESOME!
I started out trying to use the Latitude and Longitude to locate a particular subway stop but I think there's a better way right?
Now I'm looking at vehicles that have a "current_status": "STOPPED_AT" and I'm trying to figure out what stop they are stopped at.
I see that the relationships/stop/data/id has a string, but I'm unsure how to determine which stop that is?
From /vehicles, here's a train that is stooped:
{
"attributes": {
"current_status": "STOPPED_AT",
"direction_id": 1,
"latitude": 42.35526,
"longitude": -71.06016
},
"id": "R-5469174F",
"links": {
"self": "/vehicles/R-5469174F"
},
"relationships": {
"route": {
"data": {
"id": "Red",
"type": "route"
}
},
"stop": {
"data": {
"id": "70078",
"type": "stop"
}
},
"trip": {
"data": {
"id": "46386250",
"type": "trip"
}
}
},
"type": "vehicle"
},
From /stops this the the closest match for Latitude,Longitude:
"attributes": {
"address": "Washington St and Summer St, Boston, MA",
"at_street": null,
"description": null,
"latitude": 42.355518,
"location_type": 1,
"longitude": -71.060225,
"municipality": "Boston",
"name": "Downtown Crossing",
"on_street": null,
"platform_code": null,
"platform_name": null,
"vehicle_type": null,
"wheelchair_boarding": 1
},
"id": "place-dwnxg",
"links": {
"self": "/stops/place-dwnxg"
},
"relationships": {
"child_stops": {},
"facilities": {
"links": {
"related": "/facilities/?filter[stop]=place-dwnxg"
}
},
"parent_station": {
"data": null
},
"recommended_transfers": {},
"zone": {
"data": null
}
},
"type": "stop"
},
I'm not finding anything in the result from the /vehicle endpoint that will allow me to match up with the information from the /stops endpoint.
Can you help a beginner get going with this?
Thank you all for your help in advance. I know it's hard to get a newcomer going with complex APIs such as these.