# Gather Fuel Data in Sydney!..sorted (fuelcheck.nsw.gov.au)

**URL:** <https://discourse.nodered.org/t/gather-fuel-data-in-sydney-sorted-fuelcheck-nsw-gov-au/96733>\
**Category:** Share Your Projects\
**Created:** [24 April 2025 01:54 UTC](https://discourse.nodered.org/t/gather-fuel-data-in-sydney-sorted-fuelcheck-nsw-gov-au/96733 "2025-04-24T01:54:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![xx\_Nexus\_xx](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xx\_Nexus\_xx](https://discourse.nodered.org/u/xx_Nexus_xx)\
**Post date:** [24 April 2025 01:54 UTC](https://discourse.nodered.org/t/gather-fuel-data-in-sydney-sorted-fuelcheck-nsw-gov-au/96733/1 "2025-04-24T01:54:55Z")

</div>

I'm trying to load the Sydney Fuel data ([https://www.fuelcheck.nsw.gov.au/app](https://www.fuelcheck.nsw.gov.au/app)) into Node-Red using the proposed API reuqtest (same comes from ChatGPT).

But somehow I'm missing something.

Has anybody had any luck with this ?

```auto
[
    {
        "id": "432632c571592cad",
        "type": "inject",
        "z": "f239c7a83fa7019c",
        "name": "Get Fuel Data",
        "props": [],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 190,
        "y": 1120,
        "wires": [
            [
                "ab4e830dce87f6dc"
            ]
        ]
    },
    {
        "id": "ab4e830dce87f6dc",
        "type": "http request",
        "z": "f239c7a83fa7019c",
        "name": "Fetch from FuelCheck",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "https://api.nsw.gov.au/FuelPriceCheck/v2/fuel/prices/nearest?latitude=-33.8731&longitude=151.2065&fueltype=U91",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [
            {
                "keyType": "other",
                "keyValue": "x-api-key",
                "valueType": "other",
                "valueValue": "abc"
            }
        ],
        "x": 390,
        "y": 1120,
        "wires": [
            [
                "a58de6ca9ade50a0"
            ]
        ]
    },
    {
        "id": "a58de6ca9ade50a0",
        "type": "debug",
        "z": "f239c7a83fa7019c",
        "name": "Fuel API Output",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 600,
        "y": 1120,
        "wires": []
    }
]

```

---

<div class="post-metadata">

**Author:** ![leftymuller](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leftymuller/32/102326_2.png) [@leftymuller](https://discourse.nodered.org/u/leftymuller)\
**Post date:** [24 April 2025 02:51 UTC](https://discourse.nodered.org/t/gather-fuel-data-in-sydney-sorted-fuelcheck-nsw-gov-au/96733/2 "2025-04-24T02:51:18Z")

</div>

Hello!

You need to sign up to NSW gov and get a authorized API key to get access to their API

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/3/93972ccfc7cb2f2858886698539fcc2acd80e5f0.png)

---

<div class="post-metadata">

**Author:** ![xx\_Nexus\_xx](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xx\_Nexus\_xx](https://discourse.nodered.org/u/xx_Nexus_xx)\
**Post date:** [24 April 2025 04:16 UTC](https://discourse.nodered.org/t/gather-fuel-data-in-sydney-sorted-fuelcheck-nsw-gov-au/96733/3 "2025-04-24T04:16:16Z")

</div>

Sorry, I should have mentioned that I did try with a valid API-KEY, but it still fails

Did you have more luck with your key ?

---

<div class="post-metadata">

**Author:** ![leftymuller](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leftymuller/32/102326_2.png) [@leftymuller](https://discourse.nodered.org/u/leftymuller)\
**Post date:** [25 April 2025 09:52 UTC](https://discourse.nodered.org/t/gather-fuel-data-in-sydney-sorted-fuelcheck-nsw-gov-au/96733/4 "2025-04-25T09:52:59Z")

</div>

I dont have a key, no need for NSW fuel prices in Western Australia mate

What does your debug say when you have the API key in?

---

<div class="post-metadata">

**Author:** ![leftymuller](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leftymuller/32/102326_2.png) [@leftymuller](https://discourse.nodered.org/u/leftymuller)\
**Post date:** [25 April 2025 09:57 UTC](https://discourse.nodered.org/t/gather-fuel-data-in-sydney-sorted-fuelcheck-nsw-gov-au/96733/5 "2025-04-25T09:57:35Z")

</div>

I Found your problem

Try this  
[https://api.onegov.nsw.gov.au/FuelPriceCheck/v2/fuel/prices/nearest?latitude=-33.8731&longitude=151.2065&fueltype=U91](https://api.onegov.nsw.gov.au/FuelPriceCheck/v2/fuel/prices/nearest?latitude=-33.8731&longitude=151.2065&fueltype=U91)

WITH your API key in the header

Im getting a response from the api now  
"message": "Access token is not valid."

---

<div class="post-metadata">

**Author:** ![xx\_Nexus\_xx](https://avatars.discourse-cdn.com/v4/letter/x/54ee81/32.png) [@xx\_Nexus\_xx](https://discourse.nodered.org/u/xx_Nexus_xx)\
**Post date:** [26 April 2025 05:02 UTC](https://discourse.nodered.org/t/gather-fuel-data-in-sydney-sorted-fuelcheck-nsw-gov-au/96733/6 "2025-04-26T05:02:03Z")

</div>

I finally got it sorted !! .. it does not work with simple API-Key approach, but you have to generate an access\_token first

You just have to update:

- YOUR\_API\_SECRET
- YOUR\_API\_KEY
- your location data in the PAYLOAD node

```auto
[
    {
        "id": "c4bcd3228c3124f8",
        "type": "inject",
        "z": "f239c7a83fa7019c",
        "name": "Get Fuel Data",
        "props": [],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 170,
        "y": 1080,
        "wires": [
            [
                "7855745c57883e66"
            ]
        ]
    },
    {
        "id": "7855745c57883e66",
        "type": "http request",
        "z": "f239c7a83fa7019c",
        "name": "OA",
        "method": "GET",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "https://api.onegov.nsw.gov.au/oauth/client_credential/accesstoken?grant_type=client_credentials",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [
            {
                "keyType": "other",
                "keyValue": "Authorization",
                "valueType": "other",
                "valueValue": "Basic YOUR_API_SECRET"
            },
            {
                "keyType": "other",
                "keyValue": "accept",
                "valueType": "other",
                "valueValue": "application/json"
            }
        ],
        "x": 340,
        "y": 1080,
        "wires": [
            [
                "b8c05c4a8f04f783"
            ]
        ]
    },
    {
        "id": "b8c05c4a8f04f783",
        "type": "change",
        "z": "f239c7a83fa7019c",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "Fuelheck",
                "pt": "flow",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 540,
        "y": 1080,
        "wires": [
            [
                "77b94dcd90ba33db"
            ]
        ]
    },
    {
        "id": "77b94dcd90ba33db",
        "type": "change",
        "z": "f239c7a83fa7019c",
        "name": "Payload",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"fueltype\":\"P95\",\"brand\":[\"BP\"],\"namedlocation\":\"2065\",\"latitude\":\"-33.4362551\",\"longitude\":\"151.2966549\",\"radius\":\"\",\"sortby\":\"price\",\"sortascending\":\"true\"}",
                "tot": "json"
            },
            {
                "t": "set",
                "p": "token",
                "pt": "msg",
                "to": "Fuelheck.access_token",
                "tot": "flow"
            },
            {
                "t": "set",
                "p": "apikey",
                "pt": "msg",
                "to": "YOUR_API_KEY",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "time",
                "pt": "msg",
                "to": "iso",
                "tot": "date"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 140,
        "y": 1160,
        "wires": [
            [
                "97a5360f73ba2b01"
            ]
        ]
    },
    {
        "id": "97a5360f73ba2b01",
        "type": "template",
        "z": "f239c7a83fa7019c",
        "name": "",
        "field": "access_token",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "Bearer {{token}}",
        "output": "str",
        "x": 290,
        "y": 1160,
        "wires": [
            [
                "44ec467e2ccaa6ea",
                "532ccc37e54b3347"
            ]
        ]
    },
    {
        "id": "44ec467e2ccaa6ea",
        "type": "http request",
        "z": "f239c7a83fa7019c",
        "name": "Fetch from FuelCheck",
        "method": "POST",
        "ret": "obj",
        "paytoqs": "body",
        "url": "https://api.onegov.nsw.gov.au/FuelPriceCheck/v2/fuel/prices/nearby",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [
            {
                "keyType": "other",
                "keyValue": "Authorization",
                "valueType": "msg",
                "valueValue": "access_token"
            },
            {
                "keyType": "other",
                "keyValue": "accept",
                "valueType": "other",
                "valueValue": "application/json"
            },
            {
                "keyType": "other",
                "keyValue": "Content-Type",
                "valueType": "other",
                "valueValue": "application/json"
            },
            {
                "keyType": "other",
                "keyValue": "apikey",
                "valueType": "msg",
                "valueValue": "apikey"
            },
            {
                "keyType": "other",
                "keyValue": "transactionid",
                "valueType": "other",
                "valueValue": "Fuelid"
            },
            {
                "keyType": "other",
                "keyValue": "requesttimestamp",
                "valueType": "msg",
                "valueValue": "time"
            }
        ],
        "x": 530,
        "y": 1160,
        "wires": [
            [
                "82bb9e6b646d0946"
            ]
        ]
    },
    {
        "id": "532ccc37e54b3347",
        "type": "debug",
        "z": "f239c7a83fa7019c",
        "name": "Fuel API Output",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 470,
        "y": 1200,
        "wires": []
    },
    {
        "id": "82bb9e6b646d0946",
        "type": "change",
        "z": "f239c7a83fa7019c",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "Fuelprice",
                "pt": "flow",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 760,
        "y": 1160,
        "wires": [
            [
                "b9baa92c9834432d"
            ]
        ]
    },
    {
        "id": "b9baa92c9834432d",
        "type": "debug",
        "z": "f239c7a83fa7019c",
        "name": "Fuel API Output",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 790,
        "y": 1220,
        "wires": []
    }
]

```

---

<div class="post-metadata">

**Author:** ![leftymuller](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leftymuller/32/102326_2.png) [@leftymuller](https://discourse.nodered.org/u/leftymuller)\
**Post date:** [26 April 2025 06:40 UTC](https://discourse.nodered.org/t/gather-fuel-data-in-sydney-sorted-fuelcheck-nsw-gov-au/96733/7 "2025-04-26T06:40:23Z")

</div>

Your Welcome 🙂

Glad you got it sorted

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [10 May 2025 06:40 UTC](https://discourse.nodered.org/t/gather-fuel-data-in-sydney-sorted-fuelcheck-nsw-gov-au/96733/8 "2025-05-10T06:40:49Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
