Sainsbury's SmartShop Python lib
Find a file
2026-03-17 13:54:14 +00:00
libssa shop: use v2 to add items 2026-03-13 19:50:30 +00:00
.gitignore Remove repetition in the Shop class; Add more endpoints; Fix imports 2025-08-11 02:42:18 +01:00
LICENSE commit message 2025-11-01 04:16:38 +00:00
pyproject.toml edit readme and use semver 2026-03-17 13:54:14 +00:00
README.md edit readme and use semver 2026-03-17 13:54:14 +00:00

libssa

Python wrapper for the Sainsbury's SmartShop API.

Goals:

  • Allow API interaction

Non-goals:

  • Be identical to the official app(s)
  • Provide a full data model
  • 100% coverage - I add endpoints as I use them

Also, this is partly written by decompiling the app to port authentication code. If that's legally hairy or something, find another library.

Installation

pip install git+https://codeberg.org/plate/libssa

Usage

Use the Client class:

from libssa.client import Client
c = Client()

This defaults to the Android client. You can also supply a custom client ID and key (likely not needed):

from libssa import constants
c = Client(client_id=constants.HANDSET_CLIENT_ID, rsa_key=constants.HANDSET_KEY)
c = Client(client_id="ss_whatever_mobile_1k", rsa_key="-----BEGIN RSA PUBLIC KEY-----...")

Then you can log in as needed:

# Nectar grant type (use last 11 digits: 9623000 12345678900)
# 00000000063 is a real card you can test with!
c.login("nectar_card", nectar_card="00000000063")
# Username/password grant type
c.login("password", username="username@example.com", password="password")

Please refer to the code for other ways to authenticate.

Starting a shop returns a Shop (libssa.shop.Shop) object:

s = c.create_shop("1234") # start shopping at your store id
s.add_item("123456", 10) # add 10 of this item
s.finish() # finish the shop
s.move_to_pos("12") # send it to POS 12

When a request fails, you want to catch libssa.errors.RequestError, which has the status_code and response (requests.Response) properties.