Python SDK
Last updated · Changelog · OpenAPI spec · Markdown
Our official Python SDK provides a convenient way to interact with the ShopSavvy Data API from Python applications with full type safety and modern async support.
Installation
pip install shopsavvy-sdkBasic Usage
from shopsavvy import create_client
# Initialize the client
client = create_client("ss_live_your_api_key_here")
# Look up a product by barcode
product = client.get_product_details("012345678901")
print(product.data.name)
# Get current prices from all retailers
offers = client.get_current_offers("012345678901")
for offer in offers.data:
print(f"{offer.retailer}: {offer.price}")
# Get price history
history = client.get_price_history(
"012345678901",
"2024-01-01",
"2024-01-31"
)Features
- Full type safety with Pydantic models
- Modern HTTP client with automatic retries
- Comprehensive error handling
- Rails integration support
- Context manager support for automatic cleanup
- Python 2.7+ compatibility
Context Manager Usage
with create_client("ss_live_your_api_key_here") as client:
product = client.get_product_details("012345678901")
print(product.data.name)
# Client automatically closedError Handling
from shopsavvy import create_client, NotFoundError, AuthenticationError
try:
client = create_client("ss_live_your_api_key_here")
product = client.get_product_details("invalid-identifier")
except NotFoundError:
print("Product not found")
except AuthenticationError:
print("Invalid API key")
except Exception as e:
print(f"Unexpected error: {e}")Was this page helpful?