npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gegevensmagazijn.ts

v3.1.1

Published

A simple typescript/javascript wrapper for the Dutch : House of Representatives OData API

Downloads

14

Readme

Gegevensmagazijn.ts

A simple typescript/javascript wrapper for the Dutch : House of Representatives OData API.

GitHub deployments

NPM NPM GitHub Workflow Status (with event)

GitHub Repository

https://github.com/nowarries/gegevensmagazijn.ts

NPM Package

https://www.npmjs.com/package/gegevensmagazijn.ts

Wrapper Documentation

https://nowarries.github.io/gegevensmagazijn.ts/

Table of Contents

Installation

To get started with the api in your project. First install the package by writing

npm install gegevensmagazijn.ts in your project location

Usage

Please consider reading the following documentation before using this package.

To use the api in your project, first import the package by writing

import { ODataRequest } from 'gegevensmagazijn.ts'

Then create a new instance of the class by writing.

  1. The parameter is the name of the entity you want to query
  2. Available entities are listed on the API's website
const request = new ODataRequest("Fractie")

If you want to gather information about a specific entity, you can use the findById method.

request.findById("d720f5af-0516-408a-b830-0b6ffb8a581c")

Functions

To properly use the wrapper, you need to know the functions that are available to you. For this you can use the documentation. Examples

Now you can apply the 'functions' to the request. For example, if you want to get the chairs of a specific fraction, you can use the expand method like this:

request.expand("FractieZetel")

It's important to note that

Query options $filter, $orderby, $count, $skip, and $top can be applied only on collections.

So if you want to use these options, you cannot use the findById method. Instead, apply the functions to the request directly.

Processing the request

Once you applied all the functions you want to the request, you can pick one of the following options to process the request.

  1. Use the build() method to get the query url. This can be used to make a request with a different library.
request.build() // https://gegevensmagazijn.tweedekamer.nl/OData/v4/2.0/Fractie/d720f5af-0516-408a-b830-0b6ffb8a581c?$expand=FractieZetel
  1. Use the request() method to make a request with cross-fetch
request.request().then((response) => {
    console.log(response) // { ... }
})

Summary

The wrappers usage would look something like this:

import { ODataRequest } from 'gegevensmagazijn.ts'

const request = new ODataRequest("Fractie")

request
    .findById("d720f5af-0516-408a-b830-0b6ffb8a581c")
    .expand("FractieZetel")

request.request().then((response) => {
    console.log(response) // { ... }
}).catch((error) => {
    console.log(error)
})

or

import { ODataRequest } from 'gegevensmagazijn.ts'

const request = new ODataRequest("Fractie")

request
    .expand("FractieZetel")
    .filter("Afkorting ne 'CU'")
    .top(10)

console.log(request.build()) // https://gegevensmagazijn.tweedekamer.nl/OData/v4/2.0/Fractie?$top=10&$expand=FractieZetel&$filter=Afkorting%20ne%20%27CU%27

Advanced examples

const request = new ODataRequest('Besluit')
  .select('id')
  .expand('Zaak', '$select=Onderwerp')
  .orderby('Status')
  .filter("BesluitSoort eq 'Ingediend'")
  .select('BesluitSoort');

console.log(request.build());

Result:

https://gegevensmagazijn.tweedekamer.nl/OData/v4/2.0/Besluit?$orderby=Status asc&$expand=Zaak($select=Onderwerp)&$select=id,BesluitSoort&$filter=BesluitSoort eq 'Ingediend'
const request = new ODataRequest('Fractie')
  .expand('FractieZetel', '$select=Id')
  .filter('AantalZetels gt 10 and AantalZetels lt 50')
  .filter("Afkorting ne 'D66'")
  .orderby('AantalZetels', 'desc')
  .skip(1)
  .count(true)
  .format('minimal');

console.log(request.build());

Result:

https://gegevensmagazijn.tweedekamer.nl/OData/v4/2.0/Fractie?$skip=1&$count=true&$orderby=AantalZetels desc&$expand=FractieZetel($select=Id)&$filter=AantalZetels gt 10 and AantalZetels lt 50 and Afkorting ne 'D66'&$format=minima
l

Dependency

This project is dependent on:

Dutch : House of Representatives OData API | https://opendata.tweedekamer.nl

cross-fetch - A light-weight module that brings fetch to Node.js | https://github.com/lquixada/cross-fetch

TypeDoc - Documentation generator for TypeScript projects. | https://typedoc.org/