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

jumbo-wrapper

v2.1.0

Published

API Wrapper for Jumbo

Downloads

216

Readme

Unofficial Node.js API wrapper for Jumbo Supermarkten.

Installation

npm install jumbo-wrapper

or

yarn add jumbo-wrapper

then

import { Jumbo } from 'jumbo-wrapper';

Basic usage

// Creates Jumbo object using username and password, set verbose=true if you want to see all requests
const jumbo = new Jumbo({ username, password, verbose: true });
// Gets product as response from ID
const product = await jumbo.product().getProductFromId('67649PAK');

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 the first 5 product names that match a given query:

import { Jumbo } from 'jumbo-wrapper';

async function findFirstFiveProducts(productName: string) {
    const jumbo = new Jumbo();
    const products = await jumbo.product().getProductsFromName(productName, {
        limit: 5
    });
    console.log(
        products.map((product) => {
            return product.product.data.title;
        })
    );
}

findFirstFiveProducts('melk');
[
  'Jumbo Verse Halfvolle Melk 2L',
  'Jumbo Verse Halfvolle Melk 1L',
  'Jumbo Verse Halfvolle Melk 1, 5L',
  'Jumbo Karnemelk & Halfvolle Melk',
  'Jumbo Houdbare Halfvolle Melk Voordeelverpakking 6 x 1L'
]

You can also add diet and allergen filters:

import { Jumbo, ProductDietFilter, ProductAllergenFilter } from 'jumbo-wrapper';

async function findLactoseFreeMilk() {
    const jumbo = new Jumbo();
    const products = await jumbo.product().getProductsFromName('melk', {
        limit: 5,
        filters: {
            diet: [ProductDietFilter.LactoseIntolerant],
            allergens: [ProductAllergenFilter.Lactose]
        }
    });
    console.log(
        products.map((product) => {
            return product.product.data.title;
        })
    );
}
findLactoseFreeMilk();
[
  'Alpro This is Not M*lk Drink Halfvol Gekoeld 1L',
  'Alpro This is Not M*lk Drink Vol Gekoeld 1L',
  'HiPRO Proteïne Drink Houdbaar Vanille 330ml',
  'Alpro Sojadrink Houdbaar 1L',
  'Alpro Barista Haver Houdbaar 1L'
]

Keep in mind that Jumbo makes a (good) distinction between the dietary restrictions (lactose intolerant) and allergen restrictions (lactose free). The allergens supplied via the filter are the ones that are not allowed in the product.

Store

If I want to find the name of the store that is closest to a given location:

import { Jumbo } from 'jumbo-wrapper';

async function findJumboStore(longitude: number, latitude: number) {
    const jumbo = new Jumbo();
    const res = await jumbo.store().getStoresFromLongLat({
        long: longitude,
        lat: latitude,
        limit: 1
    });
    console.log(res[0].store.data.name);
}

findJumboStore(4.4993409, 51.9106489);
Jumbo Rotterdam Vijf Werelddelen

List

If I want to find the names of the first three lists with the "Winter" list category:

import { Jumbo } from 'jumbo-wrapper';

async function getFirstThreeListsFromCategory(category: string) {
    const jumbo = new Jumbo();
    const lists = await jumbo.list().getListsByName(category, {
        limit: 3
    });
    const names = lists.items.map((list) => {
        return list.title;
    });
    console.log(names);
}

getFirstThreeListsFromCategory('Winter');
[ 'Budget koken', 'Koken met groente', 'Soepen' ]

Keep in mind that while you don't need to be logged in to view public lists, if you want to view your own list you must login first.

Order

NOTE: Authentication is currently not working, for more info see this issue.

If I want to see the ID of the latest order of my Jumbo account:

import { Jumbo } from 'jumbo-wrapper';

async function getLatestOrder(username: string, password: string) {
    const jumbo = new Jumbo(username, password);
    const res = await jumbo.order().getMyLatestOrder();
    console.log(res.order.data.id);
}

getLatestOrder('[email protected]', 'password');

Keep in mind that you need to be logged in to get your orders, for instructions see Authentication.

Basket

If I want to view my current basket:

import { Jumbo } from 'jumbo-wrapper';

async function getMyBasket(username: string, password: string) {
    const jumbo = new Jumbo(username, password);
    const basket = await jumbo.basket().getMyBasket();
    console.log(basket.prices.total.amount);
}

getMyBasket('[email protected]', 'password');

While this will work when not logged in, it does not really make sense to view the basket of a user that is not logged in.

You can also update your basket as follows:

import { Jumbo } from 'jumbo-wrapper';

async function addMilkToMyBasket(username: string, password: string) {
    const jumbo = new Jumbo(username, password);
    const updatedBasket = await jumbo.basket().updateBasket({
        items: [
            {
                quantity: 1,
                sku: '67649PAK', // SKU for milk
                unit: 'pieces' // 'pieces' is often the right choice
            }
        ],
        vagueTerms: []
    });
    console.log(updatedBasket.items[0].sku);
}

addMilkToMyBasket('[email protected]', 'password');

Again, while this will work when not logged in, it does not really make sense to update the basket of a user that is not logged in. Furthermore, the response given by updateBasket is different from getMyBasket since the response from updateBasket will not include any price information, as such, it is recommended to call getMyBasket after updateBasket to get the new price information.