Skip to main content

silhouette-python-sdk

Dependencies Status Code style: ruff Pre-commit Semantic Versions License

Python SDK for trading on Silhouette - the shielded exchange on Hyperliquid.

Overview

This package provides:

  • Drop-in replacement for the official Hyperliquid Python SDK with enhanced convenience methods
  • Silhouette API integration for trading on the shielded exchange
  • Type-safe interfaces with Pydantic models generated from OpenAPI specifications
  • Clean dict-based API for easy usage without model imports
  • Enhanced functionality including balance checking, deposit automation, and withdrawal polling

IMPORTANT: This package replaces hyperliquid-python-sdk. Do not install both packages together. The official Hyperliquid SDK is included as a dependency.

Installation

pip install silhouette-python-sdk

Quick start

Using the enhanced Hyperliquid SDK

# IMPORTANT: Always import silhouette FIRST
import silhouette

# Then use standard hyperliquid imports to get enhanced versions
from hyperliquid.info import Info
from hyperliquid.exchange import Exchange
from hyperliquid.utils.constants import TESTNET_API_URL

# Enhanced Info client with get_balance() and await_withdrawal_completion()
info = Info(base_url=TESTNET_API_URL, skip_ws=True)

# Check spot balances
spot_state = info.spot_user_state("0x1615330FAee0776a643CC0075AD2008418e067Db")
print(spot_state)

# Get specific token balance (convenience method)
usdc_balance = info.get_balance("0x1615330FAee0776a643CC0075AD2008418e067Db", "USDC")
print(f"USDC Balance: {usdc_balance}")

Using the Silhouette API

from silhouette import SilhouetteApiClient

# Initialize client with auto-authentication
client = SilhouetteApiClient(
    base_url="https://api.silhouette.exchange",
    private_key="your_private_key_here",
    auto_auth=True,
)

# Check balances (returns plain dict with camelCase keys)
balances_response = client.user.get_balances()
print(f"Balances: {balances_response['balances']}")

# Place an order (returns dict, no need to import models)
order = client.order.create_order(
    side="buy",
    order_type="limit",
    base_token="HYPE",
    quote_token="USDC",
    amount="1.0",
    price="0.001",
)
print(f"Order placed: {order['orderId']}")

# Initiate a withdrawal
withdrawal = client.user.initiate_withdrawal("USDC", "100.0")
print(f"Withdrawal initiated: {withdrawal['withdrawalId']}")

Enhanced features

Hyperliquid SDK enhancements

The enhanced Hyperliquid SDK includes these convenience methods:

Info class:

  • get_balance(wallet_address: str, token_symbol: str) -> float - Get user's balance for a specific token
  • await_withdrawal_completion(wallet_address: str, pre_withdrawal_balance: float, token_symbol: str, timeout: int) -> bool - Poll balance until withdrawal completes

Exchange class:

  • deposit_to_silhouette(silhouette_address: str, token_symbol: str, amount: str, converter: TokenConverter) -> dict - Deposit tokens from Hyperliquid to Silhouette contract

All other Hyperliquid SDK methods work exactly as documented in the official Hyperliquid SDK.

Silhouette API client

The SilhouetteApiClient provides access to the Silhouette shielded exchange:

  • Dict-based API: All methods return plain Python dicts with camelCase keys matching the API
  • No model imports needed: Pydantic models are used internally for validation, but you work with simple dicts
  • User operations: Balances, withdrawal initiation and status polling
  • Order management: Create, cancel, query orders
  • Delegated orders: List, get, and batch retrieve delegated orders
  • Market data: Query supported tokens and trading pairs
  • Referral management: Register new users, set referrers, query referral details
  • Automatic authentication: SIWE-based session management with automatic token refresh

Delegated orders

Delegated orders are orders placed on Hyperliquid by Silhouette on behalf of a trader. Query them using the delegated_order operations:

# List delegated orders with optional filters
orders = client.delegated_order.list_delegated_orders(
    status="open",
    limit=50,
)
print(f"Found {len(orders['orders'])} orders")

# Get a single order by ID
order = client.delegated_order.get_delegated_order("order-id-here")
print(f"Order status: {order['order']['status']}")

# Batch retrieve multiple orders
batch = client.delegated_order.batch_get_delegated_orders(
    ["order-1", "order-2", "order-3"]
)
print(f"Found: {len(batch['orders'])}, Not found: {batch['notFound']}")

Configuration

Create examples/config.json from the example template:

cp examples/config.json.example examples/config.json

Then configure:

  • account_address: Your wallet's public address
  • secret_key: Your wallet's private key (or use keystore_path for a keystore file)
  • use_testnet: Set to true for testnet, false for mainnet

[Optional] Using an API wallet

Generate and authorise a new API private key on https://app.hyperliquid.xyz/API, and set the API wallet's private key as the secret_key in examples/config.json. Note that you must still set the public key of the main wallet (not the API wallet) as the account_address.

Contributing

See CONTRIBUTING.md for development setup, testing, and project structure.

Licence

This project is licensed under the terms of the MIT licence. See LICENSE for more details.

@misc{silhouette-python-sdk,
  author = {Silhouette},
  title = {Python SDK for trading on Silhouette - the shielded exchange on Hyperliquid},
  year = {2025},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/silhouette-exchange/silhouette-python-sdk}}
}

Metadata

Release files for silhouette-python-sdk 0.3.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for silhouette-python-sdk 0.3.5
File Size Uploaded
silhouette_python_sdk-0.3.5.tar.gz 41.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for silhouette-python-sdk 0.3.5
File Interpreter ABI Platform
silhouette_python_sdk-0.3.5-py3-none-any.whl Python 3 none any Details

Total release size: 88.8 kB

Release files / silhouette_python_sdk-0.3.5.tar.gz

Download URL silhouette_python_sdk-0.3.5.tar.gz
Size 41.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4b1e5a8873c7de9b9943d13ef3277fce5c2138d1b7b99f94dadac42acdce2b6b
BLAKE2b-256 checksum
How to use checksums
bbff4ea867774bc7c67ad30ecd1c8058f6ac1f71669209c081844f241eb27b39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.13.3 Darwin/24.6.0

Release files / silhouette_python_sdk-0.3.5-py3-none-any.whl

Download URL silhouette_python_sdk-0.3.5-py3-none-any.whl
Size 47.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f3d09ed4dabe03471a443cdce052b2c6b88c74bd808fd6f6947940df06f2e350
BLAKE2b-256 checksum
How to use checksums
9462215d902ba59192acb1d5fce6f70efddcf65a33815288d9a73ed4d01d2e3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.13.3 Darwin/24.6.0

Release history Release notifications | RSS feed

This release

0.3.5 This release

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page