Quickstart
A 60-second hello world: fetch server time, validate your keys, and list your open Spot orders.
1. Install dependencies
- Python
- Java
- Go
- Node.js
Python 3.9 or later. Install:
pip install cryptography requests
The Reference Client also uses python-socketio and websocket-client for WebSocket flows — install them when you get to that section.
Java 11 or later. Add to your build.gradle:
dependencies {
implementation 'org.bouncycastle:bcprov-jdk18on:1.78'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.0'
}
BouncyCastle provides Ed25519 signing; Jackson provides JSON serialization.
Go 1.21 or later. The signing helper uses only the standard library (crypto/ed25519, net/url, encoding/hex) — no extra modules to install.
go mod init my-trading-bot
For the WebSocket flows you'll need nats.go (HFT) or a Socket.IO client (Spot/Futures) — install those when you reach the relevant section.
Node.js 18 or later (uses native fetch and crypto.sign with Ed25519). For the REST flows there are no dependencies to install.
npm init -y
For WebSocket flows you'll need socket.io-client (Spot/Futures) or nats (HFT) — install those when you reach the relevant section.
2. Drop in the Reference Client
Copy the helper from Reference Client into your project and set your API_KEY and SECRET_KEY constants.
3. Run three calls
- Python
- Java
- Go
- Node.js
import requests
# sign_request, BASE_URL, etc. come from the Reference Client
# 1. Server time (unauthenticated)
print(requests.get(BASE_URL + "/trade/api/v2/time").json())
# 2. Validate your API key + signature
headers, path = sign_request("GET", "/trade/api/v2/validate/keys")
print(requests.get(BASE_URL + path, headers=headers).json())
# 3. List your open Spot orders on coinswitchx
headers, path = sign_request("GET", "/trade/api/v2/orders",
params={"open": "true", "exchanges": "coinswitchx"})
print(requests.get(BASE_URL + path, headers=headers).json())
// CoinswitchClient is the Reference Client class
import java.net.URI;
import java.net.http.*;
import java.util.Map;
CoinswitchClient client = new CoinswitchClient();
// 1. Server time (unauthenticated)
HttpResponse<String> t = HttpClient.newHttpClient().send(
HttpRequest.newBuilder()
.uri(new URI("https://coinswitch.co/trade/api/v2/time"))
.GET().build(),
HttpResponse.BodyHandlers.ofString());
System.out.println(t.body());
// 2. Validate your API key + signature
System.out.println(
client.send("GET", "/trade/api/v2/validate/keys", null, null).body());
// 3. List your open Spot orders on coinswitchx
System.out.println(
client.send("GET", "/trade/api/v2/orders",
Map.of("open", "true", "exchanges", "coinswitchx"), null).body());
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
// 1. Server time (unauthenticated)
resp, _ := http.Get(BaseURL + "/trade/api/v2/time")
body, _ := io.ReadAll(resp.Body)
resp.Body.Close()
fmt.Println(string(body))
// 2. Validate your API key + signature
do("GET", "/trade/api/v2/validate/keys", nil)
// 3. List your open Spot orders on coinswitchx
do("GET", "/trade/api/v2/orders", map[string]string{
"open": "true",
"exchanges": "coinswitchx",
})
}
func do(method, path string, params map[string]string) {
headers, p, err := SignRequest(method, path, params)
if err != nil { panic(err) }
req, _ := http.NewRequest(method, BaseURL+p, nil)
for k, v := range headers {
req.Header.Set(k, v)
}
resp, err := http.DefaultClient.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
const {signRequest, BASE_URL} = require('./reference-client');
async function main() {
// 1. Server time (unauthenticated)
const t = await fetch(BASE_URL + '/trade/api/v2/time');
console.log(await t.json());
// 2. Validate your API key + signature
const v = signRequest('GET', '/trade/api/v2/validate/keys');
const r2 = await fetch(BASE_URL + v.path, {headers: v.headers});
console.log(await r2.json());
// 3. List your open Spot orders on coinswitchx
const o = signRequest('GET', '/trade/api/v2/orders',
{open: 'true', exchanges: 'coinswitchx'});
const r3 = await fetch(BASE_URL + o.path, {headers: o.headers});
console.log(await r3.json());
}
main();
What you should see
If all three calls return 200s, you're integrated:
{ "serverTime": 1719905777483 }
{ "message": "Valid Access" }
{ "data": { "orders": [ ... ] } }
The third call returns an empty orders array if you have no open orders, which is fine.
Troubleshooting
401 Invalid Accesson call 2 — your API key, secret, or signature is wrong. Double-check that the key inX-AUTH-APIKEYmatches the one paired with the secret you're signing with. See Authentication.- Connection / TLS errors — verify your firewall allows outbound HTTPS to
coinswitch.co. 429— rate limit exceeded. The Quickstart calls won't trigger this on a fresh key; if it happens, wait 10 seconds and retry.
Next steps
- Recipes — the fastest path forward. Single-file clients for Spot / Futures / HFT with every endpoint pre-wrapped as a method.
- Spot Reference — every spot endpoint, with request/response shapes and examples.
- Futures Reference — perpetual futures.
- Reference Client — the smaller, signing-only helper if you want to wrap endpoints yourself.