VIEW API 

 

The NSW Government collects and publishes the standard retail prices of all prescribed fuels sold at every service station in NSW. This data is available for the estimated 2500 petrol stations with live pricing and fuel presently available by each location.

Many consumers and businesses in NSW rely on the knowledge that they have access to the cheapest petrol in their area. This API (Application Programming Interface) may be used for purposes such as the development of mobile apps, websites and enterprise systems as well as long term analytical reports.

The Fuel API 

The Fuel API has been developed as a means of accessing live pricing across all current NSW service stations. It is advised that you read the contents of this documentation carefully which includes restrictions and responsibilities that would be necessary to allow appropriate interaction with the API.

Due to the nature of our business, from time to time we upgrade our APIs and associated documentation. Please ensure you check this site regularly for newly published APIs and supporting information.

Disclaimer 

This API is maintained pursuant to Division 6 Publication of service station fuel prices of the Fair Trading Act 1987.

NSW Fair Trading disclaims all responsibility and all liability (including without limitation, liability in negligence) for all expenses, losses, damages and costs which might incur as a result of using this API, or for it being inaccurate or incomplete in any way, and for any reason.

Get All Current Prices - Returns all current prices for all service stations. There are restrictions on how often this API request can be made.

Get Reference Data - Returns list of reference data to be used in subsequent requests.

Get New Current Prices - Returns all new current prices that have been submitted since last “Get All Current Prices” or “Get New Current Prices” request using the api key on the current day.

Get Fuel Prices Within Radius - Performs a query that returns current fuel prices for a single fuel type within a specified radius.

Get Fuel Prices For Location - Performs a query that returns current fuel prices for a single fuel type and a named location (i.e. suburb or postcode)

Get Fuel Prices for Station - Returns a list of current fuel prices for a specified service station.

Get Client Credentials - The client can request an access token using only its client credentials (or other supported means of authentication) when the client is requesting access to the protected resources under its control, or those of another resource owner that have been previously arranged with the authorization server. This request is only required to perform the price update request.

Request format 

Fuel API is a JSON (JavaScript Object Notation) API. User must supply a 'Content-Type: application/json' header in the PUT and POST requests. Users must also set an 'Accept: application/json' header on all requests. Every request sent will have an API key, transaction id, and requested time stamp in the header.

Response format 

A successful call to our API will result into a 200, 400 or 500 response. The response body will contain a JSON list of data requested if a 200 response is received. A 400 response will indicate a bad request while a 500 response would show internal server error codes that are described in detail below.

Error codes.

Data types 

Data types the API returns and accepts are in JSON values which may be strings, decimals, DateTime, boolean values, integers, double, or null values. JSON  (JavaScript Object Notation) is human readable and can be parsed and generated by various programming languages easily.

Fields ‘apikey’ and ‘transactionid’ in request header are in string format while ‘requesttimestamp’ and ‘responsetimestamp’ are in dateTime format ("dd/MM/yyyy hh:mm:ss AM/PM”). Latitude and longitude may be either decimal or null values in the response body.

The order in which the sorting data will be returned is specified with a field ‘sortascending’ which should be in boolean format while most of other attributes would be in JSON format.

The Fuel API has specific endpoint request limitations to authorised users. We reserve the right to adjust rate limits for any given endpoint in order to improve the quality of service provided to users. Every API consumer will be limited to a number of requests based on their agreement.

The table below shows the date, version number and a detailed description of recent changes or modifications made to the Fuel API to date. Expected or scheduled changes are indicated in a green colour while yellow is used to indicate completed upgrades or changes. It is our responsibility to improve the quality of service we provide to you on regular basis.

Recent API Changes
Date Version Description
22-Aug-2016 1.0 Fuel API development portal launched

For a detailed release history, please click here

The Fuel APIs are secured with OAuth 2.0 protocol. In order to use our APIs you must be a registered user with a valid username and password. In addition, every user would require an API Key and a 'Secret' (Password). There are two types of access tokens required to communicate with the API. 

API tokens 

API tokens are managed via our api.nsw development portal (this site). Users require an API key for every request submitted regardless of whether you are uploading or receiving data from our servers.

OAuth access tokens 

For users who are uploading data an extra OAuth access token is a required with your valid API key.

For more information see OAuth 2.0

 

Detailed information on security of Fuel API