Skip to main content

Installation

pip install py-blink-client
Or from source:
git clone https://github.com/BlinkExchange/py-blink-client
cd py-blink-client
pip install -e .

Requirements

  • Python 3.10+
  • eth-account (EIP-712 signing)
  • requests (HTTP)
  • websockets (real-time data)

Connect and Authenticate

from py_blink_client import ClobClient

# Public data only (no auth needed)
client = ClobClient(host="https://api.blink15.com")

# Trading (requires wallet private key)
client = ClobClient(
    host="https://api.blink15.com",
    key="0xYOUR_PRIVATE_KEY",
)

# Create API credentials (one-time — cached on the client)
creds = client.create_or_derive_api_creds()
print(f"API Key: {creds.api_key}")
Your private key never leaves your machine. It’s only used locally to sign an EIP-712 message that proves wallet ownership.

How Auth Works

Blink uses two auth levels (same as Polymarket): Level 1 — EIP-712 (one-time setup) Your wallet signs a typed data message to create API credentials. This happens once when you call create_or_derive_api_creds(). Level 2 — HMAC-SHA256 (every request) All trading requests are signed with HMAC. The SDK handles this automatically after credentials are created.
# After create_or_derive_api_creds(), all calls use HMAC auth
orders = client.get_orders()              # authenticated
client.create_and_post_order(...)         # authenticated
client.cancel(...)                        # authenticated

Configuration

ParameterDefaultDescription
hosthttps://api.blink15.comAPI base URL
keyNoneWallet private key (hex string with 0x prefix)
chain_id84532Base Sepolia chain ID

Error Handling

The SDK raises BlinkApiError for HTTP errors and BlinkAuthError for authentication failures:
from py_blink_client import BlinkApiError, BlinkAuthError

try:
    order = client.create_and_post_order(args)
except BlinkAuthError as e:
    print(f"Auth failed: {e}")  # expired or invalid credentials
except BlinkApiError as e:
    print(f"API error {e.status_code}: {e.response_body}")
The SDK automatically retries on 5xx errors (3 attempts with exponential backoff).

Testnet Faucet

Get free USDC on Base Sepolia:
# Mint 100 USDC
result = client.claim_faucet("0xYourWalletAddress")
print(f"TX: {result['tx_hash']}")

# Gas-free USDC approval
client.relay_permit(owner, spender, value, deadline, v, r, s)

# Sponsor ETH for CTF token approval
client.prefund_ctf_approval("0xYourWalletAddress")

What’s Next

Trading

Place orders, batch operations, order types

WebSocket Streams

Real-time orderbook, fills, price ticks