New to APIs

hello everyone i am new here and i don’t know to access this api and i am not aware about the structure of data.?
what type of request i need to send to get the bus detail ? I have my own api key and secret key

please help me

Thank you :slight_smile:

Here is a mini guide to getting started

  1. go to and follow https://opendata.transport.nsw.gov.au/site/en_us/gs-intro.html
    That will get you up and running with access to the API, run through the API Explorer and get you understanding what to do next.
  2. Look @ https://opendata.transport.nsw.gov.au/site/en_us/gs-api-basics.html to get an understanding of API
  3. More details about the protocols at https://opendata.transport.nsw.gov.au/site/en_us/documentation.html

Next choose a language, implement OAuth and utilise the helper tools to decode the content being returned from the API. There are plenty of examples out there of how to do all of this, but I don’t have pointers for all the languages etc.

For example I am using Node and I am using the following projects.

  1. OAuth - GitHub - lelylan/simple-oauth2: A simple Node.js client library for Oauth2
  2. GTFS Realtime Binding - GitHub - MobilityData/gtfs-realtime-bindings: Language bindings generated from the GTFS Realtime protocol buffer spec for popular languages.

My example I am using is https://drive.google.com/open?id=0B9D-FwzEA1yYMG1pcDJIekIzZm8
It not create and not intended for production use as

  1. It does not cache the OAuth Bearer Token
  2. It does not cache the response from the API Call

but it is enough to show you the basics of how to get a token and use it to make a request to the API.

1 Like

I wrote a slightly longer guide covering (in Python):

  • Setting up your account
  • Creating an application
  • Pulling down the realtime bus positions
  • Parsing the binary data
  • Plotting it on a map

Here it is: Jupyter Notebook Viewer

Comments appreciated.

5 Likes

This is great - nice work.

Since you’re outputting as HTML, and have gone to the trouble of using GeoJSON, you can use an interactive Google Map with the data layer. A little nicer than a flat image :slight_smile:

hello Nirving ,

first of all thank you so much for this information. all this information to access API is for python language i am using php . so is it possible to use this php? how can i access this api by postman to handled response type that is not in postman

It’s conceptually the same. I’ll write a short PHP tutorial shortly :slight_smile:

i am waiting for it. thank you so much for your reply :slight_smile:

hello Nirving
The example that you gave me is perfectly working Thank You for that but it gives me real time alerts

how can i get time table of all stations ? and if i need to filter that data than how can I ?

hoping helpful reply :slight_smile:

hello sir have you found any solution for it ?

Well, I’m stuck.
In the API explorer, I’m trying to figure out how to properly authenticate. I’ve tried following the provided guides, to no avail. The errors sometimes vary, but this is what I’m hitting most of the time.

API is “Public Transport - Timetables - Complete - GTFS”
Authentication type is “OAuth 2”
Grant type is “Client Credentials”
Scope is “user”
Token Endpoint is “https://api.transport.nsw.gov.au/auth/oauth/v2/token

I’m new to working with API’s, altering headers is about as advanced as I can get. Any help would be greatly appreciated.

Have you created your API/API Key in your application that uses Complete GTFS ?

hello nirving
how can i filter that response, because it gives me whole data of vehicle position ? so if i want to get some particular data then how should i need to mention in my request and how ?
just show me in your example
https://drive.google.com/file/d/0B9D-FwzEA1yYMG1pcDJIekIzZm8/view

Yes, I have created an API key.
Sorry for the slow response by the way.