# Traffic Volume Counts API

**URL:** <https://opendataforum.transport.nsw.gov.au/t/traffic-volume-counts-api/2248>\
**Category:** Request for data\
**Created:** [February 1, 2021, 2:35am UTC](https://opendataforum.transport.nsw.gov.au/t/traffic-volume-counts-api/2248 "2021-02-01T02:35:01Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![hyeuk](https://avatars.discourse-cdn.com/v4/letter/h/ea666f/32.png) [@hyeuk](https://opendataforum.transport.nsw.gov.au/u/hyeuk)\
**Post date:** [February 1, 2021, 2:35am UTC](https://opendataforum.transport.nsw.gov.au/t/traffic-volume-counts-api/2248/1 "2021-02-01T02:35:01Z")

</div>

Hi,

I tried two examples in the Traffic Volume Counts API, but neither of them worked.  
SELECT FROM road\_traffic\_counts\_station\_reference ORDER BY station\_id LIMIT 50  
SELECT FROM road\_traffic\_counts\_hourly\_permanent LIMIT 10

#### Request URL

```auto
https://api.transport.nsw.gov.au/v1/roads/spatial?format=geojson&q=SELECT%20FROM%20road_traffic_counts_station_reference%20ORDER%20BY%20station_id%20LIMIT%2050

```

#### Response Body

```auto
{
  "ErrorDetails": {
    "TransactionId": "000001747c7415a0-28295b87",
    "ErrorDateTime": "2021-02-01T20:15:34.449+11:00",
    "Message": "Error in the request Data",
    "RequestedUrl": "/v1/roads/spatial",
    "RequestedMethod": "GET"
  }
}

```

Could you let me know how to fix?

Regards,

---

<div class="post-metadata">

**Author:** ![terencekhoo](https://avatars.discourse-cdn.com/v4/letter/t/3ec8ea/32.png) [@terencekhoo](https://opendataforum.transport.nsw.gov.au/u/terencekhoo)\
**Post date:** [February 1, 2021, 10:31pm UTC](https://opendataforum.transport.nsw.gov.au/t/traffic-volume-counts-api/2248/2 "2021-02-01T22:31:38Z")

</div>

Hi hyeuk,

please use the following.  
SELECT \* FROM road\_traffic\_counts\_station\_reference ORDER BY station\_id LIMIT 50  
SELECT \* FROM road\_traffic\_counts\_hourly\_permanent LIMIT 10

#### Request URL

[https://api.transport.nsw.gov.au/v1/roads/spatial?format=geojson&q=SELECT%20\*%20FROM%20road\_traffic\_counts\_station\_reference%20ORDER%20BY%20station\_id%20LIMIT%2050](https://api.transport.nsw.gov.au/v1/roads/spatial?format=geojson&q=SELECT%20*%20FROM%20road_traffic_counts_station_reference%20ORDER%20BY%20station_id%20LIMIT%2050)

---

<div class="post-metadata">

**Author:** ![hyeuk](https://avatars.discourse-cdn.com/v4/letter/h/ea666f/32.png) [@hyeuk](https://opendataforum.transport.nsw.gov.au/u/hyeuk)\
**Post date:** [February 1, 2021, 10:39pm UTC](https://opendataforum.transport.nsw.gov.au/t/traffic-volume-counts-api/2248/3 "2021-02-01T22:39:56Z")

</div>

Hi,

Thank you so much. Do you know how to correct errors in the examples in the manual ([User account | TfNSW Open Data Hub and Developer Portal](https://opendata.transport.nsw.gov.au/dataset/nsw-roads-traffic-volume-counts-api/resource/13d061b1-1606-49b5-b182-d36ce0801f14))?

Regards,

---

<div class="post-metadata">

**Author:** ![terencekhoo](https://avatars.discourse-cdn.com/v4/letter/t/3ec8ea/32.png) [@terencekhoo](https://opendataforum.transport.nsw.gov.au/u/terencekhoo)\
**Post date:** [February 1, 2021, 11:38pm UTC](https://opendataforum.transport.nsw.gov.au/t/traffic-volume-counts-api/2248/4 "2021-02-01T23:38:57Z")

</div>

Hi,

May I know which errors in the examples do you wish to correct?

---

<div class="post-metadata">

**Author:** ![hyeuk](https://avatars.discourse-cdn.com/v4/letter/h/ea666f/32.png) [@hyeuk](https://opendataforum.transport.nsw.gov.au/u/hyeuk)\
**Post date:** [February 2, 2021, 12:27am UTC](https://opendataforum.transport.nsw.gov.au/t/traffic-volume-counts-api/2248/5 "2021-02-02T00:27:24Z")

</div>

Hi,

Basically what I did was to copy the query text from the manual and to paste into q value in the API web page.

### Example 1:

I made the query simpler, but it did not work.

```auto
SELECT * FROM road_traffic_counts_hourly_permanent LEFT JOIN road_traffic_counts_station_reference ON road_traffic_counts_station_reference.station_key = road_traffic_counts_hourly_permanent.station_key WHERE station_id='SHB' AND year = '2016' AND public_holiday is true AND day_of_week BETWEEN 1 AND 5 AND classification_seq = 2 and month in (1,2,3) AND cardinal_direction_seq = 5 ORDER BY date

```

### Example 2:

It ran but the result is empty.

```auto
SELECT * FROM road_traffic_counts_station_reference WHERE ST_DWithin(the_geom, ST_MakePoint(150.999919,-33.816228)::geography,10000)

```

### Example 3.

I made the query simpler, but it did not work.

```auto
SELECT * FROM road_traffic_counts_station_reference REF JOIN road_traffic_counts_yearly_summary SUMM ON REF.STATION_KEY = SUMM.STATION_KEY WHERE SUBURB = 'Parramatta' AND PERIOD = 'PM PEAK' AND TRAFFIC_DIRECTION_SEQ IN ('1','2')

```

### Example 4

I made the query simpler, but it did not work.

```auto
SELECT * FROM (SELECT PERM.DATE, REF.STATION_ID, PERM.TRAFFIC_DIRECTION_SEQ,(HOUR_07%2bHOUR_08) AS AM_VOL
FROM road_traffic_counts_station_reference REF JOIN road_traffic_counts_hourly_permanent PERM ON PERM.STATION_KEY = REF.STATION_KEY
WHERE public_holiday is false
AND SCHOOL_HOLIDAY = '0'
AND DAY_OF_WEEK BETWEEN 1 AND 5 AND YEAR = '2016'
AND MONTH = 5) AMV
GROUP BY STATION_ID,TRAFFIC_DIRECTION_SEQ
ORDER BY STATION_ID, TRAFFIC_DIRECTION_SEQ

```

Thank you for your time.

Regards,

---

<div class="post-metadata">

**Author:** ![terencekhoo](https://avatars.discourse-cdn.com/v4/letter/t/3ec8ea/32.png) [@terencekhoo](https://opendataforum.transport.nsw.gov.au/u/terencekhoo)\
**Post date:** [February 2, 2021, 2:54am UTC](https://opendataforum.transport.nsw.gov.au/t/traffic-volume-counts-api/2248/6 "2021-02-02T02:54:11Z")

</div>

Hi,

We will update the swagger to include json format.

Example 1: Changed format to json

```
https://api.transport.nsw.gov.au/v1/roads/spatial?format=json&q=SELECT%20station_id,%20traffic_direction_seq,date,(hour_06%2Bhour_07%2Bhour_08)%20as%20%22am_peak_total%22%20%0AFROM%20road_traffic_counts_hourly_permanent%20%0ALEFT%20JOIN%20road_traffic_counts_station_reference%20%0AON%20road_traffic_counts_station_reference.station_key%20%3D%20road_traffic_counts_hourly_permanent.station_key%0AWHERE%20station_id%3D'SHB'%20AND%20year%20%3D%20'2016'%20AND%20%20public_holiday%20is%20true%20AND%20day_of_week%20BETWEEN%201%20AND%205%20AND%20classification_seq%20%3D%202%20and%20month%20in%20(1,2,3)%20AND%20cardinal_direction_seq%20%3D%205%0AORDER%20BY%20date%0A

```

Example 2: We will get back on this.

Example 3: Please ensure that you select csv as the format.

```
https://api.transport.nsw.gov.au/v1/roads/spatial?format=csv&q=SELECT%20NAME,LGA,SUBURB,ROAD_FUNCTIONAL_HIERARCHY,WGS84_LATITUDE,WGS84_LONGITUDE,SUMM.*%20%0AFROM%20road_traffic_counts_station_reference%20REF%20%0AJOIN%20road_traffic_counts_yearly_summary%20SUMM%20ON%20REF.STATION_KEY%20%3D%20SUMM.STATION_KEY%20WHERE%20SUBURB%20%3D%20'Parramatta'%20%0AAND%20PERIOD%20%3D%20'PM%20PEAK'%20%0AAND%20TRAFFIC_DIRECTION_SEQ%20IN%20('1','2')

```

Example 4: Changed format to json. Do note that you have to change the %2b to + when you are using our swagger in the API page. I will change the documentation to reflect that.

```
https://api.transport.nsw.gov.au/v1/roads/spatial?format=json&q=SELECT%20STATION_ID,%20TRAFFIC_DIRECTION_SEQ,%20%0AAVG(AMV.AM_VOL)%20AM_VOL%20%0AFROM%20(SELECT%20PERM.DATE,%20REF.STATION_ID,%20PERM.TRAFFIC_DIRECTION_SEQ,(HOUR_07%2BHOUR_08)%20AS%20AM_VOL%20%0AFROM%20road_traffic_counts_station_reference%20REF%20JOIN%20road_traffic_counts_hourly_permanent%20PERM%20ON%20PERM.STATION_KEY%20%3D%20REF.STATION_KEY%20%0AWHERE%20public_holiday%20is%20false%20%0AAND%20SCHOOL_HOLIDAY%20%3D%20'0'%20%0AAND%20DAY_OF_WEEK%20BETWEEN%201%20AND%205%20%0AAND%20YEAR%20%3D%20'2016'%20%0AAND%20MONTH%20%3D%205)%20AMV%20%0AGROUP%20BY%20STATION_ID,TRAFFIC_DIRECTION_SEQ%20%0AORDER%20BY%20STATION_ID,%20TRAFFIC_DIRECTION_SEQ%0A%0A

```

---

<div class="post-metadata">

**Author:** ![hyeuk](https://avatars.discourse-cdn.com/v4/letter/h/ea666f/32.png) [@hyeuk](https://opendataforum.transport.nsw.gov.au/u/hyeuk)\
**Post date:** [February 2, 2021, 5:03am UTC](https://opendataforum.transport.nsw.gov.au/t/traffic-volume-counts-api/2248/7 "2021-02-02T05:03:49Z")

</div>

Thank you so much for your help. I hope you could update the manual accordingly.

Regards,

Hyeuk

---

<div class="post-metadata">

**Author:** ![aloong001](https://sea1.discourse-cdn.com/flex019/user_avatar/opendataforum.transport.nsw.gov.au/aloong001/32/556_2.png) [@aloong001](https://opendataforum.transport.nsw.gov.au/u/aloong001)\
**Post date:** [August 12, 2021, 11:35pm UTC](https://opendataforum.transport.nsw.gov.au/t/traffic-volume-counts-api/2248/8 "2021-08-12T23:35:53Z")

</div>

Hi i noticed the traffic counts stop at Jun2021, will this be updated more frequently given the COV19

---

<div class="post-metadata">

**Author:** ![jyoung6](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@jyoung6](https://opendataforum.transport.nsw.gov.au/u/jyoung6)\
**Post date:** [August 26, 2021, 4:37am UTC](https://opendataforum.transport.nsw.gov.au/t/traffic-volume-counts-api/2248/9 "2021-08-26T04:37:48Z")

</div>

Hi everyone, this has now been updated as of August 2021 (it updates monthly).

---

<div class="post-metadata">

**Author:** ![otj899](https://avatars.discourse-cdn.com/v4/letter/o/ccd318/32.png) [@otj899](https://opendataforum.transport.nsw.gov.au/u/otj899)\
**Post date:** [November 17, 2021, 8:40pm UTC](https://opendataforum.transport.nsw.gov.au/t/traffic-volume-counts-api/2248/10 "2021-11-17T20:40:01Z")

</div>

Hi,  
I have structured the requests exactly as listed out in the example given, but continue to get an ‘error in request data’ error.  
Could you let me know how to fix this?  
Regards,

---

<div class="post-metadata">

**Author:** ![jyoung6](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@jyoung6](https://opendataforum.transport.nsw.gov.au/u/jyoung6)\
**Post date:** [November 17, 2021, 11:05pm UTC](https://opendataforum.transport.nsw.gov.au/t/traffic-volume-counts-api/2248/11 "2021-11-17T23:05:25Z")

</div>

Hi otj899,

Could you be more specific about which example you are referring to?

Thanks,  
Julie
