No Password Management

    picnic-api
    TypeScript icon, indicating that this package has built-in type declarations

    2.0.1 • Public • Published

    npm version GitHub license Buy me an Affligem blond MAAR3267

    Picnic-API

    Unofficial (unaffiliated) Node.js npm package for the API of the online supermarket Picnic.

    Getting started

    Using npm:

    npm install picnic-api
    

    Then import the package into your project. PicnicClient is the default export.

    import PicnicClient from "picnic-api";
    
    // or
    
    const PicnicClient = require("picnic-api");

    Now initialize the Picnic client with an optional options object.

    const picnicClient = new PicnicClient();
    
    // or
    
    const picnicClient = new PicnicClient({
        countryCode: "NL", // The country code for the requests. Can be NL or DE. Untested for other countries.
        apiVersion: "17", // default 17 as this is what the app currently uses. The api version for the requests. Does not seem to do anything yet.
        authKey: "long string here", // default null. The code for the x-picnic-auth header to make authenticated requests. If not supplied then login() needs to be called before making any other requests.
        url: "url here" // default https://storefront-prod.nl.picnicinternational.com/api/17. The url to send requests to.
    });

    If no authKey was given in the options use the login method. Empty response if successful, otherwise an error.

    await picnicClient.login("email", "password");
    // send an authenticated request...
    
    // or
    
    picnicClient.login("email", "password").then(_ => {
        // send an authenticated request...
    });

    Example of a GET request:

    let searchResults = await picnicClient.search("Affligem blond");
    
    // or
    
    picnicClient.search("Affligem blond").then(searchResults => {
        
    });

    Example of a POST request:

    await picnicClient.addProductToShoppingCart(11295810, 2);
    
    // or
    
    picnicClient.addProductToShoppingCart(11295810, 2).then(shoppingCart => {
        
    });

    If you like this library then consider using my discount code MAAR3267 so that we both get a 5 euro discount on our orders. 😄

    API Routes

    Most API routes have been implemented as methods in the PicnicClient class. However, to get a list of all known API routes the method getKnownApiRoutes can be used. These routes are extracted from the Picnic android app. Latest extraction done for version 1.15.129.

    Examples of a custom (unimplemented) request:

    picnicClient.sendRequest(HttpMethods.GET, "/unknown/route");
    picnicClient.sendRequest(HttpMethods.POST, "/invite/friend", { email: "email@email.email" });

    Install

    npm i picnic-api

    DownloadsWeekly Downloads

    13

    Version

    2.0.1

    License

    MIT

    Unpacked Size

    78.9 kB

    Total Files

    12

    Last publish

    Collaborators

    • mrvdh