API Documentation

NinjaSwap API Documentation

Welcome to the NinjaSwap API documentation. Our API allows you to integrate cryptocurrency exchange functionality into your applications, with support for 70+ cryptocurrencies and competitive rates.

Base URL

/api

Authentication

All API requests require authentication using an API key included in the request headers.

Rate Types

Choose between float rates (market price) or fixed rates (guaranteed price) for your exchanges.

Fast Processing

Our API is optimized for speed with most requests processed in under 200ms.

1. Get Available Currencies

This endpoint returns a list of all available cryptocurrencies for exchange including their capabilities (send/receive) and metadata.

Endpoint

POST/api/available-currencies

Request

This endpoint does not require any parameters.

curl -X POST "/api/available-currencies"
-H "Content-Type: application/json"
-H "X-API-Key: 616f7f9c75c0a13d89f9882a1836d83bc2fcfacff0baec5c0d58be441cd3b43b"

Response

{
  "code": 0,
  "data": [
    {
      "code": "BTC",
      "name": "Bitcoin",
      "logo": "/assets/images/coins/btc.svg",
      "network": "Bitcoin",
      "canSend": true,
      "canReceive": true
    },
    {
      "code": "ETH",
      "name": "Ethereum",
      "logo": "/assets/images/coins/eth.svg",
      "network": "Ethereum",
      "canSend": true,
      "canReceive": true
    },
    /* More currencies... */
  ]
}

2. Get Exchange Rate

This endpoint returns the current exchange rate between two cryptocurrencies.

Endpoint

POST/api/exchange-rate

Request Parameters

ParameterTypeRequiredDescription
fromCurrencyStringYesThe currency code to exchange from (e.g., "BTC")
toCurrencyStringYesThe currency code to exchange to (e.g., "ETH")
amountNumberYesThe amount to exchange
directionStringNo"from" or "to" (default: "from")
typeStringNo"float" or "fixed" (default: "float")

Request Example

curl -X POST "/api/exchange-rate"
-H "Content-Type: application/json"
-H "X-API-Key: 616f7f9c75c0a13d89f9882a1836d83bc2fcfacff0baec5c0d58be441cd3b43b"
-d { "fromCurrency": "BTC", "toCurrency": "ETH", "amount": 0.01, "direction": "from", "type": "float" }

Response

{
  "code": 0,
  "data": {
    "errors": [],
    "from": {
      "amount": 0.01,
      "code": "BTC",
      "coin": "BTC",
      "network": "",
      "precision": 8,
      "rate": 52.340873224619,
      "min": 0.00010781,
      "max": 0.76990932,
      "btc": 0.01,
      "usd": 965.4067100000001
    },
    "to": {
      "amount": 0.52340873224619,
      "code": "ETH",
      "coin": "ETH",
      "network": "",
      "precision": 8,
      "rate": 0.01910937659053312,
      "min": 0.005648045673452619,
      "max": 40.32257775783138,
      "usd": 960.3211628330495
    }
  },
  "msg": "OK (XML)"
}

3. Create Exchange Order

This endpoint creates a new cryptocurrency exchange order.

Endpoint

POST/api/create-order

Request Parameters

ParameterTypeRequiredDescription
fromCcyStringYesThe currency code to exchange from (e.g., "BTC")
toCcyStringYesThe currency code to exchange to (e.g., "ETH")
amountNumberYesThe amount to exchange in fromCcy
typeStringNoThe rate type: "float" (default) or "fixed"
directionStringYesDirection of exchange, use "from" to specify amount in fromCcy
toAddressStringYesThe wallet address to receive the exchanged currency
refundAddressStringYesRefund address in case the exchange can't be completed

Request Example

curl -X POST "/api/create-order"
-H "Content-Type: application/json"
-H "X-API-Key: 616f7f9c75c0a13d89f9882a1836d83bc2fcfacff0baec5c0d58be441cd3b43b"
-d { "fromCcy": "BTC", "toCcy": "ETH", "amount": 0.1, "type": "float", "direction": "from", "toAddress": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e", "refundAddress": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e" }

Response

{
  "code": 0,
  "data": {
    "id": "NS1234567890",
    "token": "abcdef1234567890",
    "from": {
      "currency": "BTC",
      "amount": 0.1,
      "address": "3FZbgi29cpjq2GjdwV8eyHuJJnkLtktZc5",
      "tag": null
    },
    "to": {
      "currency": "ETH",
      "amount": 1.45,
      "address": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
      "tag": null
    },
    "type": "fixed",
    "status": "waiting",
    "created_at": 1681234567,
    "expires_at": 1681238167
  }
}

4. Get Order Status

This endpoint returns the current status of an existing order.

Endpoint

POST/api/order-details

Request Parameters

ParameterTypeRequiredDescription
idStringYesThe order ID returned from create-order
tokenStringYesThe token returned from create-order

Request Example

curl -X POST "https://api.ninjaswap.fi/api/order-details"
-H "Content-Type: application/json"
-H "X-API-Key: 616f7f9c75c0a13d89f9882a1836d83bc2fcfacff0baec5c0d58be441cd3b43b"
-d { "id": "NS1234567890", "token": "abcdef1234567890" }

Response

{
  "code": 0,
  "data": {
    "id": "NS1234567890",
    "from": {
      "currency": "BTC",
      "amount": 0.1,
      "address": "3FZbgi29cpjq2GjdwV8eyHuJJnkLtktZc5",
      "tag": null,
      "txid": "7e46e13e4a3a59ff8a23990a37a3c6a57eb0e52bc7ccbe3e95b2b7e12d7b5e54"
    },
    "to": {
      "currency": "ETH",
      "amount": 1.45,
      "address": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
      "tag": null,
      "txid": null
    },
    "type": "fixed",
    "status": "confirming",
    "confirmations": 2,
    "required_confirmations": 3,
    "created_at": 1681234567,
    "expires_at": 1681238167
  }
}

5. Generate QR Codes

This endpoint generates QR codes for an order's payment addresses.

Endpoint

POST/api/qr-codes

Request Parameters

ParameterTypeRequiredDescription
idStringYesThe order ID returned from create-order
tokenStringYesThe token returned from create-order
typeStringNoQR code type: "address" (default) or "uri"

Request Example

curl -X POST "https://api.ninjaswap.fi/api/qr-codes"
-H "Content-Type: application/json"
-H "X-API-Key: 616f7f9c75c0a13d89f9882a1836d83bc2fcfacff0baec5c0d58be441cd3b43b"
-d { "id": "NS1234567890", "token": "abcdef1234567890", "type": "address" }

Response

The response includes a base64-encoded QR code image.

{
  "code": 0,
  "data": {
    "checked": true,
    "src": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwA..."
  }
}