New to APIs


#1

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:


Get realtime data
#2

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 - https://github.com/lelylan/simple-oauth2
  2. GTFS Realtime Binding - https://github.com/google/gtfs-realtime-bindings

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.


#3

#4

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: http://nbviewer.jupyter.org/urls/gist.githubusercontent.com/timbennett/7ec739fc619459316859d3875b76a76b/raw/be8cfe689ea662a69de8b62b99a9b8a62b1df21f/notebook.ipynb

Comments appreciated.


#5

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:


#7

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


#8

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


#9

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


#10

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:


#11

hello sir have you found any solution for it ?


#12

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.


#13

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


#14

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


#15

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