FauxShield Python SDK
Official Python client for the FauxShield anti-counterfeiting platform API.
Requirements
- Python 3.9+
Installation
pip install fauxshield
Or from source:
pip install -e packages/python-sdk
Quick Start
from fauxshield import FauxShieldClient
client = FauxShieldClient(api_key="fs_live_your_api_key")
# List products with auto-pagination
for product in client.products.list():
print(product["name"])
# Create a product
product = client.products.create(
name="Premium Widget",
sku="WDG-001",
category="electronics",
)
# Create a batch
batch = client.batches.create(
product_id=product["id"],
quantity=1000,
)
# Generate identities (QR tokens)
identities = client.identities.generate(
batch_id=batch["id"],
quantity=100,
)
# Check fraud alerts
for alert in client.fraud_alerts.list(status="open"):
print(f"Alert: {alert['type']} - {alert['description']}")
Context Manager
with FauxShieldClient(api_key="fs_live_...") as client:
products = client.products.list().to_list()
Configuration
client = FauxShieldClient(
api_key="fs_live_...",
base_url="https://fauxshield.vercel.app/api/v1", # default
timeout=30.0, # request timeout in seconds
max_retries=3, # retry attempts for 5xx/network errors
)
Resources
| Resource | Methods |
|---|---|
client.products |
list, get, create, update, delete |
client.batches |
list, get, create, update, recall |
client.identities |
list, generate |
client.fraud_alerts |
list, get, resolve |
client.events |
list |
client.webhooks |
list, create, update, delete, rotate_secret, test, list_deliveries |
client.api_keys |
list, create, revoke |
Pagination
All list methods return a PaginatedIterator that automatically fetches pages:
# Iterate one by one (fetches pages lazily)
for product in client.products.list(page_size=50):
process(product)
# Or collect all into a list
all_products = client.products.list().to_list()
Error Handling
from fauxshield import (
FauxShieldError,
AuthenticationError,
NotFoundError,
RateLimitError,
ValidationError,
)
try:
product = client.products.get("nonexistent")
except NotFoundError as e:
print(f"Not found: {e.message}")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after}s")
except ValidationError as e:
print(f"Invalid request: {e.fields}")
except AuthenticationError:
print("Check your API key")
except FauxShieldError as e:
print(f"API error [{e.status_code}]: {e.message}")
Webhook Verification
Verify incoming webhook signatures in your endpoint handler:
from fauxshield import verify_webhook_signature, WebhookVerificationError
try:
verify_webhook_signature(
payload=request.body,
signature=request.headers["X-FauxShield-Signature"],
secret="whsec_your_webhook_secret",
tolerance=300, # 5 minute tolerance (default)
)
# Signature valid — process the event
except WebhookVerificationError as e:
# Reject the request
print(f"Invalid webhook: {e}")
Rate Limiting
The SDK automatically retries on rate limit (429) responses. You can also inspect rate limit info:
client.products.list()
info = client.last_rate_limit
if info:
print(f"Remaining: {info['remaining']}/{info['limit']}")
Development
# Install dev dependencies
pip install -e "packages/python-sdk[dev]"
# Run tests
pytest
# Type checking
mypy fauxshield/
# Linting
ruff check fauxshield/
License
MIT
Metadata
Release files for fauxshield 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fauxshield-0.1.0.tar.gz | 17.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fauxshield-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.5 kB
Release files / fauxshield-0.1.0.tar.gz
| Download URL | fauxshield-0.1.0.tar.gz |
|---|---|
| Size | 17.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
52fe85044abfd31cd89f048b98bc148890566c341ab9f926a24922bb637377fe
|
|
BLAKE2b-256 checksum How to use checksums |
c132bca3660edfd078875be353bf264d9ea69e163ddd56e7fe174950cfa32071
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Release files / fauxshield-0.1.0-py3-none-any.whl
| Download URL | fauxshield-0.1.0-py3-none-any.whl |
|---|---|
| Size | 25.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cdeff40f6b081673bc21c6d6ad3dbeedc2bb854cc11685addcae9ca1b338af48
|
|
BLAKE2b-256 checksum How to use checksums |
58736c41a16b82bb6968d8ff230f99335950da5c4d4808f71668fa53d50ad92c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|