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

I'm trying to load the Sydney Fuel data (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 ?

[
    {
        "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": []
    }
]

Hello!

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

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 ?

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?

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

WITH your API key in the header

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

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
[
    {
        "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": []
    }
]

Your Welcome :slight_smile:

Glad you got it sorted