Unofficial Python wrapper for SOK / S-Kaupat APIs
Reason this release was yanked:
accidentally left sok import that does not exist
Project description
sokpy
A Python wrapper for the SOK (S-Group) API, providing easy access to store information, product data, and pricing from Finnish S-Group stores.
Features
- Store Management: Retrieve information about S-Group stores by brand or location
- Product Information: Get detailed product data including pricing, availability, and specifications
- Pricing Data: Access current prices, campaign prices, and historical pricing information
- Category Browsing: Browse products by categories within specific stores
Installation
pip install sokpy
Quick Start
from sokpy import SOKAPI
# Initialize the API
api = SOKAPI()
# Get a product by ID
product = api.get_product_by_id("some-product-id")
print(f"Product: {product.name}")
print(f"Price: {product.price} €")
# Get stores by brand
stores = api.get_stores_by_brand("S-Market")
for store in stores[:5]: # Show first 5 stores
print(f"Store: {store.name} - {store.location}")
# Get a specific store
store = api.get_store_by_id("some-store-id")
print(f"Store: {store.name}")
print(f"Opening hours: {store.weeklyOpeningHours}")
API Reference
SOKAPI
The main API class for interacting with SOK services.
Methods
get_product_by_id(product_id: str) -> SOKProduct: Retrieve a product by its IDget_all_stores() -> dict: Get all stores organized by brandget_stores_by_brand(brand: str) -> list[SOKStore]: Get stores for a specific brandget_store_by_id(store_id: str) -> SOKStore: Get a specific store by ID
SOKProduct
Represents a product with detailed information.
Attributes
product_id: Unique product identifiersokId: SOK-specific product IDname: Product nameprice: Current priceavailability: Product availability statuspricing: SOKPricing object with detailed pricing informationbasicQuantityUnit: Unit of measurementcomparisonPrice: Price per comparison unitcomparisonUnit: Unit for price comparisonpriceUnit: Unit for pricingisAgeLimitedByAlcohol: Whether the product is age-restrictedfrozen: Whether the product is frozenpackagingLabelCodes: List of packaging label codesbrandName: Brand namepackagingLabels: List of packaging labelsslug: URL slug for the product
SOKPricing
Contains detailed pricing information for a product.
Attributes
campaignPrice: Current campaign pricelowest30DayPrice: Lowest price in the last 30 dayscampaignPriceValidUntil: Campaign validity dateregularPrice: Regular pricecurrentPrice: Current pricesalesUnit: Unit for salescomparisonPrice: Price for comparisoncomparisonUnit: Unit for comparisonisApproximatePrice: Whether price is approximatedepositPrice: Deposit pricequantityMultiplier: Quantity multiplier
SOKStore
Represents a store with location and product information.
Attributes
store_id: Unique store identifierslug: URL slugname: Store namebrand: Store brand (e.g., "S-Market", "Prisma")domains: List of domainslocation: Street addresspostcode: Postal codepostcodeName: City nameweeklyOpeningHours: Opening hours for each daycategories: SOKCategories object for browsing products
Methods
get_filtered_products(slug: str, limit: int = 10) -> list[SOKProduct]: Get products from a specific category
Examples
Finding Stores Near You
api = SOKAPI()
# Get all Prisma stores
prisma_stores = api.get_stores_by_brand("Prisma")
print(f"Found {len(prisma_stores)} Prisma stores")
# Display store information
for store in prisma_stores[:3]:
print(f"{store.name} - {store.location}, {store.postcode} {store.postcodeName}")
Product Price Comparison
api = SOKAPI()
product = api.get_product_by_id("example-product-id")
if product.pricing:
pricing = product.pricing
print(f"Product: {product.name}")
print(f"Regular Price: {pricing.regularPrice} €")
print(f"Current Price: {pricing.currentPrice} €")
if pricing.campaignPrice:
print(f"Campaign Price: {pricing.campaignPrice} € (valid until {pricing.campaignPriceValidUntil})")
print(f"Lowest 30-day Price: {pricing.lowest30DayPrice} €")
Browsing Store Categories
api = SOKAPI()
store = api.get_store_by_id("example-store-id")
# Get products from a specific category
dairy_products = store.get_filtered_products("maito-tuotteet", limit=20)
for product in dairy_products:
print(f"{product.name}: {product.price} €")
or
api = SOKAPI()
store = api.get_store_by_id("example-store-id")
#Get products from a specific category
chewing_gums = store.categories.karkit_ja_suklaat.purukumit.products()
for product in chewing_gums:
print(f"{product.name}: {product.price} €")
Requirements
- Python 3.7+
- requests
- beautifulsoup4
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Disclaimer
This package is not officially affiliated with S-Group or SOK. Use responsibly and in accordance with S-Group's terms of service.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sokpy-0.1.0.tar.gz.
File metadata
- Download URL: sokpy-0.1.0.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5783fef2c17b335bbcab06426846cf864fd231456d1328fa92d221b55b5d962
|
|
| MD5 |
bb7c1090abf61e8d80c4b5630c1f91ab
|
|
| BLAKE2b-256 |
52ac52ac33cde89f0c385860b3a79ac6cb1cf2905580b250eb071b327145fb4f
|
File details
Details for the file sokpy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sokpy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19cbb67371f6afc1f1f5ac99b069f8d692389e2ef16c576e41a5e1008d3e1063
|
|
| MD5 |
893b8d09d5be24d6a6071f20bf23ed47
|
|
| BLAKE2b-256 |
20f277781ad2fcc6fdbd3ddb52359516c090599453c5889377043e01b54fda90
|