coop-wrapper
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Coop API Wrapper

NPM version NPM license NPM dependencies

npm installnfo

Unofficial Node.js API wrapper for Coop Supermarkten.

Installation

npm install coop-wrapper

or

yarn add coop-wrapper

then

import { Coop } from 'coop-wrapper';

Basic usage

// Creates Coop object, set verbose to true to see all requests
const coop = new Coop({ verbose: true });
// Gets products by name
const products = await coop.product().getProductsFromName('melk');

More information about the functions and parameters can be found on the wiki

Example usage

For all of these examples, please keep in mind that your function in which you request something should be async since the requests return a Promise.

Product

If I want to find all product names that match a given query:

import { Coop } from 'coop-wrapper';

async function findProducts(productName: string) {
    const coop = new Coop();
    const products = await coop.product().getProductsFromName(productName);
    console.log(
        products.elements.map((element) => {
            return element.name;
        })
    );
}

findProducts('karnemelk');
[
  'Zuivelmeester Karnemelk',
  'Melkan Karnemelk',
  'Den Eelder boeren karnemelk',
  'Melkan Houdbare karnemelk',
  'Melkunie Boeren karnemelk',
  'Melkunie Karnemelk',
  'Bio+ Karnemelk',
  'Den Eelder karnemelk rood fruit',
  'Campina Karnemelk houdbaar',
  'Arla Biologisch karnemelk'
]

Recipe

If I want to find all recipe names that match a given query:

import { Coop } from 'coop-wrapper';

async function findRecipes(recipeName: string) {
    const coop = new Coop();
    const recipes = await coop.recipe().getRecipesFromName(recipeName);
    console.log(
        recipes.results.map((result) => {
            return result.title;
        })
    );
}

findRecipes('pizza');
[
  'Naanpizza met tikka masala en paprika',
  'Plaatpizza',
  'Turkse pizza met yoghurt-muntsaus',
  'Pizza-hummus',
  "Lente‘pizza' met gegrilde groenten en mozzarella",
  'Plaatpizza in het groen',
  'Bietenpizza met paprika en spinazie',
  'Broodpizza met gegrilde avocado',
  'Panpizza',
  'Pizza met spinazie, ansjovis en olijven'
]

Package Sidebar

Install

npm i coop-wrapper

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

25.1 kB

Total Files

17

Last publish

Collaborators

  • rinsev