List of routes

105 views
Skip to first unread message

mounika mamindla

unread,
Mar 29, 2021, 10:23:14 AMMar 29
to MBTA Developers
Hello,
I am trying to access the list of routes from https://api-v3.mbta.com. I am not able to access the MBTA API using python code. Please suggest to me a code snippet on how to access MBTA API in my program so that I will be able to perform collecting the list of routes that service only light and heavy rail trains and also stops within that route. Thank you for your help in advance.

Developer

unread,
Apr 1, 2021, 9:10:10 AMApr 1
to massdotd...@googlegroups.com

Hi,


Please visit our documentation to see the available endpoints and filters available. To request the routes for light and heavy rail, you could use:


https://api-v3.mbta.com/routes?filter[type]=0,1


To request stops for a given list of routes, you could obtain the routes from the above request and use:


https://api-v3.mbta.com/stops?filter[route]=Red,Orange,Blue,...


For making requests in python, I recommend the requests library. The code to fetch the data from the above URLs would be something like:


import requests


resp = requests.get("https://api-v3.mbta.com/....")

resp.json()


If you're going to be making frequent requests, please register with us to obtain an API key, which will increase your rate limit. You could then pass your API key like follows in the request:


requests.get("https://api-v3.mbta.com/...", headers={"x-api-key": "12345"})


-- Deveoper@MBTA 





From: massdotd...@googlegroups.com <massdotd...@googlegroups.com> on behalf of mounika mamindla <mamindla.m...@gmail.com>
Sent: Wednesday, March 24, 2021 5:49 PM
To: MBTA Developers
Subject: [massdotdev] List of routes
 
Hello,
I am trying to access the list of routes from https://api-v3.mbta.com. I am not able to access the MBTA API using python code. Please suggest to me a code snippet on how to access MBTA API in my program so that I will be able to perform collecting the list of routes that service only light and heavy rail trains and also stops within that route. Thank you for your help in advance.

--
You received this message because you are subscribed to the Google Groups "MBTA Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to massdotdevelop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/massdotdevelopers/376c2091-7b8a-4d6b-a048-abe3c8d50456n%40googlegroups.com.
CAUTION: This email originated from outside of the MBTA organization. Do not click links, open attachments, or respond unless you recognize the sender and know the content is safe.



This email/electronic message, including any attached files, is being sent by the MBTA. It is solely intended for the recipient(s) and may contain information that is proprietary, confidential, legally privileged, and/or exempt from disclosure pursuant to state and federal law. If you have received this message in error or are not the intended recipient(s), please notify the sender immediately by reply, and delete all copies of this email/electronic message and any attached files from your computer. If you are the intended recipient(s), you may use the information contained in this email/electronic message and any attached files only as authorized by the MBTA. Any unauthorized use, dissemination, or disclosure of this email/electronic message and/or its attached files is strictly prohibited.
Reply all
Reply to author
Forward
0 new messages