A simple wrapper around the version 4 of the creativecommons.tankerkoenig.de API for fetching real-time gas prices in Germany
npm install tankerkoenigv4
npm run test
import { stats } from 'tankerkoenigv4';
(async () => {
const { E5, E10, Diesel } = await stats({ apikey: APIKEY });
console.log({E5, E10, Diesel});
})();
Sample output:
{
E5: { count: 13455, mean: 1.972, median: 1.969 },
E10: { count: 12837, mean: 1.917, median: 1.909 },
Diesel: { count: 13593, mean: 1.969, median: 1.959 }
}
import { byCoordinates } from 'tankerkoenigv4';
(async () => {
const { stations } = await byCoordinates({
lat: 50.114634,
lng: 8.687657,
apikey: APIKEY
})
console.log(stations);
})();
Sample output:
[
{
country: 'de',
id: '09978ef8-5fa5-46d5-8389-957eb7cd8540',
name: 'Aral Tankstelle',
brand: 'ARAL',
street: 'Grueneburgweg 67',
postalCode: '60323',
place: 'Frankfurt',
coords: { lat: 50.12197, lng: 8.669096 },
isOpen: true,
closesAt: '2022-04-15T21:45:00+02',
openingTimes: [ [Object], [Object], [Object] ],
dist: 1.55,
fuels: [ [Object], [Object], [Object] ]
},
{
country: 'de',
id: '0a70f16c-0b9e-4083-973e-01173c8839e5',
name: 'Esso Tankstelle',
brand: 'ESSO',
street: 'SPESSARTSTR. 22-24 ',
postalCode: '60385',
place: 'FRANKFURT',
coords: { lat: 50.12519, lng: 8.709553 },
isOpen: false,
opensAt: '2022-04-16T07:00:00+02',
openingTimes: [ [Object], [Object], [Object] ],
dist: 1.95,
fuels: [ [Object], [Object], [Object] ]
},
]
import { byIds } from 'tankerkoenigv4';
(async () => {
const { stations } = await byIds({
ids: ['83d5ac80-4f23-4106-b054-7c7704bfcb95'],
apikey: APIKEY
})
console.log(stations);
})();
Sample output:
[
{
country: 'de',
id: '83d5ac80-4f23-4106-b054-7c7704bfcb95',
name: 'Aral Tankstelle',
brand: 'ARAL',
street: 'Cannstatter StraΓe 46',
postalCode: '70190',
place: 'Stuttgart',
coords: { lat: 48.78922, lng: 9.192324 },
isOpen: true,
openingTimes: [],
fuels: [ [Object], [Object], [Object] ]
}
]
import { byPostalcode } from 'tankerkoenigv4';
(async () => {
const { stations } = await tankerkoenig.byPostalcode({
postalcode: '11011',
apikey: APIKEY
})
console.log(stations);
})();
Sample output:
[
{
country: 'de',
id: 'cba00de3-9841-49ce-943c-0bcded76ba18',
name: 'TotalEnergies Berlin',
brand: 'TotalEnergies',
street: 'Chausseestr. 61-62',
postalCode: '10115',
place: 'Berlin',
coords: { lat: 52.537242, lng: 13.375376 },
isOpen: true,
openingTimes: [],
fuels: [ [Object], [Object], [Object] ]
}
]
In this example we're reporting a wrong diesel price, and submit that the actual price is supposed to be 0.99 β¬ (I wish lol π )
import { complaint } from 'tankerkoenigv4';
(async () => {
await complaint({
id: '1234-1234-1234-1234',
type: 'wrongPriceDiesel',
correction: '0.99',
apikey: APIKEY
})
})();
π€ hugohabicht01
- Github: @hugohabicht01
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Give a βοΈ if this project helped you!
Copyright Β© 2022 hugohabicht01.
This project is MIT licensed.