Cross-origin support server side for OC Transpo data

110 views
Skip to first unread message

Frederic LeBel

unread,
May 25, 2017, 9:13:50 PM5/25/17
to Open Data Ottawa
I'm trying to call the OC Transpo REST API from a simple html/javascript page.  The server https://api.octranspo1.com doesn't set the Access-Control-Allow-Origin response header and doesn't support JSONP format.  This makes this API unusable from inside a browser.

Are there plans to add either the header to allow cross origin requests or support for JSONP?

Thanks

oheu...@gmail.com

unread,
Jul 10, 2018, 10:47:39 AM7/10/18
to Open Data Ottawa
Were there any updates to this issue?
I tried to use the realtime api and ran into the same problem - a browser based client seems to be a fairly common usage model but this isn't possible without the CORS header.

Thanks

Cyrus

unread,
Jul 10, 2018, 8:46:40 PM7/10/18
to Open Data Ottawa
The API hasn’t been updated in years.

But, in the documentation, they ask that you preload it on a server to prevent overload or attacks on the API. As it currently, responds very slow (3seconds right now)

oheu...@gmail.com

unread,
Jul 11, 2018, 10:30:11 AM7/11/18
to Open Data Ottawa
Fro what it' worth: my application is showing departure times and I can preload the data. However, I'd have to get all the routes for all stops in one command and I don't see an option for this either.

Benjm

unread,
Jan 13, 2022, 1:08:39 PM1/13/22
to Open Data Ottawa
I had that issue so I am running a server on cloudfare workers that is acting like a proxy. My app sends a GET request and the worker sends back the result from OC transpo with No API keys in the url & And it sends it back with the correct CORS header (strict-origin-when-cross-origin) The free teir is close (If not the same) as OC's API restrictions (ex: Daily call limit). 
Reply all
Reply to author
Forward
0 new messages