Skip to content

django23/PhPicnicAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PhPicnic-API

By me a book

Inspired and copied from the Python version: https://github.com/MikeBrink/python-picnic-api

Unofficial PHP wrapper for the Picnic API. While not all API methods have been implemented yet, you'll find most of what you need to build a working application are available.

This library is not affiliated with Picnic and retrieves data from the endpoints of the mobile application. Use at your own risk.

Get started

The easiest way to install is directly from composer:

composer install django23/PhPicnicAPI

Usage

<?php

// Composer
require 'vendor/autoload.php';

// Load Env
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();

// Picnic
$picninc = new \PhPicnic\Client($_ENV['username'], $_ENV['password'], $_ENV['country_code']);
// or
$picninc = new \PhPicnic\Client('[email protected]', 'password', 'NL');

Searching for a product

echo $picnic->search('coffee');
// [{'type': 'CATEGORY', 'id': 'coffee', 'links': [{'type': 'SEARCH', 'href': 'https://storefront-prod.nl.picnicinternational.com/api/15/search?search_term=coffee'}], 'name': 'coffee', 'items': [{'type': 'SINGLE_ARTICLE', 'id': '10511523', 'decorators': [{'type': 'UNIT_QUANTITY', 'unit_quantity_text': '500 gram'}], 'name': 'Lavazza espresso koffiebonen', 'display_price': 599, 'price': 599, 'image_id': 'd3fb2888fc41514bc06dfd6b52f8622cc222d017d2651501f227a537915fcc4f', 'max_count': 50, 'unit_quantity': '500 gram', 'unit_quantity_sub': '€11.98/kg', 'tags': []}, ...

Check cart

echo $picnic->getCart();
// {'type': 'ORDER', 'id': 'shopping_cart', 'items': [], 'delivery_slots': [...

Manipulating your cart

All of these methods will return the shopping cart.

// adding 2 'Lavazza espresso koffiebonen' to cart
echo $picnic->addProduct('10511523', 2);

// removing 1 'Lavazza espresso koffiebonen' from cart
echo $picnic->removeProduct('10511523');

// clearing the cart
echo $picnic->clearCart();

See upcoming deliveries

echo $picnic->getCurrentDeliveries();
// []

See available delivery slots

echo $picnic->getDeliverySlots();

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages