How to modify the json sample script to download mutiple a list of journeys from multiple pairs of origins and destinations


#1

Hi guys,
I want to download lists of journeys from multiple pairs of origins and destinations from category Trip Planner APIs.
I have a text file of two columns Origins and Destinations.
Is there any way to download multiple journeys from many O-D or how to modify script to download at one go?
Thanks in advance.


#2

Hi Lho,
No, you need to call each pair individually.

I would suggest you write a piece of code to loop through your text file and then parse the output.


#3

Hi Patrick,
Thank you for replying me. I appreciate it.
I had the same idea with you, but I don’t know how to modify the script to do the loop.
Do you have any sample script or any suggestion? I am a beginner for json scripting.

Thank you so much in advance!


#4

Hi Lho,
We don’t do premium support here at Transport but I can offer a little advice.

JSON isn’t a scripting language it’s a method to exchange data. You need to pick a language and make the API call from within whatever script you write. There are heaps of resources online so it should be pretty easy to teach yourself if you have programming experience.


#5

Thanks Patrick for your advice.

I have seen several topics about what to do to edit script and exploring other topics giving instructions.
If possible, can you please tell me how to get the Shared Secret id as I followed user guide and seen the topic Using the API Explorer by @yvonne.lee, but I couldn’t find the Shared Secret id from my application.

I’ve read “API Key and Shared secret are prepopulated for you” from steps:

But can you do the following

  1. sign in
  2. create an app
  3. add the APIs you need for that app
  4. go to API Explorer
  5. choose the API and App/API Key
  6. Choose OAuth2 as the auth type
  7. Choose Client Credentials
  8. API Key and Shared secret are prepopulated for you
  9. Type in “user” to the Scope
  10. add in the Token Endpoint (use this one https://api.transport.nsw.gov.au/auth/oauth/v2/token8 if you don’t have one)
  11. Choose the API endpoint
  12. Click on Submit
  13. Grab the curl command and run it

I couldn’t find it anywhere.
Thank you.


#6

Those are very old instructions, we made some changes a while back and now you only need the API key.

The instructions on how to create an application and obtain a API key is on our hub here:
https://opendata.transport.nsw.gov.au/user-guide

There is other useful documentation here:
https://opendata.transport.nsw.gov.au/documentation