The official Python SDK for Channel3 AI Shopping API
Project description
Channel3 Python SDK
The official Python SDK for the Channel3 AI Shopping API.
Installation
pip install channel3-sdk
Quick Start
Synchronous Client
import os
from channel3_sdk import Channel3Client
# Initialize the client
client = Channel3Client(api_key="your_api_key_here")
# Or use environment variable: CHANNEL3_API_KEY
# Search for products
products = client.search(query="blue denim jacket")
for product in products:
print(f"Product: {product.title}")
print(f"Brand: {product.brand_name}")
print(f"Price: ${product.offers[0].price.price}")
print("---")
# Get detailed product information
product_detail = client.get_product("prod_123456")
print(f"Detailed info for: {product_detail.title}")
print(f"Materials: {product_detail.materials}")
print(f"Key features: {product_detail.key_features}")
Asynchronous Client
import asyncio
from channel3_sdk import AsyncChannel3Client
async def main():
# Initialize the async client
client = AsyncChannel3Client(api_key="your_api_key_here")
# Search for products
products = await client.search(query="running shoes")
for product in products:
print(f"Product: {product.title}")
print(f"Score: {product.score}")
# Get detailed product information
if products:
product_detail = await client.get_product(products[0].id)
print(f"Gender: {product_detail.gender}")
# Run the async function
asyncio.run(main())
Advanced Usage
Visual Search
# Search by image URL
products = client.search(image_url="https://example.com/image.jpg")
# Search by base64 image
with open("image.jpg", "rb") as f:
import base64
base64_image = base64.b64encode(f.read()).decode()
products = client.search(base64_image=base64_image)
Multimodal Search
# Combine text and image search
products = client.search(
query="blue denim jacket",
image_url="https://example.com/jacket.jpg"
)
Search with Filters
from channel3_sdk import SearchFilters
# Create search filters
filters = SearchFilters(
colors=["blue", "navy"],
materials=["cotton", "denim"],
min_price=50.0,
max_price=200.0
)
# Search with filters
products = client.search(
query="jacket",
filters=filters,
limit=10
)
API Reference
Client Classes
Channel3Client
Synchronous client for the Channel3 API.
Methods:
search(query=None, image_url=None, base64_image=None, filters=None, limit=20)→List[Product]get_product(product_id)→ProductDetail
AsyncChannel3Client
Asynchronous client for the Channel3 API.
Methods:
async search(query=None, image_url=None, base64_image=None, filters=None, limit=20)→List[Product]async get_product(product_id)→ProductDetail
Models
Product
id: str- Unique product identifierscore: float- Search relevance scorebrand_name: str- Brand nametitle: str- Product titledescription: str- Product descriptionimage_url: str- Main product image URLoffers: List[MerchantOffering]- Available purchase optionsfamily: List[FamilyMember]- Related products
ProductDetail
brand_id: str- Brand identifierbrand_name: str- Brand nametitle: str- Product titledescription: str- Product descriptionimage_urls: List[str]- Product image URLsmerchant_offerings: List[MerchantOffering]- Purchase optionsgender: Literal["na", "men", "women"]- Target gendermaterials: Optional[List[str]]- Product materialskey_features: List[str]- Key product featuresfamily_members: List[FamilyMember]- Related products
SearchFilters
colors: Optional[List[str]]- Color filtersmaterials: Optional[List[str]]- Material filtersmin_price: Optional[float]- Minimum pricemax_price: Optional[float]- Maximum price
MerchantOffering
url: str- Purchase URLmerchant_name: str- Merchant nameprice: Price- Price informationavailability: AvailabilityStatus- Availability status
Price
price: float- Current pricecompare_at_price: Optional[float]- Original price (if discounted)currency: str- Currency code
Error Handling
The SDK provides specific exception types for different error conditions:
from channel3_sdk import (
Channel3AuthenticationError,
Channel3ValidationError,
Channel3NotFoundError,
Channel3ServerError,
Channel3ConnectionError
)
try:
products = client.search(query="shoes")
except Channel3AuthenticationError:
print("Invalid API key")
except Channel3ValidationError as e:
print(f"Invalid request: {e.message}")
except Channel3NotFoundError:
print("Resource not found")
except Channel3ServerError:
print("Server error - please try again later")
except Channel3ConnectionError:
print("Connection error - check your internet connection")
Environment Variables
CHANNEL3_API_KEY- Your Channel3 API key
Requirements
- Python 3.8+
- requests
- aiohttp
- pydantic
License
MIT License
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
channel3_sdk-0.1.1.tar.gz
(7.4 kB
view details)
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 channel3_sdk-0.1.1.tar.gz.
File metadata
- Download URL: channel3_sdk-0.1.1.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.13.0 Darwin/24.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70e88d0ae0a6315a13364ce4b79ee9bb5fae307535f72b2995edf0a77a6ccfe1
|
|
| MD5 |
8572d2df6119df48a58f482991b5c238
|
|
| BLAKE2b-256 |
f701ba3e70e72b65d1d01ed623abda54d437c84e2637597ad0cd4f75acf51161
|
File details
Details for the file channel3_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: channel3_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.13.0 Darwin/24.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5a9786b175433585c2d64713ee6fc462bddc058ad0a87022435a1e39c06fdd9
|
|
| MD5 |
14c7869fd490d096ed6c383b17371822
|
|
| BLAKE2b-256 |
0283c321b57de8e05773bfd7e7754002d33f3a92a457cc3701b92fdee8442d11
|