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

@malereg/aowatch-client

v1.3.3

Published

Abgeordnetenwatch TypeScript/JavaScript API client for Browser, Node and Typescript

Downloads

199

Readme

@malereg/aowatch-client

Abgeordnetenwatch TypeScript/JavaScript API client for Browser, Node and Typescript

npm version GitHub stars

Features:

Installation

npm install @malereg/aowatch-client --save

All api methods available

fetch one item

import { politicianList, politician } from '@malereg/aowatch-client/src/entities/entity.politician';
politician(100).then(console.log)

fetch a list

import { politicianList, politician } from '@malereg/aowatch-client/src/entities/entity.politician';
politician().then(console.log)

Paging

import { politicianList } from '@malereg/aowatch-client/src/entities/entity.politician';
politicianList({
  page: 0,
  pager_limit: 10
}).then(console.log)

Sorting

import { politicianList } from '@malereg/aowatch-client/src/entities/entity.politician';
politicianList(null, {
  sort_by: 'id',
  sort_direction: 'asc'
}).then(console.log)

Filtering

Simple equal filters on a property.

All female politicians

import { politicianList } from '@malereg/aowatch-client/src/entities/entity.politician';
politicianList(null, null, {
  sex: "f"
}).then(console.log)

More complex filters can be set up as well with comparators.

import { politicianList } from '@malereg/aowatch-client/src/entities/entity.politician';
politicianList(null, null, [{
  field: 'year_of_birth',
  operator: 'gt',
  value: 1983
}
]).then(console.log)

Extends the original API

get all data of a specific type

If you need all the data of one specific endpoint, you can simply use currying to do so using the listAll method. It will make sure all data is loaded and the metadata is properly updated.

import { listAll } from '@malereg/aowatch-client/src/list-all'
import { partyList, url } from '@malereg/aowatch-client//src/entities/entity.party';
// get all parties
const res = await listAll(partyList);

There is a Event emitter argument that allows to react to parts of the fetchAll process

const politicianList = require('@malereg/aowatch-client/entities/entity.politician').politicianList;
const partyList = require('@malereg/aowatch-client/entities/entity.party').partyList;
const listAll = require('@malereg/aowatch-client/list-all').listAll;
const getEmitter = require('@malereg/aowatch-client/list-all').getEmitter;

const politicianEmitter = getEmitter();
politicianEmitter.on('count', (count)=>{
    console.log(`fetching ${count} pages`);
});

politicianEmitter.on('page', (meta)=>{
    console.log(`Fetching politician page ${meta.result.page} of ${Math.ceil(meta.result.total/meta.result.count)}`);
});

const res = listAll(politicianList, politicianEmitter);
res.then(console.log)   

get website links of politicians

import { extractLinks } from '@malereg/aowatch-client/src/extract-links'
import { politician } from '@malereg/aowatch-client//src/entities/entity.politician';
// load the politician
const politician = await politician(100).data;
const links = extractLinks(politician.abgeordnetenwatch_url)

Javascript/Node

In Node and browser builds, you should use the generic API object. It comes with the positive sideeffect of providing events.

const client = require('@malereg/aowatch-client').AowatchCLient;

const c = new client();
c.politician.item(100).then(console.log)

Browser Package