Detta inlägg är gammalt och kan innehålla inaktuell information.

Deviation on but not in API

On I can see the upcoming event "Pendeltåg linje 35, 36 och 38
Inställd trafik mellan Stockholm C och Älvsjö under påskhelgen
Gäller från: 2017-04-13, 22:25"

But somehow this is not returned by 
Why is that? Is there some default date range filter applied when I don't set the fromDate and toDate params? Because this is not documented. Or is this just a temporary glitch?


  • Hi Matthias,
    If you don't define FromDate/ToDate parameters you get the deviations valid at the time of the request. The "missing" deviation was valid from some days after your question according to the quote above, which is why it wasn't returned.

    This information will be added to the documentation.

  • Can you give me an example on how to set the from and to query parameters? Because I can't seem to get the date format right...
  • Hi Matthias,

    As Sabina has pointed out, omitted ‘fromdate’ and ‘todate’ parameters will result in deviations valid at the time of the request.

    In order to get valid deviations for any given day your API call should look like this:[your_api_key]&fromdate=2017-04-13&toDate=2017-04-13

    The date format is 'yyyy-MM-dd'.
    You are not allowed to specify more than ONE day in the range, because of the current API restrictions.
  • So that means that if I want to find planned events for let's say the coming 5 days, I would have to query the API 5 times for tomorrow, the day after tomorrow and so on?

    And I do have a related question: The deviationsraw endpoint does not support the filtering for dates right? Does this one also just return currently active deviations? or is there a way to get the coming deviation from that endpoint too?

    Thank you for your patience and help!

Kommentera eller skriv ett nytt inlägg

Ditt namn och inlägg kan ses av alla. Din e-post visas aldrig publikt.