Description of Methods

The following methods describe the Metro Rail system:

  1. Lines  -  Returns Metro lines.
  2. Stations - Returns the list of Metro stations.
  3. Station Info - Returns information about individual Metro stations.
  4. Path - Returns a path of stations between two stations.
  5. Station Prediction - Returns station arrival information as it appears on Public Information Displays.
  6. Rail Incidents - Returns incident information as it appears on the Public Information Displays.
  7. Elevator/Escalators Incidents - Returns information about elevators and escalators as it appears on the Public Information Displays.
  8. Station Entrances - Returns entrances to Metro stations.
  9. Bus Routes - Returns the list of all bus routes.
  10. Bus Stops - Returns the list of all bus stops.
  11. Bus Schedule by Route - Returns schedule for the route.
  12. Bus Route Details - Returns shape of the route (locations the bus is going through) and its bus stops.
  13. Bus Positions - Returns real time bus positions.
  14. Bus Schedule by Stop - Returns schedule for the stop.
  15. Bus Prediction - Returns the bus arrival predictions for a specific bus stop according to the real-time positions of the buses. 

Each method has 2 endpoints: REST and JSON.

URL (REST) example: http://api.wmata.com/StationPrediction.svc/GetPrediction/A10?api_key=YOUR_API_KEY

URL (JSON) example: http://api.wmata.com/StationPrediction.svc/json/GetPrediction/A10?api_key=YOUR_API_KEY

Additionally, developers can use JSONP if desired by adding a "callback" parameter to the JSON call:

http://[url to JSON service]?api_key=[your_key]&callback=[name of callback] 

When using JSONP make sure that [name of callback] in the URL displayed above is the name of a Javascript function needed to process the JSON data.

See sample SilverLight application

63 Comments

  1. RamonaW3 years ago

    Web API Documentation Best Practices <http://blog.programmableweb.com/2010/08/12/web-api-documentation-best-practices/> suggests (among other things) that you should

    'Show Example Requests and Responses

    In addition to sample code, having HTTP, XML, and JSON samples of your request and response is important. However, samples only are not sufficient. In addition, you need a description that explains the purpose of the call and you need a table that explains each element. We recommend a table with columns for Name, Type, Description, and Remarks.

    Although the Type column provides most of the information you need regarding format, the remarks section may need to specify further. If an XML element is a date, you should specify the format of the date. If it’s a time, then you need to specify its time-zone."

  2. Wmata Admin3 years ago

    RamonaW: Thanks for the thoughtful suggestions. We will be beefing up the documentation in the near future and will consult the Best Practices doc that you linked to for guidance. Thanks - Bill

  3. Bold, Inc.3 years ago

    Does the WMATA API currently support JSONP? (http://en.wikipedia.org/wiki/JSON#JSONP) If not, would you consider enabling it?

  4. Peter Shashkin3 years ago

    We thought about it, and I believe if we have demand for it we should definitely go for it. At this point our priority is to expand range of services rather than providing additional formats. When we release bus information we should consider jsop, but I cannot provide eta at this point

  5. Bold, Inc.3 years ago

    Thanks for the response and I appreciate the future consideration and I'm sure there will be quite a few developers who will use the JSONP option.

    I just wanted to send along a blog post from Mashery demonstrating some example code for enabling JSONP with PHP in just a couple lines. (The code is very simple and could easily be written in your language of choice if it is not PHP).

    They also mention the possibility of a service to enable JSONP with a simple configuration change in your Mashery account, though I don't know if they have actually implemented that change.

    http://support.mashery.com/blog/read/New_Feature_JSONP_Error_Sets

    Thanks!

  6. Bold, Inc.3 years ago

    We have just launched our app http://nextmetro.com and it seems that it has gained enough popularity in a day or so and we have already hit our API rate limit. Is there someone I can contact about an API rate increase for the key we use on our "NextMetro" app? We are caching what we can, but are relying heavily on train predications which change rapidly, so we only cache each train predication call for 20 seconds.

    Thanks for your help!

  7. Wmata Admin3 years ago

    Bold-Inc. - We have upped the rate limit for your app per your request.

  8. Bold, Inc.3 years ago

    Thanks for the rate limit help!

    One thing I noticed tonight:
    JSONP appears to be enabled now by default. I'm thrilled that JSONP is operational but it is now on by default even when not specifying a callback function. (if no callback function is specified it wraps the response in "callback()"). That will break any app that is currently expecting regular JSON from the JSON requests. Can you alter the code to only enable JSONP when the callback query parameter is present? Thanks!

  9. perdog3 years ago

    I can confirm the issue that Bold, Inc. Mentioned above. My iPhone app is now broken and not working because of this change!

    While I am expecting JSON, Everything is all of a sudden wrapped in a Callback() function that is breaking my application.

    Was this intentional or a mistake?

    I hope it was a mistake and you can fix it quickly. As you may know, it takes over a week to get an update through the Apple app store.

    Thank you for your help!

  10. Peter Shashkin3 years ago

    This was mashery adapters update issue. Should be fixed now - let us know if you still having problems

  11. perdog3 years ago

    Hi all,

    First off, big thanks for making this API available. 2 quick questions:

    1. What's the best way to get in touch with the development team if something like the JSONP issue happens again? This comment board? Facebook? An email address? Everything is great now, but just wondering.

    2. Is there a method to check how many API requests my API key has been used for in a day - and of course how many are remaining?

    Thanks

  12. Madhvi3 years ago

    Hi all, I have been trying to get Rail Station Prediction for station 'Metro Centre (id A01). using REST API from following link.
    http://api.wmata.com/StationPrediction.svc/GetPrediction/A01?api_key=<Public Key> and I am getting information for group 1 and 2.
    But, when I try to varify the XML content with the information displayed on webpage on following URL:
    http://www.wmata.com/rider_tools/pids/showpid.cfm?station_id=1 , I can see some extra destinations in Group 3 and 4 which are not there in the XML of REST API.

    Can anyone help me and guide me about what am doing wrong? and what should I do to get complete information.

    Thanks

  13. Peter Shashkin3 years ago

    perdog -

    1) Unless you need to send a private note, this place would be best because it is monitored by multiple poeple
    2) If you dont see any reports in your interface, you probably dont have this ability. But I can see stats in admin mode.

    Madhvi - I need to check something and will get back to you tomorrow probably

  14. Peter Shashkin3 years ago

    Madhvi, we reveal you more truth than other system, and that introduces some confusion :)
    Metro Center is one station from your standpoint, but two stations from ours, because Metro Center has two codes. each has two groups.
    Rider tools present it as single station with 4 groups, we present it as two stations with 2 groups each.

  15. Haisam3 years ago

    When will buses be included in this API?

  16. Haisam3 years ago

    The API implies that REST by definition returns XML, while this is not the case. There should be a variable, perhaps called, format=xml or format=json which returns the data in the desired format. This would be more consistent than creating a /json/ "path"

  17. Peter Shashkin3 years ago

    Haisam
    1) Buses - we dont have exact date yet. This should be end of October - beg. of November approximately
    2) Terminology and call parameters can coexist without any problems. For example, we can call our JSON calls "type=spaceship", and it would still work :) But seriously, changing anything at this point is not a very good idea anyway since people started using this API. Using /json/ path was more convenient for us, since we were using so many proxies and we did not want to complicate our lives

  18. Haisam3 years ago

    Peter:

    Thank you for your reply and look forward to the bus API. I understand your concern for changing things at this moment.

  19. sahar3 years ago

    I downloaded Metrobus stops data on http://www.wmata.com/rider_tools/license_agreement.cfm. some latitude and longitude of bus stops does not seem accurate. For example, two different bus stops on different side of a road have the same latitude and longitude. Is there any other accurate data available?

    Thank you very much for your help.

  20. Peter Shashkin3 years ago

    Sahar, I recommend not to use that link, since it contains outdated and inaccurate info. We plan to release a bunch of bus services end of October \ beg of November, which will contain very good bus stops info.

  21. sahar3 years ago

    Thank you Peter for your reply.

  22. Tim Schmitz3 years ago

    I've been trying to get in touch with someone about increasing API limits for my upcoming app, but haven't had any luck getting a response from the email address listed in the FAQ. Is there someone else I should contact?

  23. Peter Shashkin3 years ago

    Tim, please send me details to pshashkin at wmata, we will figure that out

  24. sahar3 years ago

    the bus stop data do not have stop numbers which is used for "next bus arrival time". could you please tell me how can I have them?

    Thanks.

  25. Wmata Admin3 years ago

    Bus stop dataset is not released yet, and data model is not finalized. We expect that when its final, the output will have info allowing you to tie it to next bus.

  26. Jerry Lukins2 years ago

    I just registered and got a key and tried to use the call http://api.wmata.com/Rail.svc/Lines?api_key=<Substituted my key here> within internet explorer to see the response and I got an HTTP 403 Forbidden error, Am I missing part of a registration step or something?

  27. Wmata Admin2 years ago

    What is your key? you can email it to pshashkin%wmata:com, I can check

  28. Jeromy French2 years ago

    I have sifted through each of the methods, and the GTFS documentation, but I can't determine how to retrieve fare information (per trip) from the available datasets. I see in the GTFS documentation that this information would be included in the fare_attributes method, which is not (currently?) available from WMATA. Is there another way to determine the price of a trip between points A and B at a specified time/date?

  29. Wmata Admin2 years ago

    In our methods, we don't have any fare information, but we will check if we can make a service.

  30. Jeromy French2 years ago

    Thank you--that might be very helpful particularly to all those companies (and government agencies) that have to verify commuting costs in order to provide metro benefits.

  31. greatrat002 years ago

    Firstly, thanks for opening up the data!

    My question is the following:
    It seems that to get an estimate for how long it will take for the next buses to reach a particular stop two steps are involved:
    1) Look at the next scheduled tripID with the Bus Schedule by Stop method
    2) Look at the deviation parameter of that tripID with the Bus Positions method
    3) Do the math/algorithm ourselves to get the arrival predictions

    Is there any easier way to get it that I'm missing? WMATA already does the prediction computation, testified by the Bus Predictions app on your web page; can you open up a method that shoots that out directly; that is, if it's not being done already and I'm missing it.

    Thanks,
    Adam

  32. Wmata Admin2 years ago

    Adam,

    Everything you say is correct with the exception of this statement "WMATA already does the prediction computation". This is external service called NextBus. They do this calculation, and even the app is hosted by them, not by WMATA.
    At this moment nextbus prediction data is stored externally, and we dont have direct access to it. This is just a beginning, we plan to provide more services in the future, including prediction info from nextbus.

  33. Alex2 years ago

    Is there a way to calculate minutes it might take me to get from one station to another one?

  34. greatrat002 years ago

    Hi Admin,

    Thanks for your prompt reply.

    I want to make sure I got this straight...

    If I do the three steps I described above will I get something close (or same) as the NextBus Predictions? If you already compute the deviations, that implies you have some sort of prediction right? Would your next step be to add the deviation to the scheduled time yourselves and output it?

    Thanks,
    Adam

  35. Threespot2 years ago

    The Bus Positions method is currently returning an empty array, is this service currently down?

    Thanks for making this data available!

  36. Wmata Admin2 years ago

    Threespot - should be fixed now

  37. Threespot2 years ago

    It would be *extremely* beneficial if this method accepted lat, lon, and radius parameters - just as the bus stops method supports - would it be possible to add that capability?

    Without being able to filter with those kinds of parameters, if one wanted to update current bus positions as-close-to-realtime as possible, they'd potentially be making repeated calls to this method which, without specifying a routeID, can return up to 600 some records.

    Thanks!

  38. Threespot2 years ago

    (oops, I was referring to Method 13 - Bus Positions in my post)

  39. Wmata Admin2 years ago

    Threespot: You got it now (Check Docs).

  40. Threespot2 years ago

    @Wmata Admin: thanks so much!!

  41. Tom2 years ago

    I would be interested in discussing WMATA's data project in detail to see if Arlington Transit could release the same data. Whom do I contact outside of this forum? Thanks.

  42. Wmata Admin2 years ago

    Tom, you can check with Bill Rigney:
    wrigney at [our domain]

  43. indhiran2 years ago

    Any idea why the Calendar.txt file is not included in your latest GTFS zip file?

  44. Wmata Admin2 years ago

    indhiran - currently GTFS provides very limited set of data and it is going to be redone completely. No ETA as of today.
    Calendar.txt will be present in new version

  45. jonny.sizlak2 years ago

    Is there any other way to contact the admins other than comments? My API key hasn't been activated, and it's been two weeks. :(

  46. Wmata Admin2 years ago

    jonny.sizlak -> you can try now. If you encounetr problem you can contact "pshashkin" - wmata.com.

  47. indhiran2 years ago

    Any possibility of matching the TRIPID from the Bus Positions RSS feed to the trips.txt file in the GTFS zip File? A typical TRIPID in the RSS feed would be "10326_11", while tripIDs in your GTFS files are of the format "1013". If I cannot use the TripIDs to match the data between the two feeds, is there an alternate option?

  48. woohoo76762 years ago

    Hi, we recently published a metro app called DCMetro, however today calls appear to be returning "<h1>Unable to connect</h1>"

    Is this a consequence of hitting the rate limit? If so, could we apply for a higher rate limit? (already emailed pshashkin at wmata.com, if that is the correct address for this request)

    Thanks!

  49. daniel2 years ago

    Hi all, i would like to report a small error in the StationPrediction feed:

    for destinationname=destination='Twinbrk' (Twinbrook station), the DestinationCode is empty. It should be most probably 'A13'.

    By the way, thanks for a great API!

  50. Jason_McKee2 years ago

    Can anyone help... having trouble. Always getting a 403 back, with the X-Mashery-Error-Code: ERR_403_DEVELOPER_INACTIVE

    Any help would be appreciated...

  51. vasedelen2 years ago

    Are we able to access neighboring transit data (Arlington, MTA, Fairfax, etc...) or are we only able to access WMATA data?

    Thank you for your help.

    V,

  52. vasedelen2 years ago

    A follow up to my first question. I would like to know if WMATAs API, means i would be able to access data from neighboring transit agencies like Arlington, MTA, Fairfax, etc...

    or...

    am i only able to access neighboring transit agencies through Google Transit feeds? GTFS?

    your help is greatly appreciated.

    Thank you.

    V.

  53. Wmata Admin2 years ago

    Sorry for late update - we had problems with notifications. From now on, if you have general inquiry, you can use this form http://developer.wmata.com/contact

    indhiran - (adding more data to GTFS) - unfortunately GTFS is out of the scope for this initiative. We're covering Web Services only. I know there is a parallel effort on GTFS in WMATA, but I cannot speak for other team.

    woohoo7676 - (unable to connect) - do you still have this problem? You can use contact form and we can check from there. No, this is not related to overlimit

    daniel - (empty destination) - thanks for the input - will check!

    Jason_McKee - please let me know if you still have this problem

    vasedelen - most likely, we're going to expose WMATA info only. You may want to check commuterapi.com. They get our feed + they may have other agencies data. And they also have (free?) API

  54. salmansqadeer2 years ago

    Same problem as Jason - constantly getting a 403 error.

    Mailed you guys and sent my details through the contact form - hope to hear from you soon - This was working fine till last night so this is a major kink in my development process!

  55. noahplusplus1 year ago

    Hi there. Any progress on getting fare information into the API? If not, I would be delighted if you provided us with something like a CSV-formatted fare chart. (It's not as if fares change so frequently that we need that data in realtime anyway!)

  56. Enrique Lara1 year ago

    The comments above mention GTFS: On the odd chance you or the other team were not aware of the GTFS-realtime effort, please consider browsing this group:

    https://developers.google.com/transit/

  57. Tim Schmitz1 year ago

    I'm having the problem with static data as well. For example, this URL continuously returns the same data:

    http://api.wmata.com/StationPrediction.svc/json/GetPrediction/A10?api_key=API_KEY

    Has anyone successfully gotten a response on this? Any advice?

    Tim Schmitz tschmitz <at> gmail.com @timschmitz

  58. RideSchedules9 months ago

    I have never gotten a valid response for a prediction request using the StopID and api_key format.

    I have investigated the stop_id to ensure it is correct and then compared responses with the website and confirmed feed api is not returning the same result.

    It does seem the problem is being addressed. The response has always been stop is nil. Now it is returning an empty bus positions tag.

    Hopefully it will be fixed soon?

  59. Mayank Mehta9 months ago

    Can anyone please advice how to get fares from point A to point B?

    I don't see any above API calls doing so and neither found it in GTFS download.

  60. command_z8 months ago

    Can anyone recommend a good tutorial on how to use an API like this one? I've successfully received train data using the JSON url with my key. I want to know how to inject that data into my html. Could someone point me in the right direction? Thanks!

  61. manohar6 months ago

    Hi, is there any web service for trip planner other than the feed. Like where we send date, time, source and destination stations and returns itinerary with line, route, time and fare?

  62. Ian Dixon6 months ago

    Hi. I'm getting repeated email alerts that my API key is exceeding API limits. Who can I work with to increase limits, and ensure continuation of access.

    Thanks!

  63. Ian Dixon5 months ago

    My app is getting shut down from API service virtually ever day now due to ERR_403_DEVELOPER_OVER_RATE errors, which is really hurting ratings, retention, etc. Is anyone available at WMATA to address requests for increased quota? I'm having no luck emailing the listed POCs.

Please sign in to post a comment.