Skip to main content

Recipes

Ready-to-use, single-file clients you can drop into your project. Each recipe wraps every endpoint of one API surface (Spot, Futures, or HFT) as a method on a single class — signing, headers, idempotency keys, and the epoch parameter are handled for you.

These are the fastest way to start trading. Skip the per-endpoint reference until you need a specific field.

Available recipes

  • Spot Client — INR + USDT spot trading on coinswitchx, c2c1, c2c2.
  • Futures Client — USDT-margined perpetual futures with up to 100× leverage.
  • HFT Client — low-latency futures and options endpoints with the {retCode, retMsg, result} envelope.

Each recipe ships in Python, Java, Go, and Node.js — pick the file for your language, copy it into your project, set your API key + secret, and start calling methods.

How to use a recipe

# Python — drop coinswitch_spot.py into your project, then:
from coinswitch_spot import SpotClient

cs = SpotClient(
api_key="<your hex api key>",
secret_key="<your hex secret key>",
)

print(cs.server_time())
print(cs.portfolio())

cs.create_order(
side="buy", symbol="BTC/USDT",
type="limit", price=60000, quantity=0.001,
exchange="c2c1",
)
// Node — drop coinswitch_spot.js into your project, then:
const { SpotClient } = require('./coinswitch_spot');

const cs = new SpotClient({
apiKey: '<your hex api key>',
secretKey: '<your hex secret key>',
});

console.log(await cs.serverTime());
console.log(await cs.portfolio());

await cs.createOrder({
side: 'buy', symbol: 'BTC/USDT',
type: 'limit', price: 60000, quantity: 0.001,
exchange: 'c2c1',
});

What's inside each client

  • All authenticated REST endpoints for that surface.
  • Built-in Ed25519 signing with X-AUTH-EPOCH always sent.
  • Auto-minted client_order_id / orderLinkId / client_txn_id on writes — your idempotency key for safe retries.
  • A single _request / send / Request method you can extend if a new endpoint ships before the recipe is updated.

What's not inside

  • WebSocket / NATS subscriptions — those need different libraries per language. See the per-page guides under Spot › WebSockets, Futures › WebSockets, and HFT › Sockets.
  • Strategy logic — the recipes are plumbing, not strategy.
  • Persistence / order books / state management — bring your own.

Conventions

  • Files are named coinswitch_<surface>.{py,go,js} and Coinswitch<Surface>.java.
  • Class name is <Surface>Client (Python / Node) or Coinswitch<Surface> (Java) or Client in coinswitch<surface> package (Go).
  • Method names match the endpoint name in the per-endpoint reference, lowercased and snake_case (Python) or camelCase (Java / Node) or PascalCase (Go).