Trip Planner API - need help

Hello,

I’m using the API explorer on the site but for some reason, whenever I click ‘Try it out’ it doesn’t work for me - I keep getting 401, ‘The calling application is unauthenticated’. I have selected my application and it’s enabled and the API key is appearing. When I go to other APIs it works, but only Trip Planner API is giving me troubles.

EDIT: I also have another question – I’m planning to create a web app (mainly frontend) using the APIs available, is this possible without a server? I say this because I haven’t been able to make a simple API request work with just XMLHttpRequest() because the API doesn’t accept ‘Allow-Control-Access-Origin’.

Any help would be greatly appreciated.

Many thanks,
Joseph

Hi Joseph,

Looks like the API explorer (Swagger) for the Trip Planner API is pointed at the wrong API server. We’ll need someone from the Open Data team to fix it up.

In the meantime, you can still make requests directly to the API endpoint (not using the API explorer) if you remove “np” from the domain name (i.e. https://api.transport.nsw.gov.au not https://api.np.transport.nsw.gov.au).

Re CORS, it’s not currently supported by the API – you’ll need to set up some form of intermediary proxy. Also, it might not be a good idea to expose your API key publicly.

Ken

2 Likes

Thanks Ken. I think this is now fixed (re the pointing to the wrong server).

2 Likes

Thanks for the help jxeeno and yvonne :slight_smile:

setting up to communicate with this API is rather difficult :frowning:

are there any other custom headers besides “Authorization” that I should be aware of?

Authorization should be sufficient… If you’re having 401 errors, make sure you have it in the format:

Authorization: apikey <API Key>

finally got it to work, I was missing ‘apikey’ before the actual API Key :man_facepalming:

Thanks heaps !

3 Likes