Giter VIP home page Giter VIP logo

tankerkoenigv4's Introduction

Welcome to tankerkoenigv4 πŸ‘‹

Version Documentation Maintenance License: MIT

A simple wrapper around the version 4 of the creativecommons.tankerkoenig.de API for fetching real-time gas prices in Germany

Install

npm install tankerkoenigv4

Run tests

npm run test

Usage

Fetch stats

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 }
}

Find petrol stations around a certain point

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] ]
  },
]

Get prices of stations by ID

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] ]
  }
]

Get petrolstations by postcode

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] ]
  }
]

Report wrong data

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
  })
})();

Author

πŸ‘€ hugohabicht01

🀝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

πŸ“ License

Copyright Β© 2022 hugohabicht01.
This project is MIT licensed.

tankerkoenigv4's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.