-
Notifications
You must be signed in to change notification settings - Fork 2
Update to use new API #12
Comments
Note for people stumbling over this via Google: The endpoint seems to check the user agent and restricts access for eg. using request's default one. station = 2 # Marienplatz
url = f'https://www.mvg.de/fahrinfo/api/departure/{station}?footway=0'
headers = {'X-MVG-Authorization-Key': '5af1beca494712ed38d313714d4caff6', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36'}
requests.get(url, headers=headers).json() |
Hi, i try to use your sample but did not work... do you have any idea why, is there any change in the MVG API? Br, |
That is quite possible - they love to change things around... A quick check on their website reveals, that there have apparently been some changes... For example, the call for Marienplatz is now The Search-Endpoint ( Furthermore, the API-token seems to be now Someone[TM] should really update this library to use the new endpoints and data ;-) |
Thanks, i did nearly the same and check with chrome developer tools and now your code works with the new station ID´s :-) THanks! |
The api token was not required in my case |
MVG has launched a new API while keeping the old one online.
Unfortunately, it seems like the data served by the old (currently used) API is staring to degrade. For example, queries for Garching-Hochbrück only return U-Bahn-trains but not any busses.
The new API lives at
https://www.mvg.de/fahrinfo/api/departure/480?footway=0
, wherefootway
takes the currenttimeoffset
parameter and480
is the ID of the station (in this example: Garching-Hochbrück).Querying for station-data can be done at
https://www.mvg.de/fahrinfo/api/location/queryWeb?q=garching
, with theq
-parameter obviously being the search-string.Queries need to be authorized by providing the
"X-MVG-Authorization-Key
-header. One possible value is for example5af1beca494712ed38d313714d4caff6
(mvg.de website-key).The new API is a lot more usable as it does not need any of that RPC-decryption that is currently used.
If anyone feels like implementing the new API - possibly while keeping compatibility to the current Syntax: please do so :-)
The text was updated successfully, but these errors were encountered: