python-picnic-api2 1.3.4__py3-none-any.whl → 2.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,173 @@
1
+ """Tolerant traversal helpers for Picnic's PML ("layout") responses.
2
+
3
+ The ``/pages/*`` endpoints return a UI tree of widgets rather than clean domain
4
+ JSON. The shape differs by country and A/B test, so parsing must never rely on
5
+ fixed paths. These helpers walk the whole tree and match nodes by ``id``, ``id``
6
+ prefix, ``type`` or a nested-inclusion predicate.
7
+
8
+ This module replaces the older ``helper.find_nodes_by_content`` which had two
9
+ bugs: it never enforced its ``max_nodes`` limit, and it failed to recurse into
10
+ dicts nested inside lists.
11
+ """
12
+
13
+ import re
14
+ from collections.abc import Iterator
15
+
16
+ # Inline color codes embedded in markdown text. Picnic uses two forms: a hex code
17
+ # ``#(#333333)Some text#(#333333)`` and a named palette code ``#(GREEN1)...#(GREEN1)``.
18
+ _COLOR_CODE = re.compile(r"#\((?:#[0-9A-Fa-f]{6}|[A-Z][A-Z0-9_]*)\)")
19
+
20
+
21
+ def walk(node) -> Iterator[dict]:
22
+ """Yield every dict contained in ``node``, depth-first (including ``node``).
23
+
24
+ Recurses into every value of every dict and every item of every list, so
25
+ dicts nested inside lists are visited too.
26
+ """
27
+ if isinstance(node, dict):
28
+ yield node
29
+ for value in node.values():
30
+ yield from walk(value)
31
+ elif isinstance(node, list):
32
+ for item in node:
33
+ yield from walk(item)
34
+
35
+
36
+ def _is_included(node_dict: dict, filter_dict: dict) -> bool:
37
+ """Return whether ``filter_dict`` is a (recursive) subset of ``node_dict``.
38
+
39
+ An empty dict value means "this key must be present" regardless of its value;
40
+ a ``None`` filter value means "this key must be present with any value".
41
+ """
42
+ for key, value in filter_dict.items():
43
+ if key not in node_dict:
44
+ return False
45
+ if isinstance(value, dict) and isinstance(node_dict[key], dict):
46
+ if not _is_included(node_dict[key], value):
47
+ return False
48
+ elif value is not None and node_dict[key] != value:
49
+ return False
50
+ return True
51
+
52
+
53
+ def _matches(
54
+ node: dict,
55
+ *,
56
+ id: str | None,
57
+ id_prefix: str | None,
58
+ type: str | None,
59
+ match: dict | None,
60
+ ) -> bool:
61
+ if id is not None and node.get("id") != id:
62
+ return False
63
+ if id_prefix is not None:
64
+ node_id = node.get("id")
65
+ if not isinstance(node_id, str) or not node_id.startswith(id_prefix):
66
+ return False
67
+ if type is not None and node.get("type") != type:
68
+ return False
69
+ return match is None or _is_included(node, match)
70
+
71
+
72
+ def find_all(
73
+ node,
74
+ *,
75
+ id: str | None = None,
76
+ id_prefix: str | None = None,
77
+ type: str | None = None,
78
+ match: dict | None = None,
79
+ limit: int | None = None,
80
+ ) -> list[dict]:
81
+ """Return all dict nodes in ``node`` matching the given criteria.
82
+
83
+ ``limit`` is actually enforced (stops walking once reached).
84
+ """
85
+ results: list[dict] = []
86
+ for candidate in walk(node):
87
+ if _matches(candidate, id=id, id_prefix=id_prefix, type=type, match=match):
88
+ results.append(candidate)
89
+ if limit is not None and len(results) >= limit:
90
+ break
91
+ return results
92
+
93
+
94
+ def find(
95
+ node,
96
+ *,
97
+ id: str | None = None,
98
+ id_prefix: str | None = None,
99
+ type: str | None = None,
100
+ match: dict | None = None,
101
+ ) -> dict | None:
102
+ """Return the first matching dict node, or ``None``."""
103
+ results = find_all(
104
+ node, id=id, id_prefix=id_prefix, type=type, match=match, limit=1
105
+ )
106
+ return results[0] if results else None
107
+
108
+
109
+ def strip_colors(text):
110
+ """Remove Picnic inline color codes (``#(#RRGGBB)``) from markdown text.
111
+
112
+ Non-string input is returned unchanged.
113
+ """
114
+ if not isinstance(text, str):
115
+ return text
116
+ return _COLOR_CODE.sub("", text)
117
+
118
+
119
+ def _component(node) -> dict | None:
120
+ """Return a node's PML component dict, tolerating a couple of nestings."""
121
+ if not isinstance(node, dict):
122
+ return None
123
+ pml = node.get("pml")
124
+ if isinstance(pml, dict) and isinstance(pml.get("component"), dict):
125
+ return pml["component"]
126
+ if isinstance(node.get("component"), dict):
127
+ return node["component"]
128
+ return node
129
+
130
+
131
+ def text_of(node) -> str | None:
132
+ """Return a node's text/markdown content with color codes stripped."""
133
+ if not isinstance(node, dict):
134
+ return None
135
+ for key in ("markdown", "text"):
136
+ value = node.get(key)
137
+ if isinstance(value, str):
138
+ return strip_colors(value)
139
+ return None
140
+
141
+
142
+ def accessibility_label(node) -> str | None:
143
+ """Return the ``accessibilityLabel`` of a node's component, if any."""
144
+ component = _component(node)
145
+ if component:
146
+ label = component.get("accessibilityLabel")
147
+ if isinstance(label, str):
148
+ return label
149
+ return None
150
+
151
+
152
+ def on_press_target(node) -> str | None:
153
+ """Return the ``onPress.target`` deep-link of a node's component, if any."""
154
+ component = _component(node)
155
+ if not component:
156
+ return None
157
+ on_press = component.get("onPress")
158
+ if isinstance(on_press, dict):
159
+ target = on_press.get("target")
160
+ if isinstance(target, str):
161
+ return target
162
+ return None
163
+
164
+
165
+ __all__ = [
166
+ "walk",
167
+ "find",
168
+ "find_all",
169
+ "strip_colors",
170
+ "text_of",
171
+ "accessibility_label",
172
+ "on_press_target",
173
+ ]
@@ -0,0 +1,65 @@
1
+ """Search-result models, parsed from the ``search-page-results`` PML page."""
2
+
3
+ import json
4
+ import re
5
+
6
+ from .base import PicnicModel
7
+ from .pml import find_all
8
+
9
+ # ``sole_article_id`` is buried as a serialized string somewhere inside a tile.
10
+ _SOLE_ARTICLE_ID_PATTERN = re.compile(r'"sole_article_id":"(\w+)"')
11
+
12
+
13
+ class SearchResultItem(PicnicModel):
14
+ """A single product tile in a search result.
15
+
16
+ Picnic's tile payload only carries ``display_price`` (the price shown on the
17
+ tile, in integer cents) — there is no separate ``price`` key — so that is the
18
+ field to read. ``price_ranges`` is populated instead of ``display_price`` for
19
+ some promotional tiles.
20
+ """
21
+
22
+ id: str
23
+ name: str | None = None
24
+ display_price: int | None = None
25
+ image_id: str | None = None
26
+ unit_quantity: str | None = None
27
+ unit_quantity_sub: str | None = None
28
+ max_count: int | None = None
29
+ price_ranges: list | None = None
30
+ sole_article_id: str | None = None
31
+ decorators: list = []
32
+
33
+
34
+ class SearchResult(PicnicModel):
35
+ """A search response: a collection of product tiles."""
36
+
37
+ items: list[SearchResultItem] = []
38
+
39
+ @classmethod
40
+ def from_page(cls, data: dict) -> "SearchResult":
41
+ """Build a :class:`SearchResult` from a ``search-page-results`` payload.
42
+
43
+ Finds ``SELLING_UNIT_TILE`` nodes anywhere in the tree, merges each
44
+ node's ``sellingUnit`` payload with its ``sole_article_id``.
45
+ """
46
+ body = data.get("body", {}) if isinstance(data, dict) else {}
47
+ nodes = find_all(
48
+ body.get("child", {}),
49
+ match={"type": "SELLING_UNIT_TILE", "sellingUnit": {}},
50
+ )
51
+
52
+ items: list[SearchResultItem] = []
53
+ for node in nodes:
54
+ fields = dict(node.get("sellingUnit", {}))
55
+ sole_ids = _SOLE_ARTICLE_ID_PATTERN.findall(json.dumps(node))
56
+ if sole_ids:
57
+ fields["sole_article_id"] = sole_ids[0]
58
+ item = SearchResultItem.model_validate(fields)
59
+ item.raw = node
60
+ items.append(item)
61
+
62
+ return cls(items=items, raw=data)
63
+
64
+
65
+ __all__ = ["SearchResult", "SearchResultItem"]
@@ -0,0 +1,58 @@
1
+ """User model, parsed from the ``/user`` domain-JSON endpoint."""
2
+
3
+ from .base import PicnicModel
4
+
5
+
6
+ class Address(PicnicModel):
7
+ """A delivery address."""
8
+
9
+ id: str | None = None
10
+ house_number: int | None = None
11
+ house_number_ext: str | None = None
12
+ postcode: str | None = None
13
+ street: str | None = None
14
+ city: str | None = None
15
+
16
+
17
+ class Subscription(PicnicModel):
18
+ """A mailing-list / push subscription toggle."""
19
+
20
+ list_id: str | None = None
21
+ subscribed: bool | None = None
22
+ name: str | None = None
23
+
24
+
25
+ class HouseholdDetails(PicnicModel):
26
+ """Self-reported household composition."""
27
+
28
+ adults: int | None = None
29
+ children: int | None = None
30
+ cats: int | None = None
31
+ dogs: int | None = None
32
+ author: str | None = None
33
+ last_edit_ts: int | None = None
34
+
35
+
36
+ class User(PicnicModel):
37
+ """The authenticated user account, returned by ``get_user``."""
38
+
39
+ user_id: str | None = None
40
+ firstname: str | None = None
41
+ lastname: str | None = None
42
+ address: Address | None = None
43
+ phone: str | None = None
44
+ contact_email: str | None = None
45
+ customer_type: str | None = None
46
+ subscriptions: list[Subscription] = []
47
+ push_subscriptions: list[Subscription] = []
48
+ household_details: HouseholdDetails | None = None
49
+ # Flat map of consent-key -> bool; not worth its own model.
50
+ consent_decisions: dict | None = None
51
+ check_general_consent: bool | None = None
52
+ placed_order: bool | None = None
53
+ received_delivery: bool | None = None
54
+ total_deliveries: int | None = None
55
+ completed_deliveries: int | None = None
56
+
57
+
58
+ __all__ = ["Address", "Subscription", "HouseholdDetails", "User"]
@@ -0,0 +1,205 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-picnic-api2
3
+ Version: 2.0.1
4
+ Project-URL: homepage, https://github.com/codesalatdev/python-picnic-api
5
+ Project-URL: repository, https://github.com/codesalatdev/python-picnic-api
6
+ Author-email: Mike Brink <mjh.brink@icloud.com>, CodeSalat <pypi@codesalat.dev>
7
+ Maintainer-email: CodeSalat <pypi@codesalat.dev>
8
+ License: Apache-2.0
9
+ License-File: LICENSE.md
10
+ Requires-Python: >=3.13
11
+ Requires-Dist: pydantic>=2.13.4
12
+ Requires-Dist: requests>=2.34.2
13
+ Requires-Dist: typing-extensions>=4.16.0
14
+ Description-Content-Type: text/markdown
15
+
16
+ # Python-Picnic-API
17
+
18
+ **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.**
19
+
20
+ **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](https://jobs.picnic.app/en/blogs/adding-write-functionality-to-pages-with-self-service-apis)**
21
+
22
+ Fork of the Unofficial Python wrapper for the [Picnic](https://picnic.app) API. While not all API methods have been implemented yet, you'll find most of what you need to build a working application is available.
23
+
24
+ This library is not affiliated with Picnic and retrieves data from the endpoints of the mobile application. **Use at your own risk.**
25
+
26
+ ## Credits
27
+
28
+ A big thanks to @MikeBrink for building the first versions of this library.
29
+
30
+ @maartenpaul and @thijmen-j continously provided fixes that were then merged into this fork.
31
+
32
+ ## Getting started
33
+
34
+ The easiest way to install is directly from pip:
35
+
36
+ ```bash
37
+ $ pip install python-picnic-api2
38
+ ```
39
+
40
+ Then create a new instance of `PicnicAPI` and login using your credentials:
41
+
42
+ ```python
43
+ from python_picnic_api2 import PicnicAPI
44
+
45
+ picnic = PicnicAPI(username='username', password='password', country_code="NL")
46
+ ```
47
+
48
+ 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.
49
+
50
+ ### Two-factor authentication (2FA)
51
+
52
+ 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:
53
+
54
+ ```python
55
+ from python_picnic_api2 import PicnicAPI, Picnic2FARequired, Picnic2FAError
56
+
57
+ picnic = PicnicAPI(country_code="NL")
58
+
59
+ try:
60
+ picnic.login(username='username', password='password')
61
+ except Picnic2FARequired:
62
+ # Request a code via SMS or EMAIL
63
+ picnic.generate_2fa_code(channel="SMS")
64
+
65
+ code = input("Enter the code you received: ")
66
+ picnic.verify_2fa_code(code)
67
+ ```
68
+
69
+ After successful verification, the session is authenticated and you can use the API normally. If the code is invalid, `Picnic2FAError` is raised.
70
+
71
+ ## Typed models (2.x)
72
+
73
+ As of 2.x the API returns typed [pydantic](https://docs.pydantic.dev) models
74
+ instead of raw dicts. This covers both the "page" endpoints Picnic serves as a
75
+ layout tree of widgets (`search`, `get_article`, `get_category_by_ids`) and the
76
+ domain-JSON endpoints (`get_user`, `get_cart`, `get_delivery_slots`,
77
+ `get_delivery`, `get_deliveries` / `get_current_deliveries`, and the cart-mutation
78
+ methods). Every model exposes `.raw` with the original, untouched payload as an
79
+ escape hatch for data that isn't modelled yet, and `.model_dump()` for a
80
+ plain-dict view.
81
+
82
+ A couple of endpoints still return raw dicts: `get_delivery_scenario` and
83
+ `get_delivery_position` (only populated while a delivery is en route, so there is
84
+ no stable shape to model), and `get_article_category` (appears to have been
85
+ removed by Picnic — use `get_article(id, add_category=True)` instead).
86
+
87
+ If you are upgrading from 1.x, see the [migration notes](#migrating-from-1x-to-20).
88
+
89
+ ## Usage
90
+
91
+ ### Searching for an article
92
+
93
+ ```python
94
+ result = picnic.search('coffee') # -> SearchResult
95
+ result.items[0].name # 'Lavazza Caffè Crema e Aroma Bohnen'
96
+ result.items[0].display_price # 1799 (price shown on the tile, in cents)
97
+ result.items[0].raw # original tile payload
98
+ ```
99
+
100
+ Search tiles only carry `display_price` (the price shown, in integer cents) — the
101
+ raw payload has no separate `price` key — so read `display_price`.
102
+
103
+ ### Get article by ID
104
+
105
+ ```python
106
+ article = picnic.get_article("s1019822") # -> Article | None
107
+ article.id # 's1019822'
108
+ article.name # 'Lavazza Caffè Crema e Aroma Bohnen'
109
+ article.product_name # 'Caffè Crema e Aroma Bohnen'
110
+ article.producer # 'Lavazza' (None for unbranded produce)
111
+ article.unit_quantity # '1kg'
112
+ article.price_per_unit # '€17.99/kg' (comparative price, may be None)
113
+ article.price # 1799 (current price, integer cents)
114
+ article.original_price # 2249 when on sale, else None
115
+ article.image_id # hero product image id
116
+ article.description # product description (markdown)
117
+ article.highlights # ['Lange **haltbar**', ...] feature bullets
118
+ article.is_bundle # True for multipacks with other pack sizes
119
+ article.bundle_variant_ids # ['s1018999', ...] other pack-size article ids
120
+
121
+ # Optionally resolve the article's category (an extra request):
122
+ article = picnic.get_article("s1019822", add_category=True)
123
+ article.category.name # 'Koffiebonen'
124
+ ```
125
+
126
+ ### Get article by GTIN (EAN)
127
+
128
+ ```python
129
+ article = picnic.get_article_by_gtin("8000070025400") # -> Article | None
130
+ article.name # 'Lavazza Caffè Crema e Aroma Bohnen'
131
+ ```
132
+
133
+ ### Get the user
134
+
135
+ ```python
136
+ user = picnic.get_user() # -> User
137
+ user.contact_email # 'you@example.com'
138
+ user.address.city # 'Amsterdam'
139
+ user.total_deliveries # 25
140
+ ```
141
+
142
+ ### Check cart
143
+
144
+ ```python
145
+ cart = picnic.get_cart() # -> Cart
146
+ cart.total_count # 3
147
+ cart.total_price # 1234 (integer cents)
148
+ cart.items[0].items[0].name # 'Lavazza Caffè Crema e Aroma Bohnen'
149
+ cart.raw # original cart payload
150
+ ```
151
+
152
+ ### Manipulating your cart
153
+
154
+ All of these methods return the updated `Cart`.
155
+
156
+ ```python
157
+ # Add product with ID "s1019822" 2x
158
+ picnic.add_product("s1019822", 2)
159
+
160
+ # Remove product with ID "s1019822" 1x
161
+ picnic.remove_product("s1019822")
162
+
163
+ # Clear your cart
164
+ picnic.clear_cart()
165
+ ```
166
+
167
+ ### See upcoming deliveries
168
+
169
+ ```python
170
+ deliveries = picnic.get_current_deliveries() # -> list[DeliverySummary]
171
+ deliveries[0].delivery_id
172
+ deliveries[0].status # 'CURRENT'
173
+ deliveries[0].slot.window_start # '2025-04-29T17:15:00.000+02:00'
174
+
175
+ # Full detail (order lines, articles, payment info) for one delivery:
176
+ delivery = picnic.get_delivery(deliveries[0].delivery_id) # -> Delivery
177
+ delivery.orders[0].items[0].items[0].name
178
+ ```
179
+
180
+ ### See available delivery slots
181
+
182
+ ```python
183
+ slots = picnic.get_delivery_slots() # -> DeliverySlots
184
+ slots.delivery_slots[0].window_start # '2025-04-29T17:15:00.000+02:00'
185
+ slots.selected_slot.slot_id
186
+ ```
187
+
188
+ ## Migrating from 1.x to 2.0
189
+
190
+ - `search()` now returns a `SearchResult` (`.items` is a list of `SearchResultItem`)
191
+ instead of `[{"items": [...]}]`.
192
+ - `get_article()` / `get_article_by_gtin()` now return an `Article` (or `None`)
193
+ instead of a `dict`; use `.id` / `.name` / `.category` instead of key access.
194
+ - `get_category_by_ids()` now returns a `Category` instead of a `dict`.
195
+ - Missing/unexpected PML nodes now raise `PicnicParseError` (from
196
+ `python_picnic_api2`) instead of a bare `KeyError`.
197
+ - The domain-JSON methods now return typed models instead of raw dicts:
198
+ `get_user()` → `User`, `get_cart()` / `add_product()` / `remove_product()` /
199
+ `clear_cart()` → `Cart`, `get_delivery_slots()` → `DeliverySlots`,
200
+ `get_delivery()` → `Delivery`, and `get_deliveries()` /
201
+ `get_current_deliveries()` → `list[DeliverySummary]`. Use attribute access
202
+ (`cart.items`, `user.contact_email`) instead of `["items"]` / `["contact_email"]`.
203
+ - `get_delivery_scenario()`, `get_delivery_position()` and `get_article_category()`
204
+ still return raw dicts (see [Typed models](#typed-models-2x)).
205
+ - Any field you need that isn't modelled yet is available on `model.raw`.
@@ -0,0 +1,19 @@
1
+ python_picnic_api2/__init__.py,sha256=osxYdYiCQSEcxi-9WUKXcDVs54bAGctSaPQeukWy9V8,937
2
+ python_picnic_api2/client.py,sha256=x_OMRFe8x7SYinCdhyrxE_if3-kc7a5ndxWhRgL7sAg,10943
3
+ python_picnic_api2/exceptions.py,sha256=CZVj6qe6zF-ZAD7SphIwmG0fs-t9HE3aC-2TaAgInJ0,1058
4
+ python_picnic_api2/helper.py,sha256=CUoxRu2SZnHE-8azyfm7MUJ_vBA7ifVkHK-IUgUKuRM,971
5
+ python_picnic_api2/session.py,sha256=2nhlyJ2MXR1yHQRxw85B-KXF4zt8L5__KrI-T_VvURg,2388
6
+ python_picnic_api2/models/__init__.py,sha256=r9bwiAHOx9mhjizM7Cb3aTupOvTDXFQHkJEAUDdyLPo,922
7
+ python_picnic_api2/models/article.py,sha256=vxD1h2KLtXPnTxyV-dHzNxWFRNSVNVNc_GHgQJfDpK0,10745
8
+ python_picnic_api2/models/base.py,sha256=pQsS2uxXFBYUIn_qbpP_zvbL1p1Eteo68sLju40cef8,1573
9
+ python_picnic_api2/models/cart.py,sha256=tgBP4_UGTmbO9YLsLotrL8QtcuTxEFTrag9z89d3_CA,845
10
+ python_picnic_api2/models/category.py,sha256=gPzP9bBFfgtJ_8oAGfJP3HZbjJCKdL3nH8fgyGSZCvY,879
11
+ python_picnic_api2/models/common.py,sha256=y_DuqrrwALI81Jb4E60sEt-p2SwmWsKr2NlTnQsfPlA,3659
12
+ python_picnic_api2/models/delivery.py,sha256=i29cw3E_To3azBGtYKvYkKolRpWJypWxPqlRQoTl3DY,1425
13
+ python_picnic_api2/models/pml.py,sha256=1NAygk1u2SKBo-QwWMoeuZ4ixTJdDLHdnM7blYdgplM,5290
14
+ python_picnic_api2/models/search.py,sha256=kGJVXKUml2wFfDyap000inhe5udGO_EssxVji0FJ1f4,2150
15
+ python_picnic_api2/models/user.py,sha256=Q0qmnhYacCCx93UO_OrpHLdiE4VtCWsunRhJUmxgruY,1662
16
+ python_picnic_api2-2.0.1.dist-info/METADATA,sha256=8c078uiryhxbsskzRu9v_ZlY4IvVOI2_JGqpEPkMkrE,8646
17
+ python_picnic_api2-2.0.1.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
18
+ python_picnic_api2-2.0.1.dist-info/licenses/LICENSE.md,sha256=CUvt2ilcBwKAfRAnoA4RNPTLcdUj3En21LPK9YkFMGg,11358
19
+ python_picnic_api2-2.0.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.29.0
2
+ Generator: hatchling 1.31.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,95 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: python-picnic-api2
3
- Version: 1.3.4
4
- Project-URL: homepage, https://github.com/codesalatdev/python-picnic-api
5
- Project-URL: repository, https://github.com/codesalatdev/python-picnic-api
6
- Author-email: Mike Brink <mjh.brink@icloud.com>, CodeSalat <pypi@codesalat.dev>
7
- Maintainer-email: CodeSalat <pypi@codesalat.dev>
8
- License: Apache-2.0
9
- License-File: LICENSE.md
10
- Requires-Python: >=3.13
11
- Requires-Dist: requests>=2.24.0
12
- Requires-Dist: typing-extensions>=4.12.2
13
- Description-Content-Type: text/x-rst
14
-
15
- """""""""""""""""
16
- Python-Picnic-API
17
- """""""""""""""""
18
-
19
- .. image:: https://camo.githubusercontent.com/cd005dca0ef55d7725912ec03a936d3a7c8de5b5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275792532306d6525323061253230636f666665652d646f6e6174652d79656c6c6f772e737667
20
- :target: https://www.buymeacoffee.com/MikeBrink
21
- :alt: Buy me a coffee
22
-
23
- 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.
24
-
25
- This library is not affiliated with Picnic and retrieves data from the endpoints of the mobile application. Use at your own risk.
26
-
27
- .. _Picnic: https://picnic.app/nl/
28
-
29
- ===============
30
- Getting started
31
- ===============
32
- The easiest way to install is directly from pip::
33
-
34
- $ pip install python-picnic-api
35
-
36
-
37
- -----
38
- Usage
39
- -----
40
- I'll go over a few common operations here you'll most likely use in applications.
41
- To login:
42
-
43
- .. code-block:: python
44
-
45
- from python_picnic_api import PicnicAPI
46
-
47
- picnic = PicnicAPI(username='username', password='password', country_code="NL")
48
-
49
- The country_code parameter defaults to NL, but you have to change it if you live in a different country than the Netherlands (Germany: DE, Belgium: BE).
50
- You can also store your credentials by setting the store value to true, this will store your credentials and country_code in /config/app.yaml.
51
-
52
- Searching for a product
53
- -----------------------
54
- .. code-block:: python
55
-
56
- >>> picnic.search('coffee')
57
- [{'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': []}, ...
58
-
59
- Check cart
60
- ----------
61
- .. code-block:: python
62
-
63
- >>> picnic.get_cart()
64
- {'type': 'ORDER', 'id': 'shopping_cart', 'items': [], 'delivery_slots': [...
65
-
66
-
67
- Manipulating your cart
68
- ----------------------
69
- All of these methods will return the shopping cart.
70
-
71
- .. code-block:: python
72
-
73
- # adding 2 'Lavazza espresso koffiebonen' to cart
74
- picnic.add_product('10511523', count=2)
75
-
76
- # removing 1 'Lavazza espresso koffiebonen' from cart
77
- picnic.remove_product('10511523')
78
-
79
- # clearing the cart
80
- picnic.clear_cart()
81
-
82
- See upcoming deliveries
83
- ------------------------
84
- .. code-block:: python
85
-
86
- >>> picnic.get_current_deliveries()
87
- []
88
-
89
-
90
- See available delivery slots
91
- ----------------------------
92
- .. code-block:: python
93
-
94
- >>> picnic.get_delivery_slots()
95
-
@@ -1,8 +0,0 @@
1
- python_picnic_api2/__init__.py,sha256=_yT2GUMnhnNIGlYDzBxerDtlN08PzUOG00mhNCoPlGU,229
2
- python_picnic_api2/client.py,sha256=Bxp4WrABcGL7lheDsJRu0gSabq7AcTdsADGuikFL0bI,10804
3
- python_picnic_api2/helper.py,sha256=_cHhC1YCzZj7FlnR5tdvu825UOB5etcIdm23lezrw8Y,5022
4
- python_picnic_api2/session.py,sha256=2nhlyJ2MXR1yHQRxw85B-KXF4zt8L5__KrI-T_VvURg,2388
5
- python_picnic_api2-1.3.4.dist-info/METADATA,sha256=FOrKfeXQ9L110lcNOaX7oCHJvcquZyj4D3WrYyU-Y6c,3370
6
- python_picnic_api2-1.3.4.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
7
- python_picnic_api2-1.3.4.dist-info/licenses/LICENSE.md,sha256=CUvt2ilcBwKAfRAnoA4RNPTLcdUj3En21LPK9YkFMGg,11358
8
- python_picnic_api2-1.3.4.dist-info/RECORD,,