Python SDK
The official projectsilo package provides a typed client for the Project Silo REST API using httpx and Pydantic v2.
Install
shellbash
pip install projectsiloCreate a client
main.pypython
from projectsilo import ProjectSiloClient
client = ProjectSiloClient(
api_key="project_silo_live_...",
# base_url="https://api.projectsilo.app", # default
)
# Use as context manager
with ProjectSiloClient(api_key="...") as client:
...Deposit accounts
deposit_accounts.pypython
from projectsilo import CreateDepositAccountInput, Destination
# Create
account = client.create_deposit_account(CreateDepositAccountInput(
external_user_id="user_123",
destination=Destination(
chain_id=137,
address="0x1111...",
token_address="0x2791...",
),
))
print(account.deposit_addresses)
# List
accounts = client.list_deposit_accounts(limit=50)
# Get
acct = client.get_deposit_account("user_123")Fee preview
fees.pypython
from projectsilo import FeePreviewInput
quote = client.preview_fee(FeePreviewInput(
source_chain_id=8453,
source_asset="USDC",
amount="100.00",
destination_chain_id=137,
destination_asset="USDC.e",
))
print(quote.net_credit_usd, quote.effective_bps)Webhooks
webhooks.pypython
from projectsilo import verify_webhook_signature
# Verify incoming webhooks (HMAC-SHA256 over "{timestamp}.{raw_body}")
is_valid = verify_webhook_signature(
body=request.body, # bytes
signature=request.headers["x-project-silo-signature"],
timestamp=request.headers["x-project-silo-timestamp"],
secret=endpoint_secret,
# tolerance_seconds=300 — max clock skew before rejecting
)
# Create endpoint
endpoint, secret = client.create_webhook_endpoint(
CreateWebhookEndpointInput(
name="Production",
url="https://example.com/webhook",
event_types=["deposit.credited", "deposit.failed"],
),
)Error handling
errors.pypython
from projectsilo import ProjectSiloError
try:
client.get_deposit_account("nonexistent")
except ProjectSiloError as e:
print(f"API error {e.status}: {e.message} (code={e.code})")