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.0.tar.gz
(7.3 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.0.tar.gz.
File metadata
- Download URL: channel3_sdk-0.1.0.tar.gz
- Upload date:
- Size: 7.3 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 |
18db888b7ba6b4d68d07c2ff21dbe42f488fb632e79e23040d54862a27506cb0
|
|
| MD5 |
62cf4a0a95c9eabbb83dca887179f8fc
|
|
| BLAKE2b-256 |
14ec463a3dd251e3b30dfe02923520e10a8108063c7bfe8b9221d127fe2f4daa
|
File details
Details for the file channel3_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: channel3_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.5 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 |
ad5d59991d3a8d802d7695e0353374ca6bc7481345f8e866ac4661c37bc72433
|
|
| MD5 |
b9527ee235a8beb666ab0ca14160b6de
|
|
| BLAKE2b-256 |
8a6077c922ccdadff170e3c7b144a970668c58569ad977567cb16dae669092c8
|