# Get realtime data

**URL:** <https://opendataforum.transport.nsw.gov.au/t/get-realtime-data/962>\
**Category:** Real-time Public Transport\
**Created:** [July 17, 2017, 5:51am UTC](https://opendataforum.transport.nsw.gov.au/t/get-realtime-data/962 "2017-07-17T05:51:16Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhamu143](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dhamu143](https://opendataforum.transport.nsw.gov.au/u/dhamu143)\
**Post date:** [July 17, 2017, 5:51am UTC](https://opendataforum.transport.nsw.gov.au/t/get-realtime-data/962/1 "2017-07-17T05:51:16Z")

</div>

hello, everyone,  
I need to implement something like [AnyTrip](https://anytrip.com.au/map) real-time

I have only RealtimeTripId.

can anyone help me that which API will give me this kind of result?

I need to track particular single vehicle(bus, train) of NSW.

---

<div class="post-metadata">

**Author:** ![alejandro.felman](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@alejandro.felman](https://opendataforum.transport.nsw.gov.au/u/alejandro.felman)\
**Post date:** [July 17, 2017, 6:19am UTC](https://opendataforum.transport.nsw.gov.au/t/get-realtime-data/962/2 "2017-07-17T06:19:26Z")

</div>

Hi @dhamu143, AnyTrip was created by one of our users @jxeeno who posts here regularly. The following thread might be of use to you: [TfNSW real-time map](https://opendataforum.transport.nsw.gov.au/t/tfnsw-real-time-map/84)

Unfortunately we only provide open data as is and don’t offer detailed instructions on how to build complex apps. That’s for you guys to work out. From reading the thread linked above you can get a good idea of how our data was used to build something like AnyTrip.

Short answer is that you will need to use a mix of various datasets, parse the data you need and build a frontend to display that how you want.

Thanks,  
Alex

---

<div class="post-metadata">

**Author:** ![dhamu143](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dhamu143](https://opendataforum.transport.nsw.gov.au/u/dhamu143)\
**Post date:** [July 17, 2017, 7:05am UTC](https://opendataforum.transport.nsw.gov.au/t/get-realtime-data/962/3 "2017-07-17T07:05:42Z")

</div>

which API have they accessed?  
even the vehicle position api is not giving the perfect data

> [@Vehicle position api returns currupted data](https://opendataforum.transport.nsw.gov.au/t/vehicle-position-api-returns-currupted-data/963):
>
> i am accessing vehicle position api and it returns me data something like this �q�66C��=C-���\>(����B 1006 Borrowdalef $52583ecc-f2c4-4e48-9ab9-9b4c3ce0f992"\> �q�66C��=C-���\>(����B 1006 please help me

---

<div class="post-metadata">

**Author:** ![alejandro.felman](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@alejandro.felman](https://opendataforum.transport.nsw.gov.au/u/alejandro.felman)\
**Post date:** [July 17, 2017, 7:08am UTC](https://opendataforum.transport.nsw.gov.au/t/get-realtime-data/962/4 "2017-07-17T07:08:49Z")

</div>

Hi @dhamu143, I strongly recommend you read all our documentation. For those APIs you will need to use a proto file to decode the data it returns into a readable format. See:

> **[Documentation | TfNSW Open Data Hub and Developer Portal](https://opendata.transport.nsw.gov.au/documentation)**
>
> Transport for NSW's Open Data Portal

> **[Troubleshooting | TfNSW Open Data Hub and Developer Portal](https://opendata.transport.nsw.gov.au/troubleshooting)**
>
> Transport for NSW's Open Data Portal

> **[Developer Information | TfNSW Open Data Hub and Developer Portal](https://opendata.transport.nsw.gov.au/developer-information)**
>
> Transport for NSW's Open Data Portal

Thanks,  
Alex

---

<div class="post-metadata">

**Author:** ![alejandro.felman](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@alejandro.felman](https://opendataforum.transport.nsw.gov.au/u/alejandro.felman)\
**Post date:** [July 18, 2017, 1:24am UTC](https://opendataforum.transport.nsw.gov.au/t/get-realtime-data/962/5 "2017-07-18T01:24:29Z")

</div>

Hi @dhamu143, some more resources that will help you with what you’re trying to do:

- [Jupyter Notebook Viewer](http://nbviewer.jupyter.org/urls/gist.githubusercontent.com/timbennett/7ec739fc619459316859d3875b76a76b/raw/be8cfe689ea662a69de8b62b99a9b8a62b1df21f/notebook.ipynb)
- [New to APIs](https://opendataforum.transport.nsw.gov.au/t/new-to-apis/63)

Thanks,  
Alex

---

<div class="post-metadata">

**Author:** ![dhamu143](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dhamu143](https://opendataforum.transport.nsw.gov.au/u/dhamu143)\
**Post date:** [July 18, 2017, 7:07am UTC](https://opendataforum.transport.nsw.gov.au/t/get-realtime-data/962/6 "2017-07-18T07:07:50Z")

</div>

but this API is giving all result.all data is missing in vehicle position.  
at last it is giving us like this

`````nohighlight
  ````id: "10"
 `` vehicle {
    trip {
      trip_id:

it's written like this on API 

Known issues:
•The text format may be truncated.
`````

---

<div class="post-metadata">

**Author:** ![yvonne.lee](https://avatars.discourse-cdn.com/v4/letter/y/c37758/32.png) [@yvonne.lee](https://opendataforum.transport.nsw.gov.au/u/yvonne.lee)\
**Post date:** [July 18, 2017, 7:21am UTC](https://opendataforum.transport.nsw.gov.au/t/get-realtime-data/962/7 "2017-07-18T07:21:40Z")

</div>

Hey @dhamu143

Just seeing this thread – unfortunately we only provide support for our data. We are not app developers or data scientists and can only help so much. Please review the available resources that Alex and others have provided.

We also would like you to respect the other forum member’s time and availability.

Whilst we encourage your learning and development unfortunately this is not the right forum for that type of detailed discussion. Stackoverflow may be better for this [Human verification - Stack Overflow](https://stackoverflow.com/search?q=gtfs-r)

You mention you are trying to implement something like AnyTrip. AnyTrip is an endorsed app for Transport for NSW. It is not an app that can be built overnight or quickly or easily. If you want AnyTrip developed for your needs we can introduce you to facilitate a commercial discussion with the developer.

Thank you.

Kind regards  
Yvonne

---

<div class="post-metadata">

**Author:** ![dhamu143](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dhamu143](https://opendataforum.transport.nsw.gov.au/u/dhamu143)\
**Post date:** [July 18, 2017, 7:24am UTC](https://opendataforum.transport.nsw.gov.au/t/get-realtime-data/962/8 "2017-07-18T07:24:25Z")

</div>

> [@dhamu143](#):
>
> Known issues:  
> •The text format may be truncated.

ok, that’s good. but what about this

Known issues:  
•The text format may be truncated.

??

---

<div class="post-metadata">

**Author:** ![phiali](https://sea1.discourse-cdn.com/flex019/user_avatar/opendataforum.transport.nsw.gov.au/phiali/32/221_2.png) [@phiali](https://opendataforum.transport.nsw.gov.au/u/phiali)\
**Post date:** [July 18, 2017, 9:56pm UTC](https://opendataforum.transport.nsw.gov.au/t/get-realtime-data/962/9 "2017-07-18T21:56:35Z")

</div>

The realtime feed is provided using Protocol Buffers, see [Protocol Buffers &nbsp;|&nbsp; Google Developers](https://developers.google.com/protocol-buffers/) for more information. This is a binary feed which explains the odd characters and formatting you were seeing.

The text version, formatted as JSON, is simply there for debug purposes and will be truncated. In order to access all of the realtime feed data you’ll need to look into Protocol Buffers. Think of the debug version as just a glimpse at the data to give you an idea of what it holds.

---

<div class="post-metadata">

**Author:** ![dhamu143](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dhamu143](https://opendataforum.transport.nsw.gov.au/u/dhamu143)\
**Post date:** [July 27, 2017, 5:08am UTC](https://opendataforum.transport.nsw.gov.au/t/get-realtime-data/962/10 "2017-07-27T05:08:17Z")

</div>

I have been stuck on this issue. I need to track all the vehicle and vehicle API returns incomplete data.please help me.I need all data.

---

<div class="post-metadata">

**Author:** ![phiali](https://sea1.discourse-cdn.com/flex019/user_avatar/opendataforum.transport.nsw.gov.au/phiali/32/221_2.png) [@phiali](https://opendataforum.transport.nsw.gov.au/u/phiali)\
**Post date:** [July 27, 2017, 5:43am UTC](https://opendataforum.transport.nsw.gov.au/t/get-realtime-data/962/11 "2017-07-27T05:43:34Z")

</div>

It doesn’t returned truncated data when accessed via Protocol Buffers. It’s just the JSON **debug** representation that is truncated and that is expected and normal behaviour.

I’d really suggest you purchase the GTFS and GTFS Realtime books from [GTFS + GTFS-realtime Book Bundle](https://gumroad.com/l/gtfsbundle). It’ll serve as a good introduction to GTFS and the realtime components along with code samples for consuming services.

---

<div class="post-metadata">

**Author:** ![dhamu143](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dhamu143](https://opendataforum.transport.nsw.gov.au/u/dhamu143)\
**Post date:** [July 27, 2017, 5:45am UTC](https://opendataforum.transport.nsw.gov.au/t/get-realtime-data/962/12 "2017-07-27T05:45:50Z")

</div>

> [@alejandro.felman](#):
>
> Short

but by using mode: ‘direct’ in request its gives us direct data no need to direct conversion of some GTFS to normal JSON.

---

<div class="post-metadata">

**Author:** ![jayen](https://sea1.discourse-cdn.com/flex019/user_avatar/opendataforum.transport.nsw.gov.au/jayen/32/208_2.png) [@jayen](https://opendataforum.transport.nsw.gov.au/u/jayen)\
**Post date:** [August 26, 2017, 11:04am UTC](https://opendataforum.transport.nsw.gov.au/t/get-realtime-data/962/13 "2017-08-26T11:04:57Z")

</div>

it looks like in an earlier post you were downloading the data fine, but for some reason you thought it was corrupt. it was not corrupt, but in a binary format that you need. these libraries will help you somewhat: [GitHub - MobilityData/gtfs-realtime-bindings: Language bindings generated from the GTFS Realtime protocol buffer spec for popular languages.](https://github.com/google/gtfs-realtime-bindings) but in some cases tfnsw’s format is non-standard in which case you’ll have to read the links posted earlier to figure it out.

the text format (not JSON!!! @phiali) you got by enabling `debug=true` is truncated for most modes, but you shouldn’t use this anyway as you will use terabytes of internet bandwidth for nothing. this option is ONLY for debugging.

alternatively you can try asking the anytrip developer for a widget that does what you need.
