Skip to content
SwapWalletDocs
فارسیGet an API key

Quickstart

Create an API key, check it, and read your SwapWallet balances in a few minutes, with samples in cURL, Node.js, Python, PHP and Go.

This page takes you from no key to a working request against your own account. You need a SwapWallet account and a terminal; every step has the same request in cURL, Node.js, Python, PHP and Go.

Four steps

  1. Create an API key

    In the SwapWallet app, open Profile › API key and choose Create new key. The key starts with apikey- and acts with your account’s full access, so keep it on your server and nowhere else.

    Terminal
    export SWAPWALLET_API_KEY="apikey-…"   # paste your key
  2. Check the key

    This request does nothing but confirm the key works. A 401 means the header is missing, mistyped, or the key was replaced.

    curl https://swapwallet.app/api/v1/utils/authentication/check \
      -H "Authorization: Bearer $SWAPWALLET_API_KEY"
    JSON
    { "status": "OK" }
  3. Read your balances

    Your first real data: what you hold, per token. Amounts are decimal strings, so parse them with a decimal type rather than a float.

    curl https://swapwallet.app/api/v2/user/balance \
      -H "Authorization: Bearer $SWAPWALLET_API_KEY"
    JSON
    {
      "status": "OK",
      "result": [
        { "token": "ETH",  "amount": { "number": "0",        "unit": "ETH" } },
        { "token": "BNB",  "amount": { "number": "0",        "unit": "BNB" } },
        { "token": "TON",  "amount": { "number": "106.677",  "unit": "TON" } },
        { "token": "TRX",  "amount": { "number": "340",      "unit": "TRX" } },
        { "token": "BTC",  "amount": { "number": "0.00215",  "unit": "BTC" } },
        { "token": "USDT", "amount": { "number": "1149.5",   "unit": "USDT" } },
        { "token": "IRT",  "amount": { "number": "48250000", "unit": "IRT" } }
      ]
    }
  4. Pick what to build