API Reference¶
CLI¶
pysainsburys.cli
¶
Command-line interface for pysainsburys.
Command groups mirror the library layout:
- :mod:
pysainsburys.cli.auth— authentication - :mod:
pysainsburys.cli.customer— customer profile - :mod:
pysainsburys.cli.basket— basket operations - :mod:
pysainsburys.cli.favourites— favourite products - :mod:
pysainsburys.cli.orders— order history and status - :mod:
pysainsburys.cli.slots— delivery and collection slots - :mod:
pysainsburys.cli.nectar— Nectar offers and Your Nectar Prices - :mod:
pysainsburys.cli.product— catalogue search and lookup - :mod:
pysainsburys.cli.store— stores and in-store product search
build_parser()
¶
Build the CLI argument parser.
Source code in pysainsburys/cli/__init__.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
default_session_path()
¶
Return the default session file path.
Source code in pysainsburys/cli/session.py
15 16 17 | |
main(argv=None)
¶
Run the CLI.
Source code in pysainsburys/cli/__init__.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
normalize_argv(argv)
¶
Move global flags in front of the subcommand so they parse in either position.
Source code in pysainsburys/cli/__init__.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
parse_args(argv=None)
¶
Parse CLI arguments, accepting global flags before or after the command.
Source code in pysainsburys/cli/__init__.py
125 126 127 128 129 | |
run_command(args)
async
¶
Dispatch a parsed command.
Source code in pysainsburys/cli/__init__.py
132 133 134 135 136 137 138 | |
Client¶
pysainsburys.Sainsburys
¶
Async client for Sainsbury's Groceries Online.
Wrap an authenticated :class:~pysainsburys.GOLAuth session to access
customer resources, or use the public catalogue methods without signing in.
Example
Authenticated session::
auth = await GOLAuth.from_session_file(
"~/.config/pysainsburys/session.json"
)
async with Sainsburys(auth) as client:
customer = await client.get_customer()
basket = await customer.basket.fetch()
Public catalogue lookup (no login required)::
async with Sainsburys(GOLAuth()) as client:
products = await client.search_products("bread")
product = await client.get_product("3236048")
Source code in pysainsburys/__init__.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | |
__aenter__()
async
¶
Enter async context manager.
Source code in pysainsburys/__init__.py
146 147 148 | |
__aexit__(*_args)
async
¶
Close the client on context exit.
Source code in pysainsburys/__init__.py
150 151 152 | |
__init__(authenticator)
¶
Initialize with an authenticated session.
Source code in pysainsburys/__init__.py
135 136 137 138 139 140 | |
__iter__()
¶
Allow dict(sainsburys) conversion.
Source code in pysainsburys/__init__.py
300 301 302 | |
close()
async
¶
Close the underlying HTTP session.
Source code in pysainsburys/__init__.py
142 143 144 | |
find_stores(latitude, longitude, *, page=1, page_size=20)
async
¶
Find stores near a latitude and longitude (no login required).
Source code in pysainsburys/__init__.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
find_stores_by_postcode(postcode, *, page_number=1)
async
¶
Find stores near a UK postcode with click-and-collect availability.
Source code in pysainsburys/__init__.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |
get_customer()
async
¶
Fetch and cache the authenticated customer profile.
Source code in pysainsburys/__init__.py
154 155 156 157 158 159 160 161 | |
get_product(product_uid)
async
¶
Fetch a single product by uid (no login required).
Source code in pysainsburys/__init__.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
get_store(store_id)
async
¶
Fetch a single store by Product Finder store id.
Source code in pysainsburys/__init__.py
226 227 228 229 230 231 232 233 234 | |
register_callback(callback)
¶
Register a callback to be called when data is updated.
Source code in pysainsburys/__init__.py
274 275 276 277 278 | |
remove_callback(callback)
¶
Remove a registered callback.
Source code in pysainsburys/__init__.py
280 281 282 283 | |
search_products(keyword, *, page_number=1, page_size=24)
async
¶
Search products by keyword (no login required).
Source code in pysainsburys/__init__.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
to_dict()
¶
Return the Sainsburys object data as a dictionary.
Source code in pysainsburys/__init__.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 | |
update()
async
¶
Refresh commonly used cached data.
Source code in pysainsburys/__init__.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
pysainsburys.GOLAuth
¶
Represent an authenticated Sainsbury's GOL session.
Source code in pysainsburys/auth.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 | |
authenticated_headers
property
¶
Return authenticated headers for grocery API calls.
authorization_endpoint
property
¶
Return the OAuth authorization endpoint URL.
public_headers
property
¶
Return headers for unauthenticated grocery API requests.
refresh_token
property
¶
Return the OAuth refresh token.
session
property
¶
Return the aiohttp session, creating one when needed.
token_endpoint
property
¶
Return the OAuth token endpoint URL.
__aenter__()
async
¶
Enter async context manager.
Source code in pysainsburys/auth.py
320 321 322 | |
__aexit__(*_args)
async
¶
Close the auth session on context exit.
Source code in pysainsburys/auth.py
324 325 326 | |
__iter__()
¶
Allow dict(auth) conversion.
Source code in pysainsburys/auth.py
306 307 308 | |
build_authorization_url()
¶
Build a PKCE authorization URL for browser-based login.
Source code in pysainsburys/auth.py
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
close()
async
¶
Close the underlying HTTP session when owned by this object.
Source code in pysainsburys/auth.py
310 311 312 313 314 315 316 317 318 | |
exchange_authorization_code(code)
async
¶
Exchange an authorization code for OAuth tokens.
Source code in pysainsburys/auth.py
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 | |
exchange_commerce_session(*, food_profile_create=True)
async
¶
Exchange the OAuth access token for WC commerce session tokens.
Source code in pysainsburys/auth.py
796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 | |
fetch_oidc_configuration()
async
¶
Fetch OIDC discovery metadata using browser-like headers.
Source code in pysainsburys/auth.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | |
finish_login(redirect_or_code, *, expected_state=None, exchange_commerce=True)
async
¶
Complete browser login from a redirect URL or raw authorization code.
Source code in pysainsburys/auth.py
591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 | |
from_dict(data)
classmethod
¶
Create an auth object from a serialized session mapping.
Source code in pysainsburys/auth.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
from_pending_login_dict(data)
classmethod
¶
Restore in-progress login state from a mapping.
Source code in pysainsburys/auth.py
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | |
from_pending_login_file(path)
async
classmethod
¶
Load in-progress login state from disk.
Source code in pysainsburys/auth.py
296 297 298 299 | |
from_session_file(path)
async
classmethod
¶
Load a session export created by tooling or a previous to_dict().
Source code in pysainsburys/auth.py
180 181 182 183 | |
login(username=None, password=None, *, mfa_code=None, io_black_box=None, exchange_commerce=True)
async
¶
Sign in via web credentials or start interactive browser login.
Source code in pysainsburys/auth.py
707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 | |
pending_login_to_dict()
¶
Return in-progress login state for MFA completion.
Source code in pysainsburys/auth.py
261 262 263 264 265 266 267 268 269 270 | |
refresh_commerce_session(*, food_profile_create=True)
async
¶
Re-exchange OAuth tokens for a fresh commerce session.
Source code in pysainsburys/auth.py
845 846 847 848 849 850 851 852 853 | |
request_mfa_code()
async
¶
Request delivery of an MFA verification code.
Source code in pysainsburys/auth.py
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 | |
save_pending_login(path)
async
¶
Persist in-progress login state awaiting MFA verification.
Source code in pysainsburys/auth.py
292 293 294 | |
save_session_file(path)
async
¶
Persist the current session to disk.
Source code in pysainsburys/auth.py
256 257 258 259 | |
send_credentials(username, password, *, io_black_box=None)
async
¶
Submit username and password to the web identity login form.
Source code in pysainsburys/auth.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 | |
send_login_request()
async
¶
Prepare browser login and return the authorization URL.
Source code in pysainsburys/auth.py
546 547 548 549 | |
send_mfa_request(code, *, io_black_box=None, exchange_commerce=True)
async
¶
Submit an MFA verification code and complete OAuth token exchange.
Source code in pysainsburys/auth.py
676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 | |
send_public_request(method, url, *, headers=None, params=None)
async
¶
Send a request that does not require a commerce session.
Source code in pysainsburys/auth.py
945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 | |
send_refresh_request()
async
¶
Refresh the OAuth access token when a refresh token is available.
Source code in pysainsburys/auth.py
744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 | |
send_request(method, url, body=None, *, headers=None, params=None)
async
¶
Send a request to the API and return the JSON response.
Source code in pysainsburys/auth.py
855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 | |
to_dict()
¶
Return the session as a JSON-serializable mapping.
Source code in pysainsburys/auth.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |
pysainsburys.API
¶
API handler for Sainsbury's GOL.
Source code in pysainsburys/api.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
user_id
property
¶
Return the commerce user id when known.
__iter__()
¶
Allow dict(api) conversion.
Source code in pysainsburys/api.py
140 141 142 | |
close()
async
¶
Close the underlying HTTP session.
Source code in pysainsburys/api.py
125 126 127 | |
exchange_commerce_session(*, food_profile_create=True)
async
¶
Exchange OAuth tokens for a commerce session.
Source code in pysainsburys/api.py
91 92 93 94 95 96 97 98 99 | |
finish_login(redirect_or_code, *, exchange_commerce=True)
async
¶
Complete browser login from a redirect URL or authorization code.
Source code in pysainsburys/api.py
109 110 111 112 113 114 115 116 117 118 119 | |
login()
async
¶
Prepare browser login and return the authorization URL.
Source code in pysainsburys/api.py
105 106 107 | |
logout()
async
¶
End the remote commerce session.
Source code in pysainsburys/api.py
121 122 123 | |
send_product_finder_request(path, *, params=None)
async
¶
Send a public request to the Product Finder API.
Source code in pysainsburys/api.py
77 78 79 80 81 82 83 84 85 86 87 88 89 | |
send_public_request(endpoint, *, params=None, **path_params)
async
¶
Send a request that does not require a commerce session.
Source code in pysainsburys/api.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
send_request(endpoint, body=None, *, params=None, headers=None, **path_params)
async
¶
Send a request to the API using the authentication handler.
Source code in pysainsburys/api.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
to_dict()
¶
Return the API object data as a dictionary.
Source code in pysainsburys/api.py
129 130 131 132 133 134 135 136 137 138 | |
token_refresh()
async
¶
Force OAuth token refresh.
Source code in pysainsburys/api.py
101 102 103 | |
Models¶
pysainsburys.models
¶
Domain models for the Sainsbury's Groceries Online API.
Models are grouped by business domain:
- :mod:
pysainsburys.models.common— shared value types and pagination - :mod:
pysainsburys.models.product— products, detail sections, and nutrition - :mod:
pysainsburys.models.basket— basket line items and totals - :mod:
pysainsburys.models.customer— authenticated customer profile - :mod:
pysainsburys.models.order— order history and status - :mod:
pysainsburys.models.store— stores and in-store product search - :mod:
pysainsburys.models.nectar— Nectar offers and Your Nectar Prices
Import from this package for a stable, organised surface::
from pysainsburys.models import Product, Basket, Customer
AverageWeight
dataclass
¶
Typical weight for a loose product.
Source code in pysainsburys/models/product/catalogue.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
from_dict(data)
classmethod
¶
Parse an average weight from grocery API JSON.
Source code in pysainsburys/models/product/catalogue.py
210 211 212 213 214 215 | |
to_dict()
¶
Serialise the average weight to a plain dictionary.
Source code in pysainsburys/models/product/catalogue.py
217 218 219 | |
Basket
dataclass
¶
The authenticated customer's grocery basket.
Attributes:
| Name | Type | Description |
|---|---|---|
basket_id |
str | None
|
Basket identifier assigned by the commerce platform. |
order_id |
str | None
|
Associated order id when amending an existing order. |
subtotal_price |
float
|
Sum of item prices before delivery and savings. |
total_price |
float
|
Basket total including fees where calculated. |
slot_price |
float
|
Delivery or collection slot charge when applicable. |
savings |
float
|
Promotional savings applied to the basket. |
nectar_savings |
float
|
Nectar-specific savings when applicable. |
item_count |
int
|
Number of distinct line items. |
minimum_spend |
int
|
Minimum order value required for checkout. |
delivery_instructions |
str | None
|
Customer delivery note when set. |
is_in_amend_mode |
bool
|
Whether the basket is amending a placed order. |
slot_type |
str | None
|
Reserved slot type string from the API. |
has_exceeded_minimum_spend |
bool
|
Whether the minimum spend threshold is met. |
items |
list[BasketItem]
|
Line items currently in the basket. |
Source code in pysainsburys/models/basket/basket.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
is_empty
property
¶
Return True when the basket contains no items.
__iter__()
¶
Allow dict(basket) conversion.
Source code in pysainsburys/models/basket/basket.py
173 174 175 | |
from_dict(data)
classmethod
¶
Parse a basket from grocery API JSON.
Source code in pysainsburys/models/basket/basket.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
to_dict()
¶
Serialise the basket to a plain dictionary.
Source code in pysainsburys/models/basket/basket.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
BasketItem
dataclass
¶
A single line item in the grocery basket.
Attributes:
| Name | Type | Description |
|---|---|---|
product_uid |
str
|
Catalogue identifier for the product. |
quantity |
float
|
Number of units in the basket. |
name |
str | None
|
Display name when returned by the basket endpoint. |
item_uid |
str | None
|
Basket line identifier used for updates and removals. |
subtotal |
float | None
|
Line total in pounds sterling. |
unit_price |
Price | None
|
Price per unit when provided by the API. |
product_data |
dict[str, Any] | None
|
Nested product JSON when included in the basket response.
Use :meth: |
Source code in pysainsburys/models/basket/basket.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
from_dict(data)
classmethod
¶
Parse a basket item from grocery API JSON.
Source code in pysainsburys/models/basket/basket.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
to_dict()
¶
Serialise the basket item to a plain dictionary.
Source code in pysainsburys/models/basket/basket.py
76 77 78 79 80 81 82 83 84 85 86 | |
Customer
dataclass
¶
Authenticated Sainsbury's Groceries Online customer profile.
A customer is returned by :meth:~pysainsburys.Sainsburys.get_customer and
exposes convenience accessors for basket, favourites, orders, and slot
resources when bound to a client.
Attributes:
| Name | Type | Description |
|---|---|---|
user_id |
str
|
Commerce platform user identifier. |
customer_id |
str | None
|
Customer record identifier when distinct from |
identity_id |
str | None
|
Identity provider subject identifier. |
email |
str | None
|
Account email address. |
family_name |
str | None
|
Family name from the profile. |
given_name |
str | None
|
Given name from the profile. |
primary_phone |
str | None
|
Primary contact telephone number. |
postcode |
str | None
|
Default delivery postcode when set. |
title |
str | None
|
Salutation or title when provided. |
is_very_important_customer |
bool
|
VIP flag from the API. |
delivery_pass_expiry_date |
str | None
|
Delivery pass expiry when subscribed. |
personalization_id |
str | None
|
Personalisation token for recommendations. |
has_nectar_associated |
bool
|
Whether a Nectar card is associated. |
has_nectar_linked |
bool
|
Whether Nectar is fully linked for rewards. |
is_digital_nectar |
bool
|
Whether the account uses digital Nectar. |
Source code in pysainsburys/models/customer/customer.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
basket
property
¶
Basket fetch and clear helpers for this customer.
display_name
property
¶
Return a human-friendly display name.
favourites
property
¶
Favourites list and add/remove helpers for this customer.
nectar
property
¶
Nectar bonus offers and Your Nectar Price helpers.
orders
property
¶
Order history, latest order, and per-order status.
slots
property
¶
Delivery and collection slot listing helpers.
__iter__()
¶
Allow dict(customer) conversion.
Source code in pysainsburys/models/customer/customer.py
184 185 186 | |
from_dict(data, *, api=None)
classmethod
¶
Parse a customer profile from grocery API JSON.
Source code in pysainsburys/models/customer/customer.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
to_dict()
¶
Serialise the customer profile to a plain dictionary.
Source code in pysainsburys/models/customer/customer.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
DeliverySlot
dataclass
¶
A single bookable delivery or collection time window.
Attributes:
| Name | Type | Description |
|---|---|---|
slot_uid |
str | None
|
Stable slot identifier from the API when provided. |
start_time |
str | None
|
Slot start timestamp (ISO-8601). |
end_time |
str | None
|
Slot end timestamp (ISO-8601). |
price |
float | None
|
Customer-facing slot price in pounds sterling. |
unqualified_price |
float | None
|
List price before delivery-pass or promotions. |
is_available |
bool
|
Whether the slot can be booked. |
status |
str | None
|
Raw availability status string from the API. |
slot_type |
str | None
|
Delivery or collection type when returned per slot. |
Source code in pysainsburys/models/slot/slot.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
__iter__()
¶
Allow dict(slot) conversion.
Source code in pysainsburys/models/slot/slot.py
94 95 96 | |
from_dict(data)
classmethod
¶
Parse a slot entry from grocery API JSON.
Source code in pysainsburys/models/slot/slot.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
to_dict()
¶
Serialise the slot to a plain dictionary.
Source code in pysainsburys/models/slot/slot.py
81 82 83 84 85 86 87 88 89 90 91 92 | |
FinderPage
dataclass
¶
Pagination metadata from the Product Finder API.
Attributes:
| Name | Type | Description |
|---|---|---|
size |
int
|
Page size requested. |
number |
int
|
Zero-based page index returned by Product Finder. |
total_elements |
int
|
Total matching elements across all pages. |
total_pages |
int
|
Total number of pages available. |
Source code in pysainsburys/models/store/store.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
from_dict(data)
classmethod
¶
Parse Product Finder pagination JSON.
Source code in pysainsburys/models/store/store.py
34 35 36 37 38 39 40 41 42 43 | |
to_dict()
¶
Serialise pagination metadata to a plain dictionary.
Source code in pysainsburys/models/store/store.py
45 46 47 48 49 50 51 52 | |
HfssRestriction
dataclass
¶
HFSS advertising restriction for one UK nation.
Source code in pysainsburys/models/product/catalogue.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
from_dict(data)
classmethod
¶
Parse an HFSS restriction from grocery API JSON.
Source code in pysainsburys/models/product/catalogue.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
to_dict()
¶
Serialise the HFSS restriction to a plain dictionary.
Source code in pysainsburys/models/product/catalogue.py
248 249 250 251 252 253 254 255 256 | |
LocationContext
dataclass
¶
Location context used when listing slots.
Source code in pysainsburys/models/slot/slot.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | |
__iter__()
¶
Allow dict(location_context) conversion.
Source code in pysainsburys/models/slot/slot.py
314 315 316 | |
from_dict(data)
classmethod
¶
Parse location context JSON.
Source code in pysainsburys/models/slot/slot.py
291 292 293 294 295 296 297 298 299 300 301 | |
to_dict()
¶
Serialise location context to a plain dictionary.
Source code in pysainsburys/models/slot/slot.py
303 304 305 306 307 308 309 310 311 312 | |
NectarOffer
dataclass
¶
A personalised Nectar bonus-points offer.
Attributes:
| Name | Type | Description |
|---|---|---|
offer_id |
str
|
Offer identifier from the Nectar API. |
title |
str
|
Short offer headline. |
subtitle |
str
|
Supporting offer copy. |
points |
int
|
Bonus Nectar points awarded. |
skus |
list[str]
|
Product SKUs included in the offer. |
expires |
str | None
|
Offer expiry timestamp when provided. |
Source code in pysainsburys/models/nectar/nectar.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
from_dict(data)
classmethod
¶
Parse a Nectar offer from grocery API JSON.
Source code in pysainsburys/models/nectar/nectar.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
to_dict()
¶
Serialise the offer to a plain dictionary.
Source code in pysainsburys/models/nectar/nectar.py
49 50 51 52 53 54 55 56 57 58 | |
NectarOffers
dataclass
¶
Nectar bonus-point offers for the signed-in customer.
Attributes:
| Name | Type | Description |
|---|---|---|
account_status |
str | None
|
Nectar linkage status from the API. |
offers |
list[NectarOffer]
|
Active bonus-point offers. |
Source code in pysainsburys/models/nectar/nectar.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
__iter__()
¶
Allow dict(offers) conversion.
Source code in pysainsburys/models/nectar/nectar.py
95 96 97 | |
from_dict(data)
classmethod
¶
Parse Nectar offers from grocery API JSON.
Source code in pysainsburys/models/nectar/nectar.py
75 76 77 78 79 80 81 82 83 84 85 86 | |
to_dict()
¶
Serialise the offers response to a plain dictionary.
Source code in pysainsburys/models/nectar/nectar.py
88 89 90 91 92 93 | |
NectarPrice
dataclass
¶
Nectar member price for a product.
Attributes:
| Name | Type | Description |
|---|---|---|
retail_price |
float
|
Nectar price for the purchasable quantity. |
unit_price |
float | None
|
Nectar price per unit of measure, when provided. |
measure |
str | None
|
Unit label for |
url |
str | None
|
Link to the Nectar prices listing. |
category_seo_url |
str | None
|
SEO path for the Nectar prices category. |
Source code in pysainsburys/models/product/product.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
from_dict(data)
classmethod
¶
Parse a Nectar price from grocery API JSON.
Source code in pysainsburys/models/product/product.py
175 176 177 178 179 180 181 182 183 184 185 186 187 | |
to_dict()
¶
Serialise the Nectar price to a plain dictionary.
Source code in pysainsburys/models/product/product.py
189 190 191 192 193 194 195 196 197 | |
NectarSearchHit
dataclass
¶
A single Nectar search result.
Source code in pysainsburys/models/nectar/nectar.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
to_dict()
¶
Serialise the search hit to a plain dictionary.
Source code in pysainsburys/models/nectar/nectar.py
245 246 247 248 249 250 251 252 253 254 255 256 257 | |
NectarSearchResults
dataclass
¶
Keyword search results across Nectar offers and Your Nectar Prices.
Source code in pysainsburys/models/nectar/nectar.py
260 261 262 263 264 265 266 267 268 269 270 271 272 | |
to_dict()
¶
Serialise search results to a plain dictionary.
Source code in pysainsburys/models/nectar/nectar.py
267 268 269 270 271 272 | |
NutrientSummary
dataclass
¶
Traffic-light style nutrition summary for a single nutrient.
Source code in pysainsburys/models/product/nutrition.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
to_dict()
¶
Return the nutrient summary as a dictionary.
Source code in pysainsburys/models/product/nutrition.py
59 60 61 62 63 64 65 66 | |
NutritionInfo
dataclass
¶
Parsed nutrition information for a product.
Source code in pysainsburys/models/product/nutrition.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
to_dict()
¶
Return nutrition information as a dictionary.
Source code in pysainsburys/models/product/nutrition.py
109 110 111 112 113 114 115 | |
NutritionTable
dataclass
¶
A nutrition facts table from a product detail page.
Source code in pysainsburys/models/product/nutrition.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
to_dict()
¶
Return the nutrition table as a dictionary.
Source code in pysainsburys/models/product/nutrition.py
92 93 94 95 96 97 98 | |
NutritionTableRow
dataclass
¶
A single row in a nutrition facts table.
Source code in pysainsburys/models/product/nutrition.py
69 70 71 72 73 74 75 76 77 78 79 80 81 | |
to_dict()
¶
Return the table row as a dictionary.
Source code in pysainsburys/models/product/nutrition.py
76 77 78 79 80 81 | |
OrderList
dataclass
¶
A paginated list of customer orders.
Source code in pysainsburys/models/order/order.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
__iter__()
¶
Allow dict(order_list) conversion.
Source code in pysainsburys/models/order/order.py
84 85 86 | |
from_dict(data)
classmethod
¶
Parse an order list from grocery API JSON.
Source code in pysainsburys/models/order/order.py
69 70 71 72 73 74 75 | |
to_dict()
¶
Serialise the order list to a plain dictionary.
Source code in pysainsburys/models/order/order.py
77 78 79 80 81 82 | |
OrderStatus
dataclass
¶
Live status for the customer's active order slot.
Attributes:
| Name | Type | Description |
|---|---|---|
order_uid |
str | None
|
Identifier for the active order. |
is_cutoff |
bool
|
Whether the amend cutoff has passed. |
is_in_amend_mode |
bool
|
Whether the order can still be amended. |
cutoff_time |
str | None
|
Amend cutoff timestamp when provided. |
slot_end_time |
str | None
|
Reserved slot end timestamp. |
slot_start_time |
str | None
|
Reserved slot start timestamp. |
order_type |
str | None
|
Delivery or collection type string. |
total |
float
|
Current order total in pounds sterling. |
failed_payments |
list[dict[str, Any]]
|
Payment failure payloads from the API. |
Source code in pysainsburys/models/order/order.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
__iter__()
¶
Allow dict(order_status) conversion.
Source code in pysainsburys/models/order/order.py
146 147 148 | |
from_dict(data)
classmethod
¶
Parse order status from grocery API JSON.
Source code in pysainsburys/models/order/order.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
to_dict()
¶
Serialise order status to a plain dictionary.
Source code in pysainsburys/models/order/order.py
132 133 134 135 136 137 138 139 140 141 142 143 144 | |
OrderSummary
dataclass
¶
Summary information for a past or active order.
Attributes:
| Name | Type | Description |
|---|---|---|
order_id |
str
|
Primary order identifier used in URLs and APIs. |
order_uid |
str | None
|
Alternate order uid when returned separately. |
status |
str | None
|
Human-readable order status string. |
total |
float | None
|
Order total in pounds sterling. |
slot_start_time |
str | None
|
Reserved slot start timestamp. |
slot_end_time |
str | None
|
Reserved slot end timestamp. |
slot_type |
str | None
|
Delivery or collection slot type. |
Source code in pysainsburys/models/order/order.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
from_dict(data)
classmethod
¶
Parse an order summary from grocery API JSON.
Source code in pysainsburys/models/order/order.py
36 37 38 39 40 41 42 43 44 45 46 47 | |
to_dict()
¶
Serialise the order summary to a plain dictionary.
Source code in pysainsburys/models/order/order.py
49 50 51 52 53 54 55 56 57 58 59 | |
PageControls
dataclass
¶
Pagination metadata returned by grocery list endpoints.
Attributes:
| Name | Type | Description |
|---|---|---|
total_record_count |
int
|
Total items available across all pages. |
returned_record_count |
int
|
Items included in the current response. |
active_page |
int
|
One-based index of the current page. |
first_page |
int
|
One-based index of the first page. |
last_page |
int
|
One-based index of the last page. |
page_size |
int
|
Requested page size. |
Source code in pysainsburys/models/common/pagination.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
from_dict(data)
classmethod
¶
Parse pagination controls from grocery API JSON.
Source code in pysainsburys/models/common/pagination.py
31 32 33 34 35 36 37 38 39 40 41 42 43 | |
to_dict()
¶
Serialise pagination controls to a plain dictionary.
Source code in pysainsburys/models/common/pagination.py
45 46 47 48 49 50 51 52 53 54 | |
Price
dataclass
¶
A monetary amount with an optional unit of measure.
Attributes:
| Name | Type | Description |
|---|---|---|
price |
float
|
Amount in pounds sterling. |
measure |
str | None
|
Unit label returned by the API (for example |
measure_amount |
float | None
|
Quantity associated with |
Source code in pysainsburys/models/common/price.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
from_dict(data)
classmethod
¶
Parse a price object from grocery API JSON.
Source code in pysainsburys/models/common/price.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
to_dict()
¶
Serialise the price to a plain dictionary.
Source code in pysainsburys/models/common/price.py
40 41 42 43 44 45 46 | |
Product
dataclass
¶
A grocery product from the online catalogue.
When bound to a :class:~pysainsburys.Sainsburys client, a product can
mutate the authenticated customer's basket directly via
:meth:add_to_basket, :meth:set_basket_quantity, and
:meth:remove_from_basket.
Nutrition data is parsed automatically from details_html when present
on the API response (see :attr:nutrition). The same HTML also supplies
description, storage, and related copy on :attr:details. Search results
omit details_html, so those sections stay empty until the product is
loaded with :meth:~pysainsburys.Sainsburys.get_product.
Attributes:
| Name | Type | Description |
|---|---|---|
product_uid |
str
|
Stable Sainsbury's product identifier. |
name |
str
|
Display name shown on the website and app. |
sain_id |
str | None
|
Legacy SAIN identifier when returned by the API. |
is_favourite |
bool
|
Whether the product is in the signed-in customer's favourites list. |
favourite_type |
str | None
|
Favourite list type when provided by the API. |
product_type |
str | None
|
Product classification string from the API. |
eans |
list[str]
|
European article numbers associated with the product. |
unit_price |
Price | None
|
Price per unit of measure, when available. |
retail_price |
Price | None
|
Shelf price for the purchasable quantity. |
is_available |
bool
|
Whether the product can be added to a basket. |
is_alcoholic |
bool
|
Whether age-restricted checks apply. |
reviews |
ProductReviews | None
|
Aggregated review metadata. |
image_url |
str | None
|
Product listing image URL. |
nutrition |
NutritionInfo | None
|
Parsed nutrition tables and traffic-light summary. |
details |
ProductDetails | None
|
Description, storage, and other product-text sections. |
promotions |
list[Promotion]
|
Catalogue offers attached to the product. |
nectar_price |
NectarPrice | None
|
Nectar member price when the product has one. |
favourite_uid |
str | None
|
Favourite-list identifier when the product is saved. |
short_description |
str | None
|
One-line summary from the product payload. |
full_url |
str | None
|
Absolute product page URL. |
original_unit_price |
Price | None
|
Unit price before a promotion, when the API returns one. |
image |
str | None
|
Large product image URL. |
image_thumbnail |
str | None
|
Medium product image URL. |
image_thumbnail_small |
str | None
|
Small product image URL. |
image_zoom |
str | None
|
Zoom image URL when provided. |
images |
list[ProductImage]
|
Sized image variants from the assets block. |
zone |
str | None
|
Merchandising zone, such as |
department |
str | None
|
Department name when the API returns one. |
labels |
list[ProductLabel]
|
Merchandising labels such as British or Chilled. |
categories |
list[ProductCategory]
|
Catalogue categories that include the product. |
breadcrumbs |
list[ProductBreadcrumb]
|
Breadcrumb trail for the product page. |
attributes |
dict[str, list[str]]
|
Attribute groups from the API, including brand. |
header |
ProductHeader | None
|
Promotional header, such as a Nectar price banner. |
is_spotlight |
bool
|
Whether the product is flagged as featured. |
spotlight_label |
str | None
|
Featured label when |
not_for_eu |
bool
|
Whether the product is marked not for EU sale. |
is_intolerant |
bool
|
Whether the product carries an intolerance flag. |
is_mhra |
bool
|
Whether MHRA restrictions apply. |
is_supply_chain_orderable |
bool
|
Whether supply-chain ordering is enabled. |
display_icons |
list[str]
|
Icon identifiers shown on the product. |
health_rating |
str | None
|
Health rating score from |
hfss_restrictions |
list[HfssRestriction]
|
HFSS advertising restrictions by UK nation. |
pdp_deep_link |
str | None
|
Legacy product-display path. |
average_weight |
AverageWeight | None
|
Typical weight for a loose product. |
promise |
ProductPromise | None
|
Delivery promise when a slot context is present. |
Source code in pysainsburys/models/product/product.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
brand
property
¶
Brand names from the product attributes.
__iter__()
¶
Allow dict(product) conversion.
Source code in pysainsburys/models/product/product.py
581 582 583 | |
add_to_basket(quantity=1.0, *, selected_catchweight=None, uom=None)
async
¶
Add this product to the basket (POST increment).
Source code in pysainsburys/models/product/product.py
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 | |
bind_api(api)
¶
Attach a client for basket and favourites operations.
Source code in pysainsburys/models/product/product.py
430 431 432 433 | |
from_basket_nested(data, *, api=None)
classmethod
¶
Parse a product object nested inside a basket line item.
Source code in pysainsburys/models/product/product.py
408 409 410 411 412 413 414 415 416 417 418 419 | |
from_dict(data, *, api=None)
classmethod
¶
Parse a product from grocery API JSON.
Source code in pysainsburys/models/product/product.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
remove_from_basket(*, item_uid=None, force_delete=False)
async
¶
Remove this product from the basket.
Source code in pysainsburys/models/product/product.py
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | |
set_basket_quantity(quantity, *, item_uid=None, selected_catchweight=None, uom=None)
async
¶
Set the absolute basket quantity for this product.
Source code in pysainsburys/models/product/product.py
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 | |
to_dict()
¶
Serialise the product to a plain dictionary.
Source code in pysainsburys/models/product/product.py
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 | |
ProductBreadcrumb
dataclass
¶
One step in the product page breadcrumb trail.
Source code in pysainsburys/models/product/catalogue.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
from_dict(data)
classmethod
¶
Parse a breadcrumb from grocery API JSON.
Source code in pysainsburys/models/product/catalogue.py
108 109 110 111 112 113 114 115 116 | |
to_dict()
¶
Serialise the breadcrumb to a plain dictionary.
Source code in pysainsburys/models/product/catalogue.py
118 119 120 | |
ProductCategory
dataclass
¶
A catalogue category the product belongs to.
Source code in pysainsburys/models/product/catalogue.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
from_dict(data)
classmethod
¶
Parse a category from grocery API JSON.
Source code in pysainsburys/models/product/catalogue.py
85 86 87 88 89 90 91 92 93 94 | |
to_dict()
¶
Serialise the category to a plain dictionary.
Source code in pysainsburys/models/product/catalogue.py
96 97 98 | |
ProductDetails
dataclass
¶
Catalogue copy parsed from a product detail page.
Each field is a list of paragraphs. A heading the page does not include
is None.
Attributes:
| Name | Type | Description |
|---|---|---|
description |
list[str] | None
|
Product description paragraphs. |
storage |
list[str] | None
|
Storage instructions. |
dietary_information |
list[str] | None
|
Dietary and allergen statements. |
ingredients |
list[str] | None
|
Ingredient list paragraphs. |
manufacturer |
list[str] | None
|
Manufacturer or packer details. |
preparation |
list[str] | None
|
Preparation or serving instructions. |
country_of_origin |
list[str] | None
|
Origin or packing-country statements. |
packaging |
list[str] | None
|
Packaging description. |
Source code in pysainsburys/models/product/details.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
from_dict(data)
classmethod
¶
Parse product detail sections from a serialised mapping.
Source code in pysainsburys/models/product/details.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
is_empty()
¶
Return whether every section is missing.
Source code in pysainsburys/models/product/details.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
to_dict()
¶
Serialise the detail sections to a plain dictionary.
Source code in pysainsburys/models/product/details.py
107 108 109 110 111 112 113 114 115 116 117 118 | |
ProductHeader
dataclass
¶
Promotional header shown above the product, such as a Nectar price.
Source code in pysainsburys/models/product/catalogue.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
from_dict(data)
classmethod
¶
Parse a product header from grocery API JSON.
Source code in pysainsburys/models/product/catalogue.py
130 131 132 133 134 135 136 137 138 139 | |
to_dict()
¶
Serialise the header to a plain dictionary.
Source code in pysainsburys/models/product/catalogue.py
141 142 143 | |
ProductImage
dataclass
¶
A product image and the sizes the API provides for it.
Source code in pysainsburys/models/product/catalogue.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
from_dict(data)
classmethod
¶
Parse a product image from grocery API JSON.
Source code in pysainsburys/models/product/catalogue.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
to_dict()
¶
Serialise the product image to a plain dictionary.
Source code in pysainsburys/models/product/catalogue.py
195 196 197 198 199 200 | |
ProductImageSize
dataclass
¶
One rendered size of a product image.
Source code in pysainsburys/models/product/catalogue.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
from_dict(data)
classmethod
¶
Parse an image size from grocery API JSON.
Source code in pysainsburys/models/product/catalogue.py
154 155 156 157 158 159 160 161 162 163 164 165 166 | |
to_dict()
¶
Serialise the image size to a plain dictionary.
Source code in pysainsburys/models/product/catalogue.py
168 169 170 | |
ProductLabel
dataclass
¶
A merchandising label such as British or Chilled.
Source code in pysainsburys/models/product/catalogue.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
from_dict(data)
classmethod
¶
Parse a label from grocery API JSON.
Source code in pysainsburys/models/product/catalogue.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
to_dict()
¶
Serialise the label to a plain dictionary.
Source code in pysainsburys/models/product/catalogue.py
66 67 68 69 70 71 72 73 74 75 | |
ProductList
dataclass
¶
A paginated list of catalogue products.
Source code in pysainsburys/models/product/product.py
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 | |
__iter__()
¶
Allow dict(product_list) conversion.
Source code in pysainsburys/models/product/product.py
609 610 611 | |
from_dict(data)
classmethod
¶
Parse a paginated product list from grocery API JSON.
Source code in pysainsburys/models/product/product.py
593 594 595 596 597 598 599 600 | |
to_dict()
¶
Serialise the product list to a plain dictionary.
Source code in pysainsburys/models/product/product.py
602 603 604 605 606 607 | |
ProductPromise
dataclass
¶
Delivery promise attached to a product when a slot context exists.
Source code in pysainsburys/models/product/catalogue.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
from_dict(data)
classmethod
¶
Parse a product promise from grocery API JSON.
Source code in pysainsburys/models/product/catalogue.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
is_empty()
¶
Return whether the promise carries no slot information.
Source code in pysainsburys/models/product/catalogue.py
289 290 291 292 293 294 295 296 297 298 299 300 | |
to_dict()
¶
Serialise the promise to a plain dictionary.
Source code in pysainsburys/models/product/catalogue.py
302 303 304 305 306 307 308 309 310 | |
ProductReviews
dataclass
¶
Aggregated review metadata for a product.
Attributes:
| Name | Type | Description |
|---|---|---|
is_enabled |
bool
|
Whether reviews are shown for this product. |
product_uid |
str | None
|
Product identifier referenced by the review service. |
total |
int
|
Number of published reviews. |
average_rating |
float
|
Mean star rating across reviews. |
Source code in pysainsburys/models/product/product.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
from_dict(data)
classmethod
¶
Parse review metadata from grocery API JSON.
Source code in pysainsburys/models/product/product.py
58 59 60 61 62 63 64 65 66 67 68 | |
to_dict()
¶
Serialise review metadata to a plain dictionary.
Source code in pysainsburys/models/product/product.py
70 71 72 73 74 75 76 77 | |
Promotion
dataclass
¶
A catalogue promotion attached to a product.
Attributes:
| Name | Type | Description |
|---|---|---|
promotion_uid |
str
|
Promotion identifier. |
strap_line |
str | None
|
Customer-facing offer text, such as |
start_date |
str | None
|
Offer start timestamp from the API. |
end_date |
str | None
|
Offer end timestamp from the API. |
original_price |
float | None
|
Shelf price before the promotion, in pounds sterling. |
is_nectar |
bool
|
Whether the offer is a Nectar price. |
promo_type |
str | None
|
Promotion mechanic type from the API. |
promo_group |
str | None
|
Promotion grouping from the API. |
promo_mechanic_id |
str | None
|
Mechanic identifier from the API. |
icon |
str | None
|
Promotion icon URL when provided. |
link |
str | None
|
Relative link to the promotion lister. |
Source code in pysainsburys/models/product/product.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
from_dict(data)
classmethod
¶
Parse a promotion from grocery API JSON.
Source code in pysainsburys/models/product/product.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
to_dict()
¶
Serialise the promotion to a plain dictionary.
Source code in pysainsburys/models/product/product.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
SlotDay
dataclass
¶
Slots grouped for a single calendar day.
Source code in pysainsburys/models/slot/slot.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
available_slots
property
¶
Return only slots marked as available.
__iter__()
¶
Allow dict(day) conversion.
Source code in pysainsburys/models/slot/slot.py
136 137 138 | |
from_dict(data)
classmethod
¶
Parse a day entry from grocery API JSON.
Source code in pysainsburys/models/slot/slot.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
to_dict()
¶
Serialise the day to a plain dictionary.
Source code in pysainsburys/models/slot/slot.py
128 129 130 131 132 133 134 | |
SlotReservation
dataclass
¶
Current slot reservation state for the customer.
Source code in pysainsburys/models/slot/slot.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
__iter__()
¶
Allow dict(reservation) conversion.
Source code in pysainsburys/models/slot/slot.py
275 276 277 | |
from_dict(data)
classmethod
¶
Parse slot reservation JSON.
Source code in pysainsburys/models/slot/slot.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
to_dict()
¶
Serialise the reservation to a plain dictionary.
Source code in pysainsburys/models/slot/slot.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
SlotWeek
dataclass
¶
Week view of delivery or collection slots.
Attributes:
| Name | Type | Description |
|---|---|---|
slot_type |
SlotType | None
|
Requested slot type ( |
week_start_date |
str | None
|
First day of the returned week when provided. |
store_identifier |
str | None
|
Fulfilment store number used for the query. |
postcode |
str | None
|
Delivery postcode context when applicable. |
location_uid |
str | None
|
Click-and-collect location uid when applicable. |
days |
list[SlotDay]
|
Day groupings with nested slot windows. |
Source code in pysainsburys/models/slot/slot.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
available_slots
property
¶
Flatten only available slots across days.
slots
property
¶
Flatten all slots across days.
__iter__()
¶
Allow dict(slot_week) conversion.
Source code in pysainsburys/models/slot/slot.py
217 218 219 | |
from_dict(data, *, slot_type=None, store_identifier=None, postcode=None, location_uid=None)
classmethod
¶
Parse a slot week from grocery API JSON.
Source code in pysainsburys/models/slot/slot.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
to_dict()
¶
Serialise the slot week to a plain dictionary.
Source code in pysainsburys/models/slot/slot.py
206 207 208 209 210 211 212 213 214 215 | |
Store
dataclass
¶
A Sainsbury's store from Product Finder or click-and-collect.
When bound to a :class:~pysainsburys.Sainsburys client, a store can
search in-store stock via :meth:search_products.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Store display name. |
address1 |
str
|
Primary address line. |
city |
str
|
Town or city. |
post_code |
str
|
UK postcode. |
is_available |
bool
|
Whether the store accepts online orders or collection. |
store_id |
str
|
Product Finder store identifier. |
store_number |
str | None
|
Internal store number for click-and-collect locations. |
location_uid |
str | None
|
Click-and-collect location uid when applicable. |
address2 |
str | None
|
Secondary address line. |
county |
str | None
|
County or region. |
opening_hours |
str | None
|
Opening hours text when provided. |
distance |
float | None
|
Distance from the search origin in miles or kilometres. |
telephone |
str | None
|
Store telephone number. |
latitude |
float | None
|
WGS-84 latitude when available. |
longitude |
float | None
|
WGS-84 longitude when available. |
is_open |
bool | None
|
Whether the store is currently open when known. |
click_and_collect_available |
bool
|
Whether click-and-collect is offered. |
Source code in pysainsburys/models/store/store.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
product_finder_id
property
¶
Return the Product Finder store id used for in-store product search.
bind_api(api)
¶
Attach a client for in-store product lookups.
Source code in pysainsburys/models/store/store.py
164 165 166 167 | |
from_collect_dict(data, *, api=None)
classmethod
¶
Parse a click-and-collect store location from grocery API JSON.
Source code in pysainsburys/models/store/store.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
from_dict(data, *, api=None)
classmethod
¶
Parse a store from Product Finder or click-and-collect JSON.
Source code in pysainsburys/models/store/store.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
search_products(keyword, *, page=1, page_size=20)
async
¶
Search in-store products with aisle and stock for this store.
Source code in pysainsburys/models/store/store.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
to_dict()
¶
Serialise the store to a plain dictionary.
Source code in pysainsburys/models/store/store.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
StoreList
dataclass
¶
A paginated list of stores.
Source code in pysainsburys/models/store/store.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
from_dict(data, *, api=None)
classmethod
¶
Parse stores from Product Finder or click-and-collect JSON.
Source code in pysainsburys/models/store/store.py
227 228 229 230 231 232 233 234 235 236 237 238 239 | |
to_dict()
¶
Serialise the store list to a plain dictionary.
Source code in pysainsburys/models/store/store.py
241 242 243 244 245 246 247 248 249 250 | |
StoreProduct
dataclass
¶
A product with in-store aisle and stock information.
Attributes:
| Name | Type | Description |
|---|---|---|
product_code |
str
|
In-store product code used by Product Finder. |
name |
str
|
Shelf label product name. |
stock |
str
|
Stock status string (for example |
price |
float | None
|
Shelf price in pounds sterling. |
price_per_unit |
float | None
|
Normalised unit price when provided. |
unit_of_measure |
str | None
|
Unit label for |
aisle |
str | None
|
Aisle number or location hint in the store. |
image_url |
str | None
|
Product image URL when available. |
is_nectar_price |
bool
|
Whether the price is a Nectar offer. |
promotions |
list[dict[str, Any]]
|
Raw promotion payloads from Product Finder. |
Source code in pysainsburys/models/store/store.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |
from_dict(data)
classmethod
¶
Parse an in-store product from Product Finder JSON.
Source code in pysainsburys/models/store/store.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | |
to_dict()
¶
Serialise the in-store product to a plain dictionary.
Source code in pysainsburys/models/store/store.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |
StoreProductList
dataclass
¶
In-store product search results for a chosen store.
Source code in pysainsburys/models/store/store.py
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |
__iter__()
¶
Allow dict(store_product_list) conversion.
Source code in pysainsburys/models/store/store.py
346 347 348 | |
from_dict(data)
classmethod
¶
Parse in-store product results from Product Finder JSON.
Source code in pysainsburys/models/store/store.py
326 327 328 329 330 331 332 333 334 335 336 | |
to_dict()
¶
Serialise in-store product results to a plain dictionary.
Source code in pysainsburys/models/store/store.py
338 339 340 341 342 343 344 | |
UnlockYourNectarPriceResult
dataclass
¶
Result of unlocking Your Nectar Price offers.
Source code in pysainsburys/models/nectar/nectar.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
from_dict(data)
classmethod
¶
Parse an unlock response from grocery API JSON.
Source code in pysainsburys/models/nectar/nectar.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
to_dict()
¶
Serialise the unlock response to a plain dictionary.
Source code in pysainsburys/models/nectar/nectar.py
223 224 225 226 227 228 | |
YourNectarPriceOffer
dataclass
¶
A Your Nectar Price weekly offer.
Attributes:
| Name | Type | Description |
|---|---|---|
offer_id |
str
|
Offer identifier used for opt-in requests. |
sku |
str
|
Product SKU the offer applies to. |
start_date |
str | None
|
Offer start timestamp. |
expiry_date |
str | None
|
Offer expiry timestamp. |
image |
str | None
|
Product image URL when provided. |
product |
Product | None
|
Enriched catalogue product when fetched separately. |
Source code in pysainsburys/models/nectar/nectar.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
from_dict(data)
classmethod
¶
Parse a Your Nectar Price offer from grocery API JSON.
Source code in pysainsburys/models/nectar/nectar.py
122 123 124 125 126 127 128 129 130 131 | |
to_dict()
¶
Serialise the offer to a plain dictionary.
Source code in pysainsburys/models/nectar/nectar.py
133 134 135 136 137 138 139 140 141 142 | |
YourNectarPrices
dataclass
¶
Your Nectar Price opt-in state for the signed-in customer.
Attributes:
| Name | Type | Description |
|---|---|---|
opted_in |
list[YourNectarPriceOffer]
|
Offers the customer has unlocked. |
not_opted_in |
list[YourNectarPriceOffer]
|
Offers still waiting to be unlocked. |
available_until |
str | None
|
When the current YNP selection window closes. |
released_on |
str | None
|
When the current YNP offers were released. |
Source code in pysainsburys/models/nectar/nectar.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
all_offers
property
¶
Return opted-in and locked offers together.
__iter__()
¶
Allow dict(prices) conversion.
Source code in pysainsburys/models/nectar/nectar.py
195 196 197 | |
from_dict(data)
classmethod
¶
Parse Your Nectar Price opt-ins from grocery API JSON.
Source code in pysainsburys/models/nectar/nectar.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
to_dict()
¶
Serialise the YNP response to a plain dictionary.
Source code in pysainsburys/models/nectar/nectar.py
186 187 188 189 190 191 192 193 | |
basket_from_response(response)
¶
Parse a basket API response into a :class:Basket.
Source code in pysainsburys/models/basket/basket.py
12 13 14 15 16 17 | |
bind_product(api, product)
¶
Attach an API client to a product for basket and favourites operations.
Source code in pysainsburys/models/product/product.py
614 615 616 | |
bind_products(api, products)
¶
Attach an API client to each product in a list.
Source code in pysainsburys/models/product/product.py
619 620 621 622 623 | |
bind_store(api, store)
¶
Attach an API client to a store for in-store product lookups.
Source code in pysainsburys/models/store/store.py
351 352 353 | |
bind_stores(api, stores)
¶
Attach an API client to each store in a list.
Source code in pysainsburys/models/store/store.py
356 357 358 359 360 | |
decode_details_html(details_html)
¶
Decode the base64 product details_html field.
Source code in pysainsburys/models/product/nutrition.py
187 188 189 190 191 192 193 194 | |
parse_nutrition(html)
¶
Parse nutrition information from decoded product detail HTML.
Source code in pysainsburys/models/product/nutrition.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
parse_nutrition_from_details_html(details_html)
¶
Parse nutrition information from a product details_html field.
Source code in pysainsburys/models/product/nutrition.py
288 289 290 | |
parse_product_details(html)
¶
Parse product-text sections from decoded product detail HTML.
Source code in pysainsburys/models/product/details.py
205 206 207 208 209 210 211 212 213 214 | |
parse_product_details_from_details_html(details_html)
¶
Parse product-text sections from a base64 details_html field.
Source code in pysainsburys/models/product/details.py
217 218 219 220 221 | |
Common¶
pysainsburys.models.common
¶
Shared model primitives used across multiple API domains.
PageControls
dataclass
¶
Pagination metadata returned by grocery list endpoints.
Attributes:
| Name | Type | Description |
|---|---|---|
total_record_count |
int
|
Total items available across all pages. |
returned_record_count |
int
|
Items included in the current response. |
active_page |
int
|
One-based index of the current page. |
first_page |
int
|
One-based index of the first page. |
last_page |
int
|
One-based index of the last page. |
page_size |
int
|
Requested page size. |
Source code in pysainsburys/models/common/pagination.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
from_dict(data)
classmethod
¶
Parse pagination controls from grocery API JSON.
Source code in pysainsburys/models/common/pagination.py
31 32 33 34 35 36 37 38 39 40 41 42 43 | |
to_dict()
¶
Serialise pagination controls to a plain dictionary.
Source code in pysainsburys/models/common/pagination.py
45 46 47 48 49 50 51 52 53 54 | |
Price
dataclass
¶
A monetary amount with an optional unit of measure.
Attributes:
| Name | Type | Description |
|---|---|---|
price |
float
|
Amount in pounds sterling. |
measure |
str | None
|
Unit label returned by the API (for example |
measure_amount |
float | None
|
Quantity associated with |
Source code in pysainsburys/models/common/price.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
from_dict(data)
classmethod
¶
Parse a price object from grocery API JSON.
Source code in pysainsburys/models/common/price.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
to_dict()
¶
Serialise the price to a plain dictionary.
Source code in pysainsburys/models/common/price.py
40 41 42 43 44 45 46 | |
pysainsburys.models.common.price.Price
dataclass
¶
A monetary amount with an optional unit of measure.
Attributes:
| Name | Type | Description |
|---|---|---|
price |
float
|
Amount in pounds sterling. |
measure |
str | None
|
Unit label returned by the API (for example |
measure_amount |
float | None
|
Quantity associated with |
Source code in pysainsburys/models/common/price.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
from_dict(data)
classmethod
¶
Parse a price object from grocery API JSON.
Source code in pysainsburys/models/common/price.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
to_dict()
¶
Serialise the price to a plain dictionary.
Source code in pysainsburys/models/common/price.py
40 41 42 43 44 45 46 | |
pysainsburys.models.common.pagination.PageControls
dataclass
¶
Pagination metadata returned by grocery list endpoints.
Attributes:
| Name | Type | Description |
|---|---|---|
total_record_count |
int
|
Total items available across all pages. |
returned_record_count |
int
|
Items included in the current response. |
active_page |
int
|
One-based index of the current page. |
first_page |
int
|
One-based index of the first page. |
last_page |
int
|
One-based index of the last page. |
page_size |
int
|
Requested page size. |
Source code in pysainsburys/models/common/pagination.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
from_dict(data)
classmethod
¶
Parse pagination controls from grocery API JSON.
Source code in pysainsburys/models/common/pagination.py
31 32 33 34 35 36 37 38 39 40 41 42 43 | |
to_dict()
¶
Serialise pagination controls to a plain dictionary.
Source code in pysainsburys/models/common/pagination.py
45 46 47 48 49 50 51 52 53 54 | |
Product¶
pysainsburys.models.product
¶
Catalogue product models, detail sections, and nutrition parsing.
AverageWeight
dataclass
¶
Typical weight for a loose product.
Source code in pysainsburys/models/product/catalogue.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
from_dict(data)
classmethod
¶
Parse an average weight from grocery API JSON.
Source code in pysainsburys/models/product/catalogue.py
210 211 212 213 214 215 | |
to_dict()
¶
Serialise the average weight to a plain dictionary.
Source code in pysainsburys/models/product/catalogue.py
217 218 219 | |
HfssRestriction
dataclass
¶
HFSS advertising restriction for one UK nation.
Source code in pysainsburys/models/product/catalogue.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
from_dict(data)
classmethod
¶
Parse an HFSS restriction from grocery API JSON.
Source code in pysainsburys/models/product/catalogue.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
to_dict()
¶
Serialise the HFSS restriction to a plain dictionary.
Source code in pysainsburys/models/product/catalogue.py
248 249 250 251 252 253 254 255 256 | |
NectarPrice
dataclass
¶
Nectar member price for a product.
Attributes:
| Name | Type | Description |
|---|---|---|
retail_price |
float
|
Nectar price for the purchasable quantity. |
unit_price |
float | None
|
Nectar price per unit of measure, when provided. |
measure |
str | None
|
Unit label for |
url |
str | None
|
Link to the Nectar prices listing. |
category_seo_url |
str | None
|
SEO path for the Nectar prices category. |
Source code in pysainsburys/models/product/product.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
from_dict(data)
classmethod
¶
Parse a Nectar price from grocery API JSON.
Source code in pysainsburys/models/product/product.py
175 176 177 178 179 180 181 182 183 184 185 186 187 | |
to_dict()
¶
Serialise the Nectar price to a plain dictionary.
Source code in pysainsburys/models/product/product.py
189 190 191 192 193 194 195 196 197 | |
NutrientSummary
dataclass
¶
Traffic-light style nutrition summary for a single nutrient.
Source code in pysainsburys/models/product/nutrition.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
to_dict()
¶
Return the nutrient summary as a dictionary.
Source code in pysainsburys/models/product/nutrition.py
59 60 61 62 63 64 65 66 | |
NutritionInfo
dataclass
¶
Parsed nutrition information for a product.
Source code in pysainsburys/models/product/nutrition.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
to_dict()
¶
Return nutrition information as a dictionary.
Source code in pysainsburys/models/product/nutrition.py
109 110 111 112 113 114 115 | |
NutritionTable
dataclass
¶
A nutrition facts table from a product detail page.
Source code in pysainsburys/models/product/nutrition.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
to_dict()
¶
Return the nutrition table as a dictionary.
Source code in pysainsburys/models/product/nutrition.py
92 93 94 95 96 97 98 | |
NutritionTableRow
dataclass
¶
A single row in a nutrition facts table.
Source code in pysainsburys/models/product/nutrition.py
69 70 71 72 73 74 75 76 77 78 79 80 81 | |
to_dict()
¶
Return the table row as a dictionary.
Source code in pysainsburys/models/product/nutrition.py
76 77 78 79 80 81 | |
Product
dataclass
¶
A grocery product from the online catalogue.
When bound to a :class:~pysainsburys.Sainsburys client, a product can
mutate the authenticated customer's basket directly via
:meth:add_to_basket, :meth:set_basket_quantity, and
:meth:remove_from_basket.
Nutrition data is parsed automatically from details_html when present
on the API response (see :attr:nutrition). The same HTML also supplies
description, storage, and related copy on :attr:details. Search results
omit details_html, so those sections stay empty until the product is
loaded with :meth:~pysainsburys.Sainsburys.get_product.
Attributes:
| Name | Type | Description |
|---|---|---|
product_uid |
str
|
Stable Sainsbury's product identifier. |
name |
str
|
Display name shown on the website and app. |
sain_id |
str | None
|
Legacy SAIN identifier when returned by the API. |
is_favourite |
bool
|
Whether the product is in the signed-in customer's favourites list. |
favourite_type |
str | None
|
Favourite list type when provided by the API. |
product_type |
str | None
|
Product classification string from the API. |
eans |
list[str]
|
European article numbers associated with the product. |
unit_price |
Price | None
|
Price per unit of measure, when available. |
retail_price |
Price | None
|
Shelf price for the purchasable quantity. |
is_available |
bool
|
Whether the product can be added to a basket. |
is_alcoholic |
bool
|
Whether age-restricted checks apply. |
reviews |
ProductReviews | None
|
Aggregated review metadata. |
image_url |
str | None
|
Product listing image URL. |
nutrition |
NutritionInfo | None
|
Parsed nutrition tables and traffic-light summary. |
details |
ProductDetails | None
|
Description, storage, and other product-text sections. |
promotions |
list[Promotion]
|
Catalogue offers attached to the product. |
nectar_price |
NectarPrice | None
|
Nectar member price when the product has one. |
favourite_uid |
str | None
|
Favourite-list identifier when the product is saved. |
short_description |
str | None
|
One-line summary from the product payload. |
full_url |
str | None
|
Absolute product page URL. |
original_unit_price |
Price | None
|
Unit price before a promotion, when the API returns one. |
image |
str | None
|
Large product image URL. |
image_thumbnail |
str | None
|
Medium product image URL. |
image_thumbnail_small |
str | None
|
Small product image URL. |
image_zoom |
str | None
|
Zoom image URL when provided. |
images |
list[ProductImage]
|
Sized image variants from the assets block. |
zone |
str | None
|
Merchandising zone, such as |
department |
str | None
|
Department name when the API returns one. |
labels |
list[ProductLabel]
|
Merchandising labels such as British or Chilled. |
categories |
list[ProductCategory]
|
Catalogue categories that include the product. |
breadcrumbs |
list[ProductBreadcrumb]
|
Breadcrumb trail for the product page. |
attributes |
dict[str, list[str]]
|
Attribute groups from the API, including brand. |
header |
ProductHeader | None
|
Promotional header, such as a Nectar price banner. |
is_spotlight |
bool
|
Whether the product is flagged as featured. |
spotlight_label |
str | None
|
Featured label when |
not_for_eu |
bool
|
Whether the product is marked not for EU sale. |
is_intolerant |
bool
|
Whether the product carries an intolerance flag. |
is_mhra |
bool
|
Whether MHRA restrictions apply. |
is_supply_chain_orderable |
bool
|
Whether supply-chain ordering is enabled. |
display_icons |
list[str]
|
Icon identifiers shown on the product. |
health_rating |
str | None
|
Health rating score from |
hfss_restrictions |
list[HfssRestriction]
|
HFSS advertising restrictions by UK nation. |
pdp_deep_link |
str | None
|
Legacy product-display path. |
average_weight |
AverageWeight | None
|
Typical weight for a loose product. |
promise |
ProductPromise | None
|
Delivery promise when a slot context is present. |
Source code in pysainsburys/models/product/product.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
brand
property
¶
Brand names from the product attributes.
__iter__()
¶
Allow dict(product) conversion.
Source code in pysainsburys/models/product/product.py
581 582 583 | |
add_to_basket(quantity=1.0, *, selected_catchweight=None, uom=None)
async
¶
Add this product to the basket (POST increment).
Source code in pysainsburys/models/product/product.py
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 | |
bind_api(api)
¶
Attach a client for basket and favourites operations.
Source code in pysainsburys/models/product/product.py
430 431 432 433 | |
from_basket_nested(data, *, api=None)
classmethod
¶
Parse a product object nested inside a basket line item.
Source code in pysainsburys/models/product/product.py
408 409 410 411 412 413 414 415 416 417 418 419 | |
from_dict(data, *, api=None)
classmethod
¶
Parse a product from grocery API JSON.
Source code in pysainsburys/models/product/product.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
remove_from_basket(*, item_uid=None, force_delete=False)
async
¶
Remove this product from the basket.
Source code in pysainsburys/models/product/product.py
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | |
set_basket_quantity(quantity, *, item_uid=None, selected_catchweight=None, uom=None)
async
¶
Set the absolute basket quantity for this product.
Source code in pysainsburys/models/product/product.py
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 | |
to_dict()
¶
Serialise the product to a plain dictionary.
Source code in pysainsburys/models/product/product.py
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 | |
ProductBreadcrumb
dataclass
¶
One step in the product page breadcrumb trail.
Source code in pysainsburys/models/product/catalogue.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
from_dict(data)
classmethod
¶
Parse a breadcrumb from grocery API JSON.
Source code in pysainsburys/models/product/catalogue.py
108 109 110 111 112 113 114 115 116 | |
to_dict()
¶
Serialise the breadcrumb to a plain dictionary.
Source code in pysainsburys/models/product/catalogue.py
118 119 120 | |
ProductCategory
dataclass
¶
A catalogue category the product belongs to.
Source code in pysainsburys/models/product/catalogue.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
from_dict(data)
classmethod
¶
Parse a category from grocery API JSON.
Source code in pysainsburys/models/product/catalogue.py
85 86 87 88 89 90 91 92 93 94 | |
to_dict()
¶
Serialise the category to a plain dictionary.
Source code in pysainsburys/models/product/catalogue.py
96 97 98 | |
ProductDetails
dataclass
¶
Catalogue copy parsed from a product detail page.
Each field is a list of paragraphs. A heading the page does not include
is None.
Attributes:
| Name | Type | Description |
|---|---|---|
description |
list[str] | None
|
Product description paragraphs. |
storage |
list[str] | None
|
Storage instructions. |
dietary_information |
list[str] | None
|
Dietary and allergen statements. |
ingredients |
list[str] | None
|
Ingredient list paragraphs. |
manufacturer |
list[str] | None
|
Manufacturer or packer details. |
preparation |
list[str] | None
|
Preparation or serving instructions. |
country_of_origin |
list[str] | None
|
Origin or packing-country statements. |
packaging |
list[str] | None
|
Packaging description. |
Source code in pysainsburys/models/product/details.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
from_dict(data)
classmethod
¶
Parse product detail sections from a serialised mapping.
Source code in pysainsburys/models/product/details.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
is_empty()
¶
Return whether every section is missing.
Source code in pysainsburys/models/product/details.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
to_dict()
¶
Serialise the detail sections to a plain dictionary.
Source code in pysainsburys/models/product/details.py
107 108 109 110 111 112 113 114 115 116 117 118 | |
ProductHeader
dataclass
¶
Promotional header shown above the product, such as a Nectar price.
Source code in pysainsburys/models/product/catalogue.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
from_dict(data)
classmethod
¶
Parse a product header from grocery API JSON.
Source code in pysainsburys/models/product/catalogue.py
130 131 132 133 134 135 136 137 138 139 | |
to_dict()
¶
Serialise the header to a plain dictionary.
Source code in pysainsburys/models/product/catalogue.py
141 142 143 | |
ProductImage
dataclass
¶
A product image and the sizes the API provides for it.
Source code in pysainsburys/models/product/catalogue.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
from_dict(data)
classmethod
¶
Parse a product image from grocery API JSON.
Source code in pysainsburys/models/product/catalogue.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
to_dict()
¶
Serialise the product image to a plain dictionary.
Source code in pysainsburys/models/product/catalogue.py
195 196 197 198 199 200 | |
ProductImageSize
dataclass
¶
One rendered size of a product image.
Source code in pysainsburys/models/product/catalogue.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
from_dict(data)
classmethod
¶
Parse an image size from grocery API JSON.
Source code in pysainsburys/models/product/catalogue.py
154 155 156 157 158 159 160 161 162 163 164 165 166 | |
to_dict()
¶
Serialise the image size to a plain dictionary.
Source code in pysainsburys/models/product/catalogue.py
168 169 170 | |
ProductLabel
dataclass
¶
A merchandising label such as British or Chilled.
Source code in pysainsburys/models/product/catalogue.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
from_dict(data)
classmethod
¶
Parse a label from grocery API JSON.
Source code in pysainsburys/models/product/catalogue.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
to_dict()
¶
Serialise the label to a plain dictionary.
Source code in pysainsburys/models/product/catalogue.py
66 67 68 69 70 71 72 73 74 75 | |
ProductList
dataclass
¶
A paginated list of catalogue products.
Source code in pysainsburys/models/product/product.py
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 | |
__iter__()
¶
Allow dict(product_list) conversion.
Source code in pysainsburys/models/product/product.py
609 610 611 | |
from_dict(data)
classmethod
¶
Parse a paginated product list from grocery API JSON.
Source code in pysainsburys/models/product/product.py
593 594 595 596 597 598 599 600 | |
to_dict()
¶
Serialise the product list to a plain dictionary.
Source code in pysainsburys/models/product/product.py
602 603 604 605 606 607 | |
ProductPromise
dataclass
¶
Delivery promise attached to a product when a slot context exists.
Source code in pysainsburys/models/product/catalogue.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |
from_dict(data)
classmethod
¶
Parse a product promise from grocery API JSON.
Source code in pysainsburys/models/product/catalogue.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
is_empty()
¶
Return whether the promise carries no slot information.
Source code in pysainsburys/models/product/catalogue.py
289 290 291 292 293 294 295 296 297 298 299 300 | |
to_dict()
¶
Serialise the promise to a plain dictionary.
Source code in pysainsburys/models/product/catalogue.py
302 303 304 305 306 307 308 309 310 | |
ProductReviews
dataclass
¶
Aggregated review metadata for a product.
Attributes:
| Name | Type | Description |
|---|---|---|
is_enabled |
bool
|
Whether reviews are shown for this product. |
product_uid |
str | None
|
Product identifier referenced by the review service. |
total |
int
|
Number of published reviews. |
average_rating |
float
|
Mean star rating across reviews. |
Source code in pysainsburys/models/product/product.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
from_dict(data)
classmethod
¶
Parse review metadata from grocery API JSON.
Source code in pysainsburys/models/product/product.py
58 59 60 61 62 63 64 65 66 67 68 | |
to_dict()
¶
Serialise review metadata to a plain dictionary.
Source code in pysainsburys/models/product/product.py
70 71 72 73 74 75 76 77 | |
Promotion
dataclass
¶
A catalogue promotion attached to a product.
Attributes:
| Name | Type | Description |
|---|---|---|
promotion_uid |
str
|
Promotion identifier. |
strap_line |
str | None
|
Customer-facing offer text, such as |
start_date |
str | None
|
Offer start timestamp from the API. |
end_date |
str | None
|
Offer end timestamp from the API. |
original_price |
float | None
|
Shelf price before the promotion, in pounds sterling. |
is_nectar |
bool
|
Whether the offer is a Nectar price. |
promo_type |
str | None
|
Promotion mechanic type from the API. |
promo_group |
str | None
|
Promotion grouping from the API. |
promo_mechanic_id |
str | None
|
Mechanic identifier from the API. |
icon |
str | None
|
Promotion icon URL when provided. |
link |
str | None
|
Relative link to the promotion lister. |
Source code in pysainsburys/models/product/product.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
from_dict(data)
classmethod
¶
Parse a promotion from grocery API JSON.
Source code in pysainsburys/models/product/product.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
to_dict()
¶
Serialise the promotion to a plain dictionary.
Source code in pysainsburys/models/product/product.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
bind_product(api, product)
¶
Attach an API client to a product for basket and favourites operations.
Source code in pysainsburys/models/product/product.py
614 615 616 | |
bind_products(api, products)
¶
Attach an API client to each product in a list.
Source code in pysainsburys/models/product/product.py
619 620 621 622 623 | |
decode_details_html(details_html)
¶
Decode the base64 product details_html field.
Source code in pysainsburys/models/product/nutrition.py
187 188 189 190 191 192 193 194 | |
parse_nutrition(html)
¶
Parse nutrition information from decoded product detail HTML.
Source code in pysainsburys/models/product/nutrition.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
parse_nutrition_from_details_html(details_html)
¶
Parse nutrition information from a product details_html field.
Source code in pysainsburys/models/product/nutrition.py
288 289 290 | |
parse_product_details(html)
¶
Parse product-text sections from decoded product detail HTML.
Source code in pysainsburys/models/product/details.py
205 206 207 208 209 210 211 212 213 214 | |
parse_product_details_from_details_html(details_html)
¶
Parse product-text sections from a base64 details_html field.
Source code in pysainsburys/models/product/details.py
217 218 219 220 221 | |
pysainsburys.models.product.product.Product
dataclass
¶
A grocery product from the online catalogue.
When bound to a :class:~pysainsburys.Sainsburys client, a product can
mutate the authenticated customer's basket directly via
:meth:add_to_basket, :meth:set_basket_quantity, and
:meth:remove_from_basket.
Nutrition data is parsed automatically from details_html when present
on the API response (see :attr:nutrition). The same HTML also supplies
description, storage, and related copy on :attr:details. Search results
omit details_html, so those sections stay empty until the product is
loaded with :meth:~pysainsburys.Sainsburys.get_product.
Attributes:
| Name | Type | Description |
|---|---|---|
product_uid |
str
|
Stable Sainsbury's product identifier. |
name |
str
|
Display name shown on the website and app. |
sain_id |
str | None
|
Legacy SAIN identifier when returned by the API. |
is_favourite |
bool
|
Whether the product is in the signed-in customer's favourites list. |
favourite_type |
str | None
|
Favourite list type when provided by the API. |
product_type |
str | None
|
Product classification string from the API. |
eans |
list[str]
|
European article numbers associated with the product. |
unit_price |
Price | None
|
Price per unit of measure, when available. |
retail_price |
Price | None
|
Shelf price for the purchasable quantity. |
is_available |
bool
|
Whether the product can be added to a basket. |
is_alcoholic |
bool
|
Whether age-restricted checks apply. |
reviews |
ProductReviews | None
|
Aggregated review metadata. |
image_url |
str | None
|
Product listing image URL. |
nutrition |
NutritionInfo | None
|
Parsed nutrition tables and traffic-light summary. |
details |
ProductDetails | None
|
Description, storage, and other product-text sections. |
promotions |
list[Promotion]
|
Catalogue offers attached to the product. |
nectar_price |
NectarPrice | None
|
Nectar member price when the product has one. |
favourite_uid |
str | None
|
Favourite-list identifier when the product is saved. |
short_description |
str | None
|
One-line summary from the product payload. |
full_url |
str | None
|
Absolute product page URL. |
original_unit_price |
Price | None
|
Unit price before a promotion, when the API returns one. |
image |
str | None
|
Large product image URL. |
image_thumbnail |
str | None
|
Medium product image URL. |
image_thumbnail_small |
str | None
|
Small product image URL. |
image_zoom |
str | None
|
Zoom image URL when provided. |
images |
list[ProductImage]
|
Sized image variants from the assets block. |
zone |
str | None
|
Merchandising zone, such as |
department |
str | None
|
Department name when the API returns one. |
labels |
list[ProductLabel]
|
Merchandising labels such as British or Chilled. |
categories |
list[ProductCategory]
|
Catalogue categories that include the product. |
breadcrumbs |
list[ProductBreadcrumb]
|
Breadcrumb trail for the product page. |
attributes |
dict[str, list[str]]
|
Attribute groups from the API, including brand. |
header |
ProductHeader | None
|
Promotional header, such as a Nectar price banner. |
is_spotlight |
bool
|
Whether the product is flagged as featured. |
spotlight_label |
str | None
|
Featured label when |
not_for_eu |
bool
|
Whether the product is marked not for EU sale. |
is_intolerant |
bool
|
Whether the product carries an intolerance flag. |
is_mhra |
bool
|
Whether MHRA restrictions apply. |
is_supply_chain_orderable |
bool
|
Whether supply-chain ordering is enabled. |
display_icons |
list[str]
|
Icon identifiers shown on the product. |
health_rating |
str | None
|
Health rating score from |
hfss_restrictions |
list[HfssRestriction]
|
HFSS advertising restrictions by UK nation. |
pdp_deep_link |
str | None
|
Legacy product-display path. |
average_weight |
AverageWeight | None
|
Typical weight for a loose product. |
promise |
ProductPromise | None
|
Delivery promise when a slot context is present. |
Source code in pysainsburys/models/product/product.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
brand
property
¶
Brand names from the product attributes.
__iter__()
¶
Allow dict(product) conversion.
Source code in pysainsburys/models/product/product.py
581 582 583 | |
add_to_basket(quantity=1.0, *, selected_catchweight=None, uom=None)
async
¶
Add this product to the basket (POST increment).
Source code in pysainsburys/models/product/product.py
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 | |
bind_api(api)
¶
Attach a client for basket and favourites operations.
Source code in pysainsburys/models/product/product.py
430 431 432 433 | |
from_basket_nested(data, *, api=None)
classmethod
¶
Parse a product object nested inside a basket line item.
Source code in pysainsburys/models/product/product.py
408 409 410 411 412 413 414 415 416 417 418 419 | |
from_dict(data, *, api=None)
classmethod
¶
Parse a product from grocery API JSON.
Source code in pysainsburys/models/product/product.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
remove_from_basket(*, item_uid=None, force_delete=False)
async
¶
Remove this product from the basket.
Source code in pysainsburys/models/product/product.py
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | |
set_basket_quantity(quantity, *, item_uid=None, selected_catchweight=None, uom=None)
async
¶
Set the absolute basket quantity for this product.
Source code in pysainsburys/models/product/product.py
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 | |
to_dict()
¶
Serialise the product to a plain dictionary.
Source code in pysainsburys/models/product/product.py
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 | |
pysainsburys.models.product.product.ProductList
dataclass
¶
A paginated list of catalogue products.
Source code in pysainsburys/models/product/product.py
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 | |
__iter__()
¶
Allow dict(product_list) conversion.
Source code in pysainsburys/models/product/product.py
609 610 611 | |
from_dict(data)
classmethod
¶
Parse a paginated product list from grocery API JSON.
Source code in pysainsburys/models/product/product.py
593 594 595 596 597 598 599 600 | |
to_dict()
¶
Serialise the product list to a plain dictionary.
Source code in pysainsburys/models/product/product.py
602 603 604 605 606 607 | |
pysainsburys.models.product.product.Promotion
dataclass
¶
A catalogue promotion attached to a product.
Attributes:
| Name | Type | Description |
|---|---|---|
promotion_uid |
str
|
Promotion identifier. |
strap_line |
str | None
|
Customer-facing offer text, such as |
start_date |
str | None
|
Offer start timestamp from the API. |
end_date |
str | None
|
Offer end timestamp from the API. |
original_price |
float | None
|
Shelf price before the promotion, in pounds sterling. |
is_nectar |
bool
|
Whether the offer is a Nectar price. |
promo_type |
str | None
|
Promotion mechanic type from the API. |
promo_group |
str | None
|
Promotion grouping from the API. |
promo_mechanic_id |
str | None
|
Mechanic identifier from the API. |
icon |
str | None
|
Promotion icon URL when provided. |
link |
str | None
|
Relative link to the promotion lister. |
Source code in pysainsburys/models/product/product.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
from_dict(data)
classmethod
¶
Parse a promotion from grocery API JSON.
Source code in pysainsburys/models/product/product.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
to_dict()
¶
Serialise the promotion to a plain dictionary.
Source code in pysainsburys/models/product/product.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
pysainsburys.models.product.product.NectarPrice
dataclass
¶
Nectar member price for a product.
Attributes:
| Name | Type | Description |
|---|---|---|
retail_price |
float
|
Nectar price for the purchasable quantity. |
unit_price |
float | None
|
Nectar price per unit of measure, when provided. |
measure |
str | None
|
Unit label for |
url |
str | None
|
Link to the Nectar prices listing. |
category_seo_url |
str | None
|
SEO path for the Nectar prices category. |
Source code in pysainsburys/models/product/product.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
from_dict(data)
classmethod
¶
Parse a Nectar price from grocery API JSON.
Source code in pysainsburys/models/product/product.py
175 176 177 178 179 180 181 182 183 184 185 186 187 | |
to_dict()
¶
Serialise the Nectar price to a plain dictionary.
Source code in pysainsburys/models/product/product.py
189 190 191 192 193 194 195 196 197 | |
pysainsburys.models.product.details.ProductDetails
dataclass
¶
Catalogue copy parsed from a product detail page.
Each field is a list of paragraphs. A heading the page does not include
is None.
Attributes:
| Name | Type | Description |
|---|---|---|
description |
list[str] | None
|
Product description paragraphs. |
storage |
list[str] | None
|
Storage instructions. |
dietary_information |
list[str] | None
|
Dietary and allergen statements. |
ingredients |
list[str] | None
|
Ingredient list paragraphs. |
manufacturer |
list[str] | None
|
Manufacturer or packer details. |
preparation |
list[str] | None
|
Preparation or serving instructions. |
country_of_origin |
list[str] | None
|
Origin or packing-country statements. |
packaging |
list[str] | None
|
Packaging description. |
Source code in pysainsburys/models/product/details.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
from_dict(data)
classmethod
¶
Parse product detail sections from a serialised mapping.
Source code in pysainsburys/models/product/details.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
is_empty()
¶
Return whether every section is missing.
Source code in pysainsburys/models/product/details.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
to_dict()
¶
Serialise the detail sections to a plain dictionary.
Source code in pysainsburys/models/product/details.py
107 108 109 110 111 112 113 114 115 116 117 118 | |
pysainsburys.models.product.nutrition.NutritionInfo
dataclass
¶
Parsed nutrition information for a product.
Source code in pysainsburys/models/product/nutrition.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
to_dict()
¶
Return nutrition information as a dictionary.
Source code in pysainsburys/models/product/nutrition.py
109 110 111 112 113 114 115 | |
pysainsburys.models.product.nutrition.parse_nutrition_from_details_html(details_html)
¶
Parse nutrition information from a product details_html field.
Source code in pysainsburys/models/product/nutrition.py
288 289 290 | |
Basket¶
pysainsburys.models.basket
¶
Basket domain models.
Basket
dataclass
¶
The authenticated customer's grocery basket.
Attributes:
| Name | Type | Description |
|---|---|---|
basket_id |
str | None
|
Basket identifier assigned by the commerce platform. |
order_id |
str | None
|
Associated order id when amending an existing order. |
subtotal_price |
float
|
Sum of item prices before delivery and savings. |
total_price |
float
|
Basket total including fees where calculated. |
slot_price |
float
|
Delivery or collection slot charge when applicable. |
savings |
float
|
Promotional savings applied to the basket. |
nectar_savings |
float
|
Nectar-specific savings when applicable. |
item_count |
int
|
Number of distinct line items. |
minimum_spend |
int
|
Minimum order value required for checkout. |
delivery_instructions |
str | None
|
Customer delivery note when set. |
is_in_amend_mode |
bool
|
Whether the basket is amending a placed order. |
slot_type |
str | None
|
Reserved slot type string from the API. |
has_exceeded_minimum_spend |
bool
|
Whether the minimum spend threshold is met. |
items |
list[BasketItem]
|
Line items currently in the basket. |
Source code in pysainsburys/models/basket/basket.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
is_empty
property
¶
Return True when the basket contains no items.
__iter__()
¶
Allow dict(basket) conversion.
Source code in pysainsburys/models/basket/basket.py
173 174 175 | |
from_dict(data)
classmethod
¶
Parse a basket from grocery API JSON.
Source code in pysainsburys/models/basket/basket.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
to_dict()
¶
Serialise the basket to a plain dictionary.
Source code in pysainsburys/models/basket/basket.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
BasketItem
dataclass
¶
A single line item in the grocery basket.
Attributes:
| Name | Type | Description |
|---|---|---|
product_uid |
str
|
Catalogue identifier for the product. |
quantity |
float
|
Number of units in the basket. |
name |
str | None
|
Display name when returned by the basket endpoint. |
item_uid |
str | None
|
Basket line identifier used for updates and removals. |
subtotal |
float | None
|
Line total in pounds sterling. |
unit_price |
Price | None
|
Price per unit when provided by the API. |
product_data |
dict[str, Any] | None
|
Nested product JSON when included in the basket response.
Use :meth: |
Source code in pysainsburys/models/basket/basket.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
from_dict(data)
classmethod
¶
Parse a basket item from grocery API JSON.
Source code in pysainsburys/models/basket/basket.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
to_dict()
¶
Serialise the basket item to a plain dictionary.
Source code in pysainsburys/models/basket/basket.py
76 77 78 79 80 81 82 83 84 85 86 | |
basket_from_response(response)
¶
Parse a basket API response into a :class:Basket.
Source code in pysainsburys/models/basket/basket.py
12 13 14 15 16 17 | |
pysainsburys.models.basket.basket.Basket
dataclass
¶
The authenticated customer's grocery basket.
Attributes:
| Name | Type | Description |
|---|---|---|
basket_id |
str | None
|
Basket identifier assigned by the commerce platform. |
order_id |
str | None
|
Associated order id when amending an existing order. |
subtotal_price |
float
|
Sum of item prices before delivery and savings. |
total_price |
float
|
Basket total including fees where calculated. |
slot_price |
float
|
Delivery or collection slot charge when applicable. |
savings |
float
|
Promotional savings applied to the basket. |
nectar_savings |
float
|
Nectar-specific savings when applicable. |
item_count |
int
|
Number of distinct line items. |
minimum_spend |
int
|
Minimum order value required for checkout. |
delivery_instructions |
str | None
|
Customer delivery note when set. |
is_in_amend_mode |
bool
|
Whether the basket is amending a placed order. |
slot_type |
str | None
|
Reserved slot type string from the API. |
has_exceeded_minimum_spend |
bool
|
Whether the minimum spend threshold is met. |
items |
list[BasketItem]
|
Line items currently in the basket. |
Source code in pysainsburys/models/basket/basket.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
is_empty
property
¶
Return True when the basket contains no items.
__iter__()
¶
Allow dict(basket) conversion.
Source code in pysainsburys/models/basket/basket.py
173 174 175 | |
from_dict(data)
classmethod
¶
Parse a basket from grocery API JSON.
Source code in pysainsburys/models/basket/basket.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
to_dict()
¶
Serialise the basket to a plain dictionary.
Source code in pysainsburys/models/basket/basket.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
pysainsburys.basket.BasketAccess
¶
Fetch and manipulate the authenticated customer's grocery basket.
Source code in pysainsburys/basket.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
cached
property
¶
Return the last fetched basket, if any.
add(product_uid, quantity=1.0, *, uom='ea', selected_catchweight=None)
async
¶
Add a product to the basket (POST increment).
Source code in pysainsburys/basket.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
clear()
async
¶
Remove all items from the basket.
Source code in pysainsburys/basket.py
157 158 159 160 | |
fetch(*, calculate=True)
async
¶
Fetch the current basket.
Source code in pysainsburys/basket.py
65 66 67 68 69 70 71 72 73 74 | |
remove(product_uid, *, item_uid=None, force_delete=False)
async
¶
Remove a product from the basket.
Source code in pysainsburys/basket.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
set_quantity(product_uid, quantity, *, item_uid=None, uom='ea', selected_catchweight=None)
async
¶
Set the absolute basket quantity for a product.
Source code in pysainsburys/basket.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
Customer¶
pysainsburys.models.customer
¶
Customer profile models.
Customer
dataclass
¶
Authenticated Sainsbury's Groceries Online customer profile.
A customer is returned by :meth:~pysainsburys.Sainsburys.get_customer and
exposes convenience accessors for basket, favourites, orders, and slot
resources when bound to a client.
Attributes:
| Name | Type | Description |
|---|---|---|
user_id |
str
|
Commerce platform user identifier. |
customer_id |
str | None
|
Customer record identifier when distinct from |
identity_id |
str | None
|
Identity provider subject identifier. |
email |
str | None
|
Account email address. |
family_name |
str | None
|
Family name from the profile. |
given_name |
str | None
|
Given name from the profile. |
primary_phone |
str | None
|
Primary contact telephone number. |
postcode |
str | None
|
Default delivery postcode when set. |
title |
str | None
|
Salutation or title when provided. |
is_very_important_customer |
bool
|
VIP flag from the API. |
delivery_pass_expiry_date |
str | None
|
Delivery pass expiry when subscribed. |
personalization_id |
str | None
|
Personalisation token for recommendations. |
has_nectar_associated |
bool
|
Whether a Nectar card is associated. |
has_nectar_linked |
bool
|
Whether Nectar is fully linked for rewards. |
is_digital_nectar |
bool
|
Whether the account uses digital Nectar. |
Source code in pysainsburys/models/customer/customer.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
basket
property
¶
Basket fetch and clear helpers for this customer.
display_name
property
¶
Return a human-friendly display name.
favourites
property
¶
Favourites list and add/remove helpers for this customer.
nectar
property
¶
Nectar bonus offers and Your Nectar Price helpers.
orders
property
¶
Order history, latest order, and per-order status.
slots
property
¶
Delivery and collection slot listing helpers.
__iter__()
¶
Allow dict(customer) conversion.
Source code in pysainsburys/models/customer/customer.py
184 185 186 | |
from_dict(data, *, api=None)
classmethod
¶
Parse a customer profile from grocery API JSON.
Source code in pysainsburys/models/customer/customer.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
to_dict()
¶
Serialise the customer profile to a plain dictionary.
Source code in pysainsburys/models/customer/customer.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
pysainsburys.models.customer.customer.Customer
dataclass
¶
Authenticated Sainsbury's Groceries Online customer profile.
A customer is returned by :meth:~pysainsburys.Sainsburys.get_customer and
exposes convenience accessors for basket, favourites, orders, and slot
resources when bound to a client.
Attributes:
| Name | Type | Description |
|---|---|---|
user_id |
str
|
Commerce platform user identifier. |
customer_id |
str | None
|
Customer record identifier when distinct from |
identity_id |
str | None
|
Identity provider subject identifier. |
email |
str | None
|
Account email address. |
family_name |
str | None
|
Family name from the profile. |
given_name |
str | None
|
Given name from the profile. |
primary_phone |
str | None
|
Primary contact telephone number. |
postcode |
str | None
|
Default delivery postcode when set. |
title |
str | None
|
Salutation or title when provided. |
is_very_important_customer |
bool
|
VIP flag from the API. |
delivery_pass_expiry_date |
str | None
|
Delivery pass expiry when subscribed. |
personalization_id |
str | None
|
Personalisation token for recommendations. |
has_nectar_associated |
bool
|
Whether a Nectar card is associated. |
has_nectar_linked |
bool
|
Whether Nectar is fully linked for rewards. |
is_digital_nectar |
bool
|
Whether the account uses digital Nectar. |
Source code in pysainsburys/models/customer/customer.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
basket
property
¶
Basket fetch and clear helpers for this customer.
display_name
property
¶
Return a human-friendly display name.
favourites
property
¶
Favourites list and add/remove helpers for this customer.
nectar
property
¶
Nectar bonus offers and Your Nectar Price helpers.
orders
property
¶
Order history, latest order, and per-order status.
slots
property
¶
Delivery and collection slot listing helpers.
__iter__()
¶
Allow dict(customer) conversion.
Source code in pysainsburys/models/customer/customer.py
184 185 186 | |
from_dict(data, *, api=None)
classmethod
¶
Parse a customer profile from grocery API JSON.
Source code in pysainsburys/models/customer/customer.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
to_dict()
¶
Serialise the customer profile to a plain dictionary.
Source code in pysainsburys/models/customer/customer.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
Order¶
pysainsburys.models.order
¶
Order domain models.
OrderList
dataclass
¶
A paginated list of customer orders.
Source code in pysainsburys/models/order/order.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
__iter__()
¶
Allow dict(order_list) conversion.
Source code in pysainsburys/models/order/order.py
84 85 86 | |
from_dict(data)
classmethod
¶
Parse an order list from grocery API JSON.
Source code in pysainsburys/models/order/order.py
69 70 71 72 73 74 75 | |
to_dict()
¶
Serialise the order list to a plain dictionary.
Source code in pysainsburys/models/order/order.py
77 78 79 80 81 82 | |
OrderStatus
dataclass
¶
Live status for the customer's active order slot.
Attributes:
| Name | Type | Description |
|---|---|---|
order_uid |
str | None
|
Identifier for the active order. |
is_cutoff |
bool
|
Whether the amend cutoff has passed. |
is_in_amend_mode |
bool
|
Whether the order can still be amended. |
cutoff_time |
str | None
|
Amend cutoff timestamp when provided. |
slot_end_time |
str | None
|
Reserved slot end timestamp. |
slot_start_time |
str | None
|
Reserved slot start timestamp. |
order_type |
str | None
|
Delivery or collection type string. |
total |
float
|
Current order total in pounds sterling. |
failed_payments |
list[dict[str, Any]]
|
Payment failure payloads from the API. |
Source code in pysainsburys/models/order/order.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
__iter__()
¶
Allow dict(order_status) conversion.
Source code in pysainsburys/models/order/order.py
146 147 148 | |
from_dict(data)
classmethod
¶
Parse order status from grocery API JSON.
Source code in pysainsburys/models/order/order.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
to_dict()
¶
Serialise order status to a plain dictionary.
Source code in pysainsburys/models/order/order.py
132 133 134 135 136 137 138 139 140 141 142 143 144 | |
OrderSummary
dataclass
¶
Summary information for a past or active order.
Attributes:
| Name | Type | Description |
|---|---|---|
order_id |
str
|
Primary order identifier used in URLs and APIs. |
order_uid |
str | None
|
Alternate order uid when returned separately. |
status |
str | None
|
Human-readable order status string. |
total |
float | None
|
Order total in pounds sterling. |
slot_start_time |
str | None
|
Reserved slot start timestamp. |
slot_end_time |
str | None
|
Reserved slot end timestamp. |
slot_type |
str | None
|
Delivery or collection slot type. |
Source code in pysainsburys/models/order/order.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
from_dict(data)
classmethod
¶
Parse an order summary from grocery API JSON.
Source code in pysainsburys/models/order/order.py
36 37 38 39 40 41 42 43 44 45 46 47 | |
to_dict()
¶
Serialise the order summary to a plain dictionary.
Source code in pysainsburys/models/order/order.py
49 50 51 52 53 54 55 56 57 58 59 | |
pysainsburys.orders.Orders
¶
Order history and status for a customer.
Source code in pysainsburys/orders.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
cached
property
¶
Return the last fetched order list, if any.
latest
property
¶
Return a handle for the most recent order.
__getitem__(order_id)
¶
Return a handle for an order by id.
Source code in pysainsburys/orders.py
84 85 86 | |
fetch(*, page_number=1, page_size=20)
async
¶
Fetch a page of order history.
Source code in pysainsburys/orders.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
Slot¶
pysainsburys.models.slot
¶
Slot domain models.
DeliverySlot
dataclass
¶
A single bookable delivery or collection time window.
Attributes:
| Name | Type | Description |
|---|---|---|
slot_uid |
str | None
|
Stable slot identifier from the API when provided. |
start_time |
str | None
|
Slot start timestamp (ISO-8601). |
end_time |
str | None
|
Slot end timestamp (ISO-8601). |
price |
float | None
|
Customer-facing slot price in pounds sterling. |
unqualified_price |
float | None
|
List price before delivery-pass or promotions. |
is_available |
bool
|
Whether the slot can be booked. |
status |
str | None
|
Raw availability status string from the API. |
slot_type |
str | None
|
Delivery or collection type when returned per slot. |
Source code in pysainsburys/models/slot/slot.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
__iter__()
¶
Allow dict(slot) conversion.
Source code in pysainsburys/models/slot/slot.py
94 95 96 | |
from_dict(data)
classmethod
¶
Parse a slot entry from grocery API JSON.
Source code in pysainsburys/models/slot/slot.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
to_dict()
¶
Serialise the slot to a plain dictionary.
Source code in pysainsburys/models/slot/slot.py
81 82 83 84 85 86 87 88 89 90 91 92 | |
LocationContext
dataclass
¶
Location context used when listing slots.
Source code in pysainsburys/models/slot/slot.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | |
__iter__()
¶
Allow dict(location_context) conversion.
Source code in pysainsburys/models/slot/slot.py
314 315 316 | |
from_dict(data)
classmethod
¶
Parse location context JSON.
Source code in pysainsburys/models/slot/slot.py
291 292 293 294 295 296 297 298 299 300 301 | |
to_dict()
¶
Serialise location context to a plain dictionary.
Source code in pysainsburys/models/slot/slot.py
303 304 305 306 307 308 309 310 311 312 | |
SlotDay
dataclass
¶
Slots grouped for a single calendar day.
Source code in pysainsburys/models/slot/slot.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
available_slots
property
¶
Return only slots marked as available.
__iter__()
¶
Allow dict(day) conversion.
Source code in pysainsburys/models/slot/slot.py
136 137 138 | |
from_dict(data)
classmethod
¶
Parse a day entry from grocery API JSON.
Source code in pysainsburys/models/slot/slot.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
to_dict()
¶
Serialise the day to a plain dictionary.
Source code in pysainsburys/models/slot/slot.py
128 129 130 131 132 133 134 | |
SlotReservation
dataclass
¶
Current slot reservation state for the customer.
Source code in pysainsburys/models/slot/slot.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
__iter__()
¶
Allow dict(reservation) conversion.
Source code in pysainsburys/models/slot/slot.py
275 276 277 | |
from_dict(data)
classmethod
¶
Parse slot reservation JSON.
Source code in pysainsburys/models/slot/slot.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
to_dict()
¶
Serialise the reservation to a plain dictionary.
Source code in pysainsburys/models/slot/slot.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
SlotWeek
dataclass
¶
Week view of delivery or collection slots.
Attributes:
| Name | Type | Description |
|---|---|---|
slot_type |
SlotType | None
|
Requested slot type ( |
week_start_date |
str | None
|
First day of the returned week when provided. |
store_identifier |
str | None
|
Fulfilment store number used for the query. |
postcode |
str | None
|
Delivery postcode context when applicable. |
location_uid |
str | None
|
Click-and-collect location uid when applicable. |
days |
list[SlotDay]
|
Day groupings with nested slot windows. |
Source code in pysainsburys/models/slot/slot.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
available_slots
property
¶
Flatten only available slots across days.
slots
property
¶
Flatten all slots across days.
__iter__()
¶
Allow dict(slot_week) conversion.
Source code in pysainsburys/models/slot/slot.py
217 218 219 | |
from_dict(data, *, slot_type=None, store_identifier=None, postcode=None, location_uid=None)
classmethod
¶
Parse a slot week from grocery API JSON.
Source code in pysainsburys/models/slot/slot.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
to_dict()
¶
Serialise the slot week to a plain dictionary.
Source code in pysainsburys/models/slot/slot.py
206 207 208 209 210 211 212 213 214 215 | |
pysainsburys.slots.Slots
¶
List delivery and collection slots for a customer.
Source code in pysainsburys/slots.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | |
cached
property
¶
Return the last fetched slot week, if any.
cached_reservation
property
¶
Return the last fetched slot reservation, if any.
fetch_location_context()
async
¶
Fetch location context used when choosing delivery or collection.
Source code in pysainsburys/slots.py
147 148 149 150 151 152 153 154 155 | |
fetch_reservation(*, order_uid=None)
async
¶
Fetch the customer's current slot reservation state.
Source code in pysainsburys/slots.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
list(*, slot_type, store_identifier=None, postcode=None, location_uid=None, week_start_date=None, order_uid=None, use_location_context=True)
async
¶
List available slots for delivery or click-and-collect.
When use_location_context is true (default), missing
store_identifier, postcode, or location_uid values are
filled from :meth:fetch_location_context when available.
Source code in pysainsburys/slots.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | |
list_collection(*, store_identifier=None, location_uid=None, week_start_date=None, order_uid=None, use_location_context=True)
async
¶
List click-and-collect slots.
Source code in pysainsburys/slots.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | |
list_delivery(*, postcode=None, store_identifier=None, week_start_date=None, order_uid=None, use_location_context=True)
async
¶
List home-delivery slots.
Source code in pysainsburys/slots.py
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
reserve(slot, *, slot_type=None, start_time=None, end_time=None, store_identifier=None, postcode=None, location_uid=None, order_uid=None, use_location_context=True)
async
¶
Reserve a slot, or replace the current reservation with another slot.
This write path is inferred from static Android models and has not yet been validated against a live commerce session.
Source code in pysainsburys/slots.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
validate(*, order_uid=None)
async
¶
Validate the customer's current slot reservation.
Source code in pysainsburys/slots.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
Store¶
pysainsburys.models.store
¶
Store and in-store product models.
FinderPage
dataclass
¶
Pagination metadata from the Product Finder API.
Attributes:
| Name | Type | Description |
|---|---|---|
size |
int
|
Page size requested. |
number |
int
|
Zero-based page index returned by Product Finder. |
total_elements |
int
|
Total matching elements across all pages. |
total_pages |
int
|
Total number of pages available. |
Source code in pysainsburys/models/store/store.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
from_dict(data)
classmethod
¶
Parse Product Finder pagination JSON.
Source code in pysainsburys/models/store/store.py
34 35 36 37 38 39 40 41 42 43 | |
to_dict()
¶
Serialise pagination metadata to a plain dictionary.
Source code in pysainsburys/models/store/store.py
45 46 47 48 49 50 51 52 | |
Store
dataclass
¶
A Sainsbury's store from Product Finder or click-and-collect.
When bound to a :class:~pysainsburys.Sainsburys client, a store can
search in-store stock via :meth:search_products.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Store display name. |
address1 |
str
|
Primary address line. |
city |
str
|
Town or city. |
post_code |
str
|
UK postcode. |
is_available |
bool
|
Whether the store accepts online orders or collection. |
store_id |
str
|
Product Finder store identifier. |
store_number |
str | None
|
Internal store number for click-and-collect locations. |
location_uid |
str | None
|
Click-and-collect location uid when applicable. |
address2 |
str | None
|
Secondary address line. |
county |
str | None
|
County or region. |
opening_hours |
str | None
|
Opening hours text when provided. |
distance |
float | None
|
Distance from the search origin in miles or kilometres. |
telephone |
str | None
|
Store telephone number. |
latitude |
float | None
|
WGS-84 latitude when available. |
longitude |
float | None
|
WGS-84 longitude when available. |
is_open |
bool | None
|
Whether the store is currently open when known. |
click_and_collect_available |
bool
|
Whether click-and-collect is offered. |
Source code in pysainsburys/models/store/store.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
product_finder_id
property
¶
Return the Product Finder store id used for in-store product search.
bind_api(api)
¶
Attach a client for in-store product lookups.
Source code in pysainsburys/models/store/store.py
164 165 166 167 | |
from_collect_dict(data, *, api=None)
classmethod
¶
Parse a click-and-collect store location from grocery API JSON.
Source code in pysainsburys/models/store/store.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
from_dict(data, *, api=None)
classmethod
¶
Parse a store from Product Finder or click-and-collect JSON.
Source code in pysainsburys/models/store/store.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
search_products(keyword, *, page=1, page_size=20)
async
¶
Search in-store products with aisle and stock for this store.
Source code in pysainsburys/models/store/store.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
to_dict()
¶
Serialise the store to a plain dictionary.
Source code in pysainsburys/models/store/store.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
StoreList
dataclass
¶
A paginated list of stores.
Source code in pysainsburys/models/store/store.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
from_dict(data, *, api=None)
classmethod
¶
Parse stores from Product Finder or click-and-collect JSON.
Source code in pysainsburys/models/store/store.py
227 228 229 230 231 232 233 234 235 236 237 238 239 | |
to_dict()
¶
Serialise the store list to a plain dictionary.
Source code in pysainsburys/models/store/store.py
241 242 243 244 245 246 247 248 249 250 | |
StoreProduct
dataclass
¶
A product with in-store aisle and stock information.
Attributes:
| Name | Type | Description |
|---|---|---|
product_code |
str
|
In-store product code used by Product Finder. |
name |
str
|
Shelf label product name. |
stock |
str
|
Stock status string (for example |
price |
float | None
|
Shelf price in pounds sterling. |
price_per_unit |
float | None
|
Normalised unit price when provided. |
unit_of_measure |
str | None
|
Unit label for |
aisle |
str | None
|
Aisle number or location hint in the store. |
image_url |
str | None
|
Product image URL when available. |
is_nectar_price |
bool
|
Whether the price is a Nectar offer. |
promotions |
list[dict[str, Any]]
|
Raw promotion payloads from Product Finder. |
Source code in pysainsburys/models/store/store.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |
from_dict(data)
classmethod
¶
Parse an in-store product from Product Finder JSON.
Source code in pysainsburys/models/store/store.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | |
to_dict()
¶
Serialise the in-store product to a plain dictionary.
Source code in pysainsburys/models/store/store.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |
StoreProductList
dataclass
¶
In-store product search results for a chosen store.
Source code in pysainsburys/models/store/store.py
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |
__iter__()
¶
Allow dict(store_product_list) conversion.
Source code in pysainsburys/models/store/store.py
346 347 348 | |
from_dict(data)
classmethod
¶
Parse in-store product results from Product Finder JSON.
Source code in pysainsburys/models/store/store.py
326 327 328 329 330 331 332 333 334 335 336 | |
to_dict()
¶
Serialise in-store product results to a plain dictionary.
Source code in pysainsburys/models/store/store.py
338 339 340 341 342 343 344 | |
bind_store(api, store)
¶
Attach an API client to a store for in-store product lookups.
Source code in pysainsburys/models/store/store.py
351 352 353 | |
bind_stores(api, stores)
¶
Attach an API client to each store in a list.
Source code in pysainsburys/models/store/store.py
356 357 358 359 360 | |
pysainsburys.models.store.store.Store
dataclass
¶
A Sainsbury's store from Product Finder or click-and-collect.
When bound to a :class:~pysainsburys.Sainsburys client, a store can
search in-store stock via :meth:search_products.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Store display name. |
address1 |
str
|
Primary address line. |
city |
str
|
Town or city. |
post_code |
str
|
UK postcode. |
is_available |
bool
|
Whether the store accepts online orders or collection. |
store_id |
str
|
Product Finder store identifier. |
store_number |
str | None
|
Internal store number for click-and-collect locations. |
location_uid |
str | None
|
Click-and-collect location uid when applicable. |
address2 |
str | None
|
Secondary address line. |
county |
str | None
|
County or region. |
opening_hours |
str | None
|
Opening hours text when provided. |
distance |
float | None
|
Distance from the search origin in miles or kilometres. |
telephone |
str | None
|
Store telephone number. |
latitude |
float | None
|
WGS-84 latitude when available. |
longitude |
float | None
|
WGS-84 longitude when available. |
is_open |
bool | None
|
Whether the store is currently open when known. |
click_and_collect_available |
bool
|
Whether click-and-collect is offered. |
Source code in pysainsburys/models/store/store.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
product_finder_id
property
¶
Return the Product Finder store id used for in-store product search.
bind_api(api)
¶
Attach a client for in-store product lookups.
Source code in pysainsburys/models/store/store.py
164 165 166 167 | |
from_collect_dict(data, *, api=None)
classmethod
¶
Parse a click-and-collect store location from grocery API JSON.
Source code in pysainsburys/models/store/store.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
from_dict(data, *, api=None)
classmethod
¶
Parse a store from Product Finder or click-and-collect JSON.
Source code in pysainsburys/models/store/store.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
search_products(keyword, *, page=1, page_size=20)
async
¶
Search in-store products with aisle and stock for this store.
Source code in pysainsburys/models/store/store.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
to_dict()
¶
Serialise the store to a plain dictionary.
Source code in pysainsburys/models/store/store.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
Exceptions¶
pysainsburys.exceptions
¶
Exceptions for Sainsbury's GOL API.
AccessDeniedError
¶
Bases: AuthError
Resource owner or policy denied the request.
Source code in pysainsburys/exceptions.py
117 118 | |
AuthError
¶
Bases: Exception
General authentication error.
Source code in pysainsburys/exceptions.py
56 57 | |
BrowserLoginRequiredError
¶
Bases: InteractionRequiredError
Interactive browser login is required to continue.
When raised, open :attr:authorization_url in a desktop browser, sign in,
then call :meth:GOLAuth.finish_login with the redirect URL or code.
Source code in pysainsburys/exceptions.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
CommerceSessionError
¶
Bases: AuthError
Error exchanging OAuth tokens for a commerce session.
Source code in pysainsburys/exceptions.py
137 138 | |
ConfirmationRedirectError
¶
Bases: AuthError
Error confirming login with redirect.
Source code in pysainsburys/exceptions.py
141 142 | |
ExpiredAccessTokenError
¶
Bases: AuthError
401 Unauthorized — access token or commerce session expired.
Source code in pysainsburys/exceptions.py
89 90 | |
HttpException
¶
Bases: Exception
General HTTP error storing status and response.
Source code in pysainsburys/exceptions.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
errors
property
¶
Return structured API errors when the body matches GOL error JSON.
InteractionRequiredError
¶
Bases: AuthError
Interactive user action is required to continue.
Source code in pysainsburys/exceptions.py
121 122 | |
InvalidClientError
¶
Bases: AuthError
Client authentication failed.
Source code in pysainsburys/exceptions.py
101 102 | |
InvalidGrantError
¶
Bases: AuthError
OAuth grant expired or invalid.
Source code in pysainsburys/exceptions.py
93 94 | |
InvalidRequestError
¶
Bases: AuthError
OAuth request is malformed or missing required parameters.
Source code in pysainsburys/exceptions.py
97 98 | |
InvalidScopeError
¶
Bases: AuthError
Requested OAuth scope is invalid, unknown, or malformed.
Source code in pysainsburys/exceptions.py
113 114 | |
LoginRequiredError
¶
Bases: AuthError
User sign-in is required to continue.
Source code in pysainsburys/exceptions.py
125 126 | |
MFARequiredError
¶
Bases: InteractionRequiredError
MFA is required to complete the login flow.
Raised after :meth:GOLAuth.request_mfa_code has triggered delivery of
the verification code. Call :meth:GOLAuth.send_mfa_request with the
code received by the user.
Source code in pysainsburys/exceptions.py
163 164 165 166 167 168 169 170 | |
NotBoundError
¶
Bases: Exception
Domain object is not bound to an authenticated client.
Source code in pysainsburys/exceptions.py
177 178 | |
ParseError
¶
Bases: Exception
Error parsing an API response into a domain model.
Source code in pysainsburys/exceptions.py
173 174 | |
SessionRequiredError
¶
Bases: AuthError
Commerce session headers or cookies are missing.
Source code in pysainsburys/exceptions.py
129 130 | |
TokenRequestError
¶
Bases: AuthError
Error requesting a token from the token server.
Source code in pysainsburys/exceptions.py
133 134 | |
UnauthorizedClientError
¶
Bases: AuthError
Client is not authorized for this grant type or flow.
Source code in pysainsburys/exceptions.py
105 106 | |
UnknownEndpointError
¶
Bases: HttpException
Unexpected HTTP status from a known endpoint.
Source code in pysainsburys/exceptions.py
85 86 | |
UnsupportedGrantTypeError
¶
Bases: AuthError
OAuth grant type is not supported.
Source code in pysainsburys/exceptions.py
109 110 | |
format_http_error_message(status, response, *, parsed=None)
¶
Format a human-readable HTTP error message.
Source code in pysainsburys/exceptions.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
parse_error_response(response)
¶
Parse an HTTP error body as JSON when possible.
Source code in pysainsburys/exceptions.py
9 10 11 12 13 14 15 16 17 18 19 20 | |
Configuration¶
pysainsburys.config
¶
Connection settings for Sainsbury's GOL API.
Config
dataclass
¶
Where and how to connect to the grocery API.
Source code in pysainsburys/config.py
12 13 14 15 16 17 | |