API Documentation

Integrate 0xSwap cryptocurrency exchange into your platform using our REST API.

Authentication

All API requests require authentication using API Key and HMAC-SHA256 signature.

Headers:

X-API-KEY: your_api_key
X-API-SIGN: hmac_sha256(request_body, api_secret)
Content-Type: application/json; charset=UTF-8

Contact [email protected] to request API access.

Base URL

https://0xswap.exchange/api/v1/

Endpoints

POST /api/v1/ccies

Get list of available currencies

Request:

{}

Response:

{
  "code": 0,
  "msg": "",
  "data": [
    {
      "code": "BTC",
      "coin": "BTC",
      "network": "BTC",
      "name": "Bitcoin",
      "recv": true,
      "send": true,
      "enabled": true
    }
  ]
}

POST /api/v1/price

Get exchange rate and mode (auto/manual)

Request:

{
  "fromCcy": "BTC",
  "toCcy": "ETH",
  "direction": "from",
  "amount": 1.0
}

Response:

{
  "code": 0,
  "msg": "",
  "data": {
    "from": { ... },
    "to": { ... },
    "mode": "auto"  // or "manual"
  }
}

POST /api/v1/create

Create new exchange order

Request:

{
  "fromCcy": "BTC",
  "toCcy": "ETH",
  "direction": "from",
  "amount": 1.0,
  "toAddress": "0x...",
  "email": "[email protected]"
}

Response:

{
  "code": 0,
  "msg": "",
  "data": {
    "id": "0A1B2C",
    "token": "...",
    "from": { "address": "...", ... },
    "to": { "address": "...", ... }
  }
}

POST /api/v1/order

Get order status

Request:

{
  "id": "0A1B2C",
  "token": "your_order_token"
}

Code Examples

Node.js / JavaScript

const crypto = require('crypto');

const API_KEY = 'your_api_key';
const API_SECRET = 'your_api_secret';
const BASE_URL = 'https://0xswap.exchange';

async function makeRequest(endpoint, body) {
  const bodyString = JSON.stringify(body);
  const signature = crypto
    .createHmac('sha256', API_SECRET)
    .update(bodyString)
    .digest('hex');

  const response = await fetch(`${BASE_URL}${endpoint}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-API-KEY': API_KEY,
      'X-API-SIGN': signature,
    },
    body: bodyString,
  });

  return response.json();
}

// Get currencies
const currencies = await makeRequest('/api/v1/ccies', {});