eco-counter-client

1.0.0 • Public • Published

eco-counter-client

Fetch data about bicycle counters from the Eco Counter API.

npm version build status ISC-licensed chat on gitter support me on Patreon

Installing

npm install eco-counter-client

Usage

An organisation seems to be just a set of counters. You need to pass in an organisation ID. See eco-counter-organisations for a list.

const {counters, data} = require('eco-counter-client')
 
counters(4728) // Berlin
.then((counters) => {
    const c = counters[0]
    console.log(c)
    return data(c.organisation.id, c.id, c.instruments, c.periodStart, c.periodEnd)
})
.then(console.log)
.catch(console.error)

counters(org) returns a Promise that resolves with an array of bike counters. A single result looks like this:

{
    id: '100024661',
    name: 'Jannowitzbrücke',
    url: 'http://www.stadtentwicklung.berlin.de/verkehr/lenkung/vlb/de/erhebungen.shtml',
    coordinates: {
        latitude: 52.5140658632566,
        longitude: 13.41775102070807,
        country: 'de'
    },
    organisation: {
        id: 4728,
        name: 'VERKEHRSLENKUNG BERLIN'
    },
    count: 492398,
    periodStart: 2016-01-01T00:00:00.000Z, // JS Date object
    periodEnd: 2020-03-21T23:00:00.000Z, // JS Date object
    instruments: [101024661, 102024661],
    photos: ['https://www.eco-visio.net/Photos/100024661/14677966316060.jpg'],
    logo: 'https://www.eco-visio.net/Logos/4728/1485517072671.jpg'
}

data(org, id, instruments, start, end) returns a Promise that resolves with an array days. They look like this:

[
    {day: '2016-01-01', count: 950},
    // …
    {day: '2016-26-01', count: 5819},
    // …
    {day: '2016-24-02', count: 6202},
    // …
    {day: '2016-30-03', count: 5556},
    // …
]

Contributing

If you have a question or have difficulties using eco-counter-client, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to the issues page.

Readme

Keywords

Package Sidebar

Install

npm i eco-counter-client

Weekly Downloads

2

Version

1.0.0

License

ISC

Unpacked Size

8.17 kB

Total Files

5

Last publish

Collaborators

  • derhuerst