1.0.3 • Published 1 year ago

@sherex/minrenovasjon v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

Usage

Applying for an API key

You can apply for an API key at https://www.norkart.no/product/api-for-utviklere/.

Installation

npm i @sherex/minrenovasjon

TS Example:

Simple example using .getEmptyingDatesFromAddress to get the emptying days for a specified address.

import { MinRenovasjonClient } from '@sherex/minrenovasjon'

;(async () => {
  const client = new MinRenovasjonClient({ 'A_SUPER_SECRET_KEY' })

  const emptyingDates = await client.getEmptyingDatesFromAddress({
    municipality: 'Skien',
    addressName: 'Fylkesbakken',
    houseNumber: '5'
  })

  console.log(emptyingDates)
})().catch(console.error)

Will output:

[
  {
    fractionId: 1,
    fraction: 'Rest, mat og plast',
    fractionIconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/matrestavfallplast.png',
    dates: [ 2021-02-21T23:00:00.000Z, 2021-02-28T23:00:00.000Z ]
  },
  {
    fractionId: 2,
    fraction: 'Papp og papir',
    fractionIconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/papppapirdrikkekartong.png',
    dates: [ 2021-02-22T23:00:00.000Z, 2021-03-22T23:00:00.000Z ]
  },
  {
    fractionId: 4,
    fraction: 'Glass- og metallemballasje',
    fractionIconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/glassogmetallemballasje.png',
    dates: [ 2021-03-28T22:00:00.000Z, 2021-05-24T22:00:00.000Z ]
  }
]
import { MinRenovasjonClient } from '@sherex/minrenovasjon'

;(async () => {
  // Create the client
  const client = new MinRenovasjonClient({ 'A_SUPER_SECRET_KEY' })

  // Get all fractions for a municipality
  const fractions = await client.getFractions({ municipalityNumber: '3807' })
  console.log(fractions)

  // Get the emptying dates with direct address information (no address search)
  const emptyingDates = await client.getEmptyingDates({
    municipalityNumber: '3807',
    addressCode: '31700',
    addressName: 'Fylkesbakken',
    houseNumber: '5'
  })
  console.log(emptyingDates)

  // Use the address information from getAddressInformation() in getEmptyingDates()
  const addresses = await client.getAddressInformation({
    municipality: 'Skien',
    addressName: 'Fylkesbakken',
    houseNumber: '5'
  })
  console.log(addresses)

  const emptyingDates = await client.getEmptyingDates(addresses[0])
})().catch(console.error)

API

MinRenovasjonClient(options)

Creates the client to interact with the APIs.

ParameterTypeRequiredDefaultDescription
options.appKeystringtrueundefinedThe key for the Norkart APIs. Applying for an API key
options.norkartBaseUrlstringfalsehttps://komteksky.norkart.no/komtek.renovasjonwebapi/apiBase-url for Norkart's APIs
options.geonorgeBaseUrlstringfalsehttps://ws.geonorge.no/adresser/v1Base-url for Geonorge's APIs

MinRenovasjonClient#getEmptyingDatesFromAddress(options)

Gets the emptying dates for the specified address.

ParameterTypeRequiredDefaultDescription
options.municipalitystringtrueundefinedThe municipality for the chosen house. Eg. Skien
options.addressNamestringtrueundefinedThe name of the street excluding the housenumber. Eg. Fylkesbakken
options.houseNumberstringtrueundefinedThe housenumber of that house, including the letter if any. Eg. 2C
[
  {
    fractionId: 1,
    fraction: 'Rest, mat og plast',
    fractionIconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/matrestavfallplast.png',
    dates: [ 2021-02-21T23:00:00.000Z, 2021-02-28T23:00:00.000Z ]
  },
  {
    fractionId: 2,
    fraction: 'Papp og papir',
    fractionIconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/papppapirdrikkekartong.png',
    dates: [ 2021-02-22T23:00:00.000Z, 2021-03-22T23:00:00.000Z ]
  },
  {
    fractionId: 4,
    fraction: 'Glass- og metallemballasje',
    fractionIconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/glassogmetallemballasje.png',
    dates: [ 2021-03-28T22:00:00.000Z, 2021-05-24T22:00:00.000Z ]
  }
]

MinRenovasjonClient#getFractions(options)

Used internally in .getEmptyingDatesFromAddress().

Gets the different fractions that can be recycled in this municipality.

ParameterTypeRequiredDefaultDescription
options.municipalityNumberstringtrueundefinedThe municipalitynumber for the chosen house. You can find this using .get Eg. 3807
[
  {
    id: 1,
    name: 'Rest, mat og plast',
    iconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/matrestavfallplast.png'
  },
  {
    id: 2,
    name: 'Papp og papir',
    iconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/papppapirdrikkekartong.png'
  },
  {
    id: 3,
    name: 'Matavfall',
    iconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/matavfall.png'
  },
  {
    id: 4,
    name: 'Glass- og metallemballasje',
    iconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/glassogmetallemballasje.png'
  },
  {
    id: 5,
    name: 'Drikkekartonger',
    iconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/brush.png'
  },
  {
    id: 6,
    name: 'Farlig avfall (Må bestilles på rig.no/farlig)',
    iconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/farligavfall.png'
  },
  {
    id: 7,
    name: 'Plastemballasje',
    iconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/plastemballasje.png'
  },
  {
    id: 8,
    name: 'Trevirke',
    iconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/brush.png'
  },
  {
    id: 9,
    name: 'Tekstiler',
    iconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/brush.png'
  },
  {
    id: 10,
    name: 'Hageavfall (Må bestilles på rig.no/hage)',
    iconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/hageavfall.png'
  },
  {
    id: 11,
    name: 'Metaller',
    iconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/brush.png'
  },
  {
    id: 12,
    name: 'Hvitevarer/EE-avfall',
    iconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/brush.png'
  },
  {
    id: 13,
    name: 'Papp',
    iconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/pappogkartong.png'
  },
  {
    id: 14,
    name: 'Grovavfall (Må bestilles på rig.no/grovavfall)',
    iconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/gjenstandertilombruk.png'
  },
  {
    id: 15,
    name: 'Hjemmekompostering',
    iconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/brush.png'
  },
  {
    id: 16,
    name: 'Usortert restavfall',
    iconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/restavfall.png'
  }
]

MinRenovasjonClient#getEmptyingDates(options)

Used internally in .getEmptyingDatesFromAddress().

Gets the emptying dates for the address details gotten from .getAddressInfo().

ParameterTypeRequiredDefaultDescription
options.municipalityNumberstringtrueundefinedThe municipalitynumber for the chosen house. You can find this using .get Eg. 3807
options.addressCodestringtrueundefinedThe addresscode gotten from .getAddressInfo()
options.addressNamestringtrueundefinedThe name of the street excluding the housenumber. Eg. Fylkesbakken
options.houseNumberstringtrueundefinedThe housenumber of that house, including the letter if any. Eg. 2C
[
  {
    fractionId: 1,
    fraction: 'Rest, mat og plast',
    fractionIconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/matrestavfallplast.png',
    dates: [ 2021-02-21T23:00:00.000Z, 2021-02-28T23:00:00.000Z ]
  },
  {
    fractionId: 2,
    fraction: 'Papp og papir',
    fractionIconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/papppapirdrikkekartong.png',
    dates: [ 2021-02-22T23:00:00.000Z, 2021-03-22T23:00:00.000Z ]
  },
  {
    fractionId: 4,
    fraction: 'Glass- og metallemballasje',
    fractionIconUrl: 'https://komteksky.norkart.no/komtek.renovasjonwebapi/Ikoner/glassogmetallemballasje.png',
    dates: [ 2021-03-28T22:00:00.000Z, 2021-05-24T22:00:00.000Z ]
  }
]

MinRenovasjonClient#getAddressInformation(options)

Used internally in .getEmptyingDatesFromAddress().

Search for address details used in other methods.

ParameterTypeRequiredDefaultDescription
options.municipalitystringtrueundefinedThe municipality for the chosen house. Eg. Skien
options.addressNamestringtrueundefinedThe name of the street excluding the housenumber. Eg. Fylkesbakken
options.houseNumberstringtrueundefinedThe housenumber of that house, including the letter if any. Eg. 2C
[
  {
    municipalityNumber: '3807',
    addressCode: '31700',
    addressName: 'Fylkesbakken',
    houseNumber: '2C'
  }
]

LICENSE

MIT