This library is undergoing rapid changes as is the Picnic API itself. It is mainly intended for use within Home Assistant, but there are integration tests running regularly checking for failures in features not used by the Home Assistant integration.
If you want to know why interacting with Picnic is getting harder than ever, check out their blogpost about architectural changes: https://blog.picnic.nl/adding-write-functionality-to-pages-with-self-service-apis-d09aa7dbc9c0
Fork of the Unofficial Python 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.
A big thanks to @MikeBrink for building the first versions of this library.
@maartenpaul and @thijmen-j continously provided fixes that were then merged into this fork.
The easiest way to install is directly from pip:
$ pip install python-picnic-api2Then create a new instance of PicnicAPI and login using your credentials:
from python_picnic_api2 import PicnicAPI
picnic = PicnicAPI(username='username', password='password', country_code="NL")The country_code parameter defaults to NL, but you have to change it if you live in a different country than the Netherlands (ISO 3166-1 Alpha-2). This obviously only works for countries that picnic services.
For new logins, Picnic may require two-factor authentication. When 2FA is required, logging in raises a Picnic2FARequired exception. You then need to request a code and verify it:
from python_picnic_api2 import PicnicAPI, Picnic2FARequired, Picnic2FAError
picnic = PicnicAPI(country_code="NL")
try:
picnic.login(username='username', password='password')
except Picnic2FARequired:
# Request a code via SMS or EMAIL
picnic.generate_2fa_code(channel="SMS")
code = input("Enter the code you received: ")
picnic.verify_2fa_code(code)After successful verification, the session is authenticated and you can use the API normally. If the code is invalid, Picnic2FAError is raised.
picnic.search('coffee')[{'items': [{'id': 's1019822', 'name': 'Lavazza Caffè Crema e Aroma Bohnen', 'decorators': [], 'display_price': 1799, 'image_id': 'aecbf7d3b018025ec78daf5a1099b6842a860a2e3faeceec777c13d708ce442c', 'max_count': 99, 'unit_quantity': '1kg', 'sole_article_id': None}, ... ]}]picnic.get_article("s1019822"){'name': 'Lavazza Caffè Crema e Aroma Bohnen', 'id': 's1019822'}picnic.get_article_by_gtin("8000070025400"){'name': 'Lavazza Caffè Crema e Aroma Bohnen', 'id': 's1019822'}picnic.get_cart(){'type': 'ORDER', 'id': 'shopping_cart', 'items': [{'type': 'ORDER_LINE', 'id': '1470', 'items': [{'type': 'ORDER_ARTICLE', 'id': 's1019822', 'name': 'Lavazza Caffè Crema e Aroma Bohnen',...All of these methods will return the shopping cart.
# Add product with ID "s1019822" 2x
picnic.add_product("s1019822", 2)
# Remove product with ID "s1019822" 1x
picnic.remove_product("s1019822")
# Clear your cart
picnic.clear_cart()picnic.get_current_deliveries()[{'delivery_id': 'XXYYZZ', 'creation_time': '2025-04-28T08:08:41.666+02:00', 'slot': {'slot_id': 'XXYYZZ', 'hub_id': '...picnic.get_delivery_slots(){'delivery_slots': [{'slot_id': 'XXYYZZ', 'hub_id': 'YYY', 'fc_id': 'FCX', 'window_start': '2025-04-29T17:15:00.000+02:00', 'window_end': '2025-04-29T19:15:00.000+02:00'...