wiltshire-bin-day-api
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Provides a Typescript abstraction to the Wiltshire Council Bin Day Website

npm version

Install with npm

npm install wiltshire-bin-day-api

Basic Implementation

The main function in this repo is the getBinDays function, which returns a list of bin day information for the current month for the given address.

const { getBinDays } = require('wiltshire-bin-day-api')

const binDays = await getBinDays(<POSTCODE>, <HOUSE NAME/NUMBER>)

console.log(binDays)

Returns a list of objects of the binDay type:

[{
    date: 2021-10-07T00:00:00.000Z,
    binType: 'Household waste'
},
{
    date: 2021-10-14T00:00:00.000Z,
    binType: 'Mixed dry recycling (blue lidded bin) and glass (black box or basket)
},
... etc
]

If the UPRN is known (find here), it can be passed to save an extra HTTP call

const binDays = await getBinDays(<POSTCODE>, <HOUSE NAME/NUMBER>, <UPRN>)

The function defaults to the current month/year. If you'd like bin data for another month, these can be passed. The months are numbered with January as 1

const binDays = await getBinDays(<POSTCODE>, <HOUSE NAME/NUMBER>, <UPRN>, <MONTH>, <YEAR>)

Lower-Level Implementation

The api-level functions are also exposed and used as shown below.

AddressList

Get list of details for all available house names/numbers in the given postcode.

const { addressList } = require('wiltshire-bin-day-api')

const addresses = await addressList(<POSTCODE>, <MONTH>, <YEAR>)

Calendar

Get HTML string of calendar with bin day details embedded

const { calendar } = require('wiltshire-bin-day-api')

const binCalendarHtml = await calendar(<POSTCODE>, <UPRN>, <MONTH>, <YEAR>)

Can be automatically parsed with binDayHtmlParser to get binDay objects

const binDays = binDayHTMLParser(binCalendarHtml)

Contribute

Feel free to open a pull request! The repo was quickly made for a project.

License

MIT


Medium @ethanr2000  ·  GitHub @ethanr-2000  ·  LinkedIn @ethanroberts2000

Readme

Keywords

none

Package Sidebar

Install

npm i wiltshire-bin-day-api

Weekly Downloads

1

Version

1.0.4

License

MIT

Unpacked Size

40.3 kB

Total Files

24

Last publish

Collaborators

  • ethanr2000