Python REST
This example uses Python with Monaco’s REST API. Public market data does not require authentication; trading and account routes require a Monaco client ID plus a wallet-authorized ed25519 session key.Prerequisites
clientId.
Market Data
No authentication is required to read trading pairs.Authenticate
Monaco authenticates with a wallet-authorized ed25519 session key. Generate a keypair locally, have the wallet sign a challenge that commits to it, then sign every authenticated request with the session key. No tokens are issued.Sign Requests
This guide uses legacy signing, where every authenticated request carriesX-Monaco-PublicKey, X-Monaco-Timestamp, and X-Monaco-Signature, and the signature covers METHOD\npath?query\ntimestamp_ms\nSHA256_hex(body). Monaco also accepts RFC 9421 HTTP message signatures over the same session key; a Python client can implement either, but never both on one request. Serialize the body yourself so the bytes you hash are exactly the bytes you send:
Place and Cancel an Order
The API keepsidempotencyKey optional. Raw REST callers and generated Python bindings must supply their own keys for retry protection. Create and retain the key before serialization or signing. Persist the prepared payload and key before sending if recovery must survive a process restart.
order_request to signed_request again, which produces a fresh signature. Use a distinct key for every batch-create item, generated before signing the batch. Generated protobuf clients use the field name idempotency_key; populate it before SerializeToString() and retain the message for recovery. Protection lasts 24 hours after acceptance and retries do not extend it. Do not retry an unresolved submission after expiry. These examples do not retry automatically.
A GTC order rests on the book until filled or cancelled. See Order Management for other time-in-force options.
Generate gRPC Clients with BSR
Monaco publishes protobuf definitions to the Buf Schema Registry. Use BSR when you want generated gRPC clients in Go, Python, C++, Java, C#, Kotlin, Swift, Ruby, PHP, TypeScript, or another supported language.Install Buf
Create buf.gen.yaml
Use the Monaco BSR module as the input and select plugins for your target language.
Generate
out: directories you configured.

