Swypt Logo
Swypt Logo
/API Docs

Swypt API Documentation

Integrate fiat ↔ crypto conversions into your product using Swypt's on-ramp and off-ramp APIs. Convert KES via M-Pesa to tokens on-chain, or send crypto to receive KES directly — across six blockchain networks.

On-Ramp

KES → crypto via M-Pesa STK Push, then receive tokens on-chain.

Off-Ramp

Send crypto to Swypt escrow, receive KES via M-Pesa.

Multi-Chain

Polygon, Lisk, Celo, Base, Scroll, and Algorand supported.

Authentication

Every API request requires two custom headers. Obtain your API key and secret from your Swypt dashboard.

x-api-key— Your API key
x-api-secret— Your API secret
Warning: Never expose your API key or secret in client-side code. Use environment variables and route requests through your backend.
js
400 font-semibold">const 300">headers = {
  400 font-semibold">class="text-emerald-300">'x-api-key': 400 font-semibold">class="text-emerald-300">'YOUR_API_KEY',
  400 font-semibold">class="text-emerald-300">'x-api-secret': 400 font-semibold">class="text-emerald-300">'YOUR_API_SECRET'
};

400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">// Include 300">headers in every Axios request
400 font-semibold">const 300">response = 400 font-semibold">await 300">axios.get(300">url, { 300">headers });

Quick Start

Get integrated in 5 steps. Follow this flow for a complete on-ramp or off-ramp integration.

1

API Credentials

Obtain your x-api-key and x-api-secret from the Swypt dashboard and store them securely.

2

Fetch Quote

Call POST /api/fx-quotes with your desired currency pair and network to get live rate/fees.

3

Contract Escrow

For off-ramps: Approve and call withdrawToEscrow (EVM) or send USDC (Algorand).

4

Order Request

Call POST /api/offramp-orders or initiate an STK Push via POST /api/onramp-orders.

5

Finalize Crypto

On payment SUCCESS, trigger POST /api/deposit to release crypto (on-ramp only).

Deployed Contracts

EVM Chains

Swypt escrows are deployed across multiple EVM chains. Click on an address to view the smart contract code on the explorer, or copy the address directly.

Algorand

SUPPORTED ASSET

USDC — Asset ID: 31566704

Must be utilized for Algorand off-ramp deposits and transfers.

Smart Contract ABI

Required to interact with Swypt contracts on EVM chains. Key functions:

Algorand uses native blockchain transactions and does not require an ABI. See the Algorand-specific sections below for integration details.
Contract Interface methods

Method Description

Standard withdrawal (requires prior token approval). Returns a nonce.

Inputs & Parameters

_tokenAddressaddress
Contract address of the token being deposited
_amountuint256
Total token amount inclusive of exchange fees (base units)
_feeAmountuint256
Escrow/conversion fee amount in base units
JS EXAMPLES
javascript
400 font-semibold">import { ethers } 400 font-semibold">from 400 font-semibold">class="text-emerald-300">"ethers";

400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">// 1. Initialize web3 browser provider and signer
400 font-semibold">const provider = new ethers.BrowserProvider(window.ethereum);
400 font-semibold">const signer = 400 font-semibold">await provider.getSigner();

400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">// 2. Instantiate ERC20 and approve Swypt contract
400 font-semibold">const token = new ethers.Contract(TOKEN_ADDRESS, ERC20_ABI, signer);
400 font-semibold">const approveTx = 400 font-semibold">await token.approve(SWYPT_CONTRACT_ADDRESS, amount);
400 font-semibold">await approveTx.wait();

400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">// 3. Call Swypt escrow contract
400 font-semibold">const escrow = new ethers.Contract(SWYPT_CONTRACT_ADDRESS, SWYPT_ABI, signer);
400 font-semibold">const tx = 400 font-semibold">await escrow.withdrawToEscrow(
  TOKEN_ADDRESS,
  amount,
  feeAmount
);
400 font-semibold">const receipt = 400 font-semibold">await tx.wait();

300">console.300">log(400 font-semibold">class="text-emerald-300">"Deposit complete! Nonce details inside events. Tx Hash:", receipt.hash);
Function Signature ABIJSON
json
{
  "inputs": [
    { "internalType": "address", "name": "_tokenAddress", "type": "address" },
    { "internalType": "uint256", "name": "_amount", "type": "uint256" },
    { "internalType": "uint256", "name": "_feeAmount", "type": "uint256" }
  ],
  "name": "withdrawToEscrow",
  "outputs": [
    { "internalType": "uint256", "name": "nonce", "type": "uint256" }
  ],
  "stateMutability": "payable",
  "type": "function"
}

Complete Swypt Contract ABI

javascript
400 font-semibold">export 400 font-semibold">const SWYPT_CONTRACT_ABI = [
  { inputs: [], stateMutability: 400 font-semibold">class="text-emerald-300">'nonpayable', 400 font-semibold">type: 400 font-semibold">class="text-emerald-300">'constructor' },
  { inputs: [], name: 400 font-semibold">class="text-emerald-300">'AccessControlBadConfirmation', 400 font-semibold">type: 400 font-semibold">class="text-emerald-300">'error' },
  {
    inputs: [
      { internalType: 400 font-semibold">class="text-emerald-300">'address', name: 400 font-semibold">class="text-emerald-300">'account', 400 font-semibold">type: 400 font-semibold">class="text-emerald-300">'address' },
      { internalType: 400 font-semibold">class="text-emerald-300">'bytes32', name: 400 font-semibold">class="text-emerald-300">'neededRole', 400 font-semibold">type: 400 font-semibold">class="text-emerald-300">'bytes32' },
    ],
    name: 400 font-semibold">class="text-emerald-300">'AccessControlUnauthorizedAccount',
    400 font-semibold">type: 400 font-semibold">class="text-emerald-300">'error',
  },
  {
    inputs: [
      { internalType: 400 font-semibold">class="text-emerald-300">'address', name: 400 font-semibold">class="text-emerald-300">'_tokenAddress', 400 font-semibold">type: 400 font-semibold">class="text-emerald-300">'address' },
      { internalType: 400 font-semibold">class="text-emerald-300">'uint256', name: 400 font-semibold">class="text-emerald-300">'_amount', 400 font-semibold">type: 400 font-semibold">class="text-emerald-300">'uint256' },
      { internalType: 400 font-semibold">class="text-emerald-300">'uint256', name: 400 font-semibold">class="text-emerald-300">'_feeAmount', 400 font-semibold">type: 400 font-semibold">class="text-emerald-300">'uint256' },
    ],
    name: 400 font-semibold">class="text-emerald-300">'withdrawToEscrow',
    outputs: [{ internalType: 400 font-semibold">class="text-emerald-300">'uint256', name: 400 font-semibold">class="text-emerald-300">'nonce', 400 font-semibold">type: 400 font-semibold">class="text-emerald-300">'uint256' }],
    stateMutability: 400 font-semibold">class="text-emerald-300">'payable', 400 font-semibold">type: 400 font-semibold">class="text-emerald-300">'400 font-semibold">function',
  },
  {
    inputs: [{ internalType: 400 font-semibold">class="text-emerald-300">'uint256', name: 400 font-semibold">class="text-emerald-300">'_nonce', 400 font-semibold">type: 400 font-semibold">class="text-emerald-300">'uint256' }],
    name: 400 font-semibold">class="text-emerald-300">'viewDepositWithNonce',
    outputs: [
      { internalType: 400 font-semibold">class="text-emerald-300">'address', name: 400 font-semibold">class="text-emerald-300">'token', 400 font-semibold">type: 400 font-semibold">class="text-emerald-300">'address' },
      { internalType: 400 font-semibold">class="text-emerald-300">'address', name: 400 font-semibold">class="text-emerald-300">'user', 400 font-semibold">type: 400 font-semibold">class="text-emerald-300">'address' },
      { internalType: 400 font-semibold">class="text-emerald-300">'uint256', name: 400 font-semibold">class="text-emerald-300">'amount', 400 font-semibold">type: 400 font-semibold">class="text-emerald-300">'uint256' },
      { internalType: 400 font-semibold">class="text-emerald-300">'uint256', name: 400 font-semibold">class="text-emerald-300">'exchangeRate', 400 font-semibold">type: 400 font-semibold">class="text-emerald-300">'uint256' },
      { internalType: 400 font-semibold">class="text-emerald-300">'uint256', name: 400 font-semibold">class="text-emerald-300">'feeAmount', 400 font-semibold">type: 400 font-semibold">class="text-emerald-300">'uint256' },
    ],
    stateMutability: 400 font-semibold">class="text-emerald-300">'view', 400 font-semibold">type: 400 font-semibold">class="text-emerald-300">'400 font-semibold">function',
  },
];

Getting Quotes

Always fetch a quote before initiating any transaction. Quotes give you the live exchange rate, fee breakdown, and amount limits for the chosen currency pair and network.

Get Quote

POSThttps://pool.swypt.io/api/fx-quotes

Interactive Playground

ParameterTypeRequiredDescription
typestringYes
Operation type
Example:"onramp" | "offramp"
amountstringonramp
Fiat amount to convert (onramp)
Example:"10"
fiatAmountstringofframp
Fiat output amount (offramp)
Example:"1000"
fiatCurrencystringYes
Fiat currency code
Example:"KES"
cryptoCurrencystringYes
Cryptocurrency symbol
Example:"USDT"
networkstringYes
Blockchain network
Example:"celo"
categorystringNo
Transaction category (offramp only)
Example:"B2C"
Quote Tip: The fee.amount from the offramp quote is what you pass as _feeAmount to the smart contract's withdrawToEscrow call.
js
400 font-semibold">const 300">axios = 300">require(400 font-semibold">class="text-emerald-300">'300">axios');

400 font-semibold">const 300">response = 400 font-semibold">await 300">axios.post(400 font-semibold">class="text-emerald-300">'https:400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">//pool.swypt.io/api/fx-quotes', {
  400 font-semibold">class="text-emerald-300">"400 font-semibold">type": 400 font-semibold">class="text-emerald-300">"onramp",
  400 font-semibold">class="text-emerald-300">"fiatCurrency": 400 font-semibold">class="text-emerald-300">"KES",
  400 font-semibold">class="text-emerald-300">"cryptoCurrency": 400 font-semibold">class="text-emerald-300">"USDT",
  400 font-semibold">class="text-emerald-300">"network": 400 font-semibold">class="text-emerald-300">"celo",
  400 font-semibold">class="text-emerald-300">"amount": 400 font-semibold">class="text-emerald-300">"10"
}, {
  300">headers: {
    400 font-semibold">class="text-emerald-300">'x-api-key': 400 font-semibold">class="text-emerald-300">'YOUR_API_KEY',
    400 font-semibold">class="text-emerald-300">'x-api-secret': 400 font-semibold">class="text-emerald-300">'YOUR_API_SECRET'
  }
});

Supported Assets

GEThttps://pool.swypt.io/api/listed-assets

Fetches the list of all supported fiat currencies, target assets and blockchain configurations.

js
400 font-semibold">const 300">axios = 300">require(400 font-semibold">class="text-emerald-300">'300">axios');

400 font-semibold">const 300">response = 400 font-semibold">await 300">axios.get(400 font-semibold">class="text-emerald-300">'https:400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">//pool.swypt.io/api/listed-assets', {
  300">headers: {
    400 font-semibold">class="text-emerald-300">'x-api-key': 400 font-semibold">class="text-emerald-300">'YOUR_API_KEY',
    400 font-semibold">class="text-emerald-300">'x-api-secret': 400 font-semibold">class="text-emerald-300">'YOUR_API_SECRET'
  }
});

Off-Ramp Flow

Convert crypto to KES (M-Pesa). Two steps: execute a blockchain transaction, then notify Swypt via API.

1

Execute blockchain transaction

Call withdrawToEscrow (EVM) or send USDC to Swypt wallet (Algorand).

2

Initiate the offramp order

POST the transaction hash and recipient phone number to /api/offramp-orders.

EVM — withdrawToEscrow

Approve the token spend, then call the contract. The fee amount comes from your quote response.

javascript
400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">// 1. Approve the contract to spend your tokens
400 font-semibold">const contractAddress = 400 font-semibold">class="text-emerald-300">"0x2816a02000B9845C464796b8c36B2D5D199525d5"; 400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">// Lisk
400 font-semibold">const amount = parseUnits(amountPlusFee.toString(), tokenDecimals);
400 font-semibold">const feeAmount = parseUnits(fee.toString(), tokenDecimals);

400 font-semibold">await token.approve(contractAddress, amount);

400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">// 2. Call withdrawToEscrow — returns a nonce
400 font-semibold">const tx = 400 font-semibold">await contract.withdrawToEscrow(tokenAddress, amount, feeAmount);
400 font-semibold">await tx.wait(); 400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">// Wait for on-chain confirmation

Algorand — Native USDC Transfer

Prerequisites: user must be opted into USDC (Asset ID: 31566704) and have ~0.001 ALGO for transaction fees.
javascript
400 font-semibold">import algosdk 400 font-semibold">from 400 font-semibold">class="text-emerald-300">'algosdk';

400 font-semibold">const SWYPT_WALLET = 400 font-semibold">class="text-emerald-300">'XEI2YQ47YAEDJEOYE3KQTYJNRCA2G2TO7U4STRYMOOXAZMIHRQ7HEEPGOE';
400 font-semibold">const USDC_ASSET_ID = 31566704;

400 font-semibold">const algodClient = new algosdk.Algodv2(400 font-semibold">class="text-emerald-300">'', 400 font-semibold">class="text-emerald-300">'https:400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">//mainnet-api.algonode.cloud', 443);
400 font-semibold">const suggestedParams = 400 font-semibold">await algodClient.getTransactionParams().do();

400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">// USDC has 6 decimals: 1 USDC = 1,000,000 base units
400 font-semibold">const amountInBaseUnits = Math.floor(totalUSDC * 1_000_000);

400 font-semibold">const txn = algosdk.makeAssetTransferTxnWithSuggestedParamsFromObject({
  sender: userAddress,
  receiver: SWYPT_WALLET,
  amount: amountInBaseUnits,
  assetIndex: USDC_ASSET_ID,
  suggestedParams,
  note: new Uint8Array(Buffer.400 font-semibold">from(400 font-semibold">class="text-emerald-300">'Swypt Offramp'))
});

400 font-semibold">const signedTxn = 400 font-semibold">await wallet.signTransaction(txn);
400 font-semibold">const { txId } = 400 font-semibold">await algodClient.sendRawTransaction(signedTxn).do();
400 font-semibold">await algosdk.waitForConfirmation(algodClient, txId, 4); 400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">// ~10 seconds

Initiate Offramp Order

POSThttps://pool.swypt.io/api/offramp-orders

Interactive Playground

ParameterTypeRequiredDescription
chainstringYes
Blockchain network
Example:"celo"
hashstringYes
Transaction hash (66 chars EVM / 52 chars Algorand)
Example:"0x80856f..."
partyBstringYes
Recipient M-Pesa phone number
Example:"254703710518"
tokenAddressstringYes
Token contract address or Algorand asset ID
Example:"0x48065fbBE..."
projectstringYes
Your project identifier (used for support resolution)
Example:"my-project"
userAddressstringYes
User's wallet address
Example:"0x98e358..."
js
400 font-semibold">const 300">axios = 300">require(400 font-semibold">class="text-emerald-300">'300">axios');

400 font-semibold">const 300">response = 400 font-semibold">await 300">axios.post(400 font-semibold">class="text-emerald-300">'https:400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">//pool.swypt.io/api/offramp-orders', {
  400 font-semibold">class="text-emerald-300">"chain": 400 font-semibold">class="text-emerald-300">"celo",
  400 font-semibold">class="text-emerald-300">"hash": 400 font-semibold">class="text-emerald-300">"0x80856f025035da9387873410155c4868c1825101e2c06d580aea48e8179b5e0b",
  400 font-semibold">class="text-emerald-300">"partyB": 400 font-semibold">class="text-emerald-300">"254703710518",
  400 font-semibold">class="text-emerald-300">"tokenAddress": 400 font-semibold">class="text-emerald-300">"0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e",
  400 font-semibold">class="text-emerald-300">"project": 400 font-semibold">class="text-emerald-300">"my-project",
  400 font-semibold">class="text-emerald-300">"userAddress": 400 font-semibold">class="text-emerald-300">"0x98e35888468c07320e1061eB8F5D6Bb7dc491b7c"
}, {
  300">headers: {
    400 font-semibold">class="text-emerald-300">'x-api-key': 400 font-semibold">class="text-emerald-300">'YOUR_API_KEY',
    400 font-semibold">class="text-emerald-300">'x-api-secret': 400 font-semibold">class="text-emerald-300">'YOUR_API_SECRET'
  }
});

Check Status

GEThttps://pool.swypt.io/api/offramp-order-status/:orderID

Fetch current offramp processing progress. Status responses: PENDING, SUCCESS, FAILED.

js
400 font-semibold">const 300">axios = 300">require(400 font-semibold">class="text-emerald-300">'300">axios');

400 font-semibold">const 300">response = 400 font-semibold">await 300">axios.get(400 font-semibold">class="text-emerald-300">'https:400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">//pool.swypt.io/api/offramp-order-status/WD-xsy6e-HO', {
  300">headers: {
    400 font-semibold">class="text-emerald-300">'x-api-key': 400 font-semibold">class="text-emerald-300">'YOUR_API_KEY',
    400 font-semibold">class="text-emerald-300">'x-api-secret': 400 font-semibold">class="text-emerald-300">'YOUR_API_SECRET'
  }
});

Create Ticket

POSThttps://pool.swypt.io/api/offramp-ticket

For failed or pending offramp transactions. Pass orderID alone, or all fields manually.

Tip: Either provide orderID (data is auto-populated from the failed tx) or all the manual fields.
js
400 font-semibold">const 300">axios = 300">require(400 font-semibold">class="text-emerald-300">'300">axios');

400 font-semibold">const 300">response = 400 font-semibold">await 300">axios.post(400 font-semibold">class="text-emerald-300">'https:400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">//pool.swypt.io/api/offramp-ticket', {
  400 font-semibold">class="text-emerald-300">"orderID": 400 font-semibold">class="text-emerald-300">"WD-xsy6e-HO",
  400 font-semibold">class="text-emerald-300">"description": 400 font-semibold">class="text-emerald-300">"Refund for failed withdrawal"
}, {
  300">headers: {
    400 font-semibold">class="text-emerald-300">'x-api-key': 400 font-semibold">class="text-emerald-300">'YOUR_API_KEY',
    400 font-semibold">class="text-emerald-300">'x-api-secret': 400 font-semibold">class="text-emerald-300">'YOUR_API_SECRET'
  }
});

On-Ramp Flow

Convert KES (M-Pesa) to crypto tokens on-chain. Three steps: trigger payment, poll for confirmation, then push tokens to user.

1

Initiate STK Push

Send an M-Pesa payment prompt to the user's phone via POST /api/onramp-orders.

2

Poll for SUCCESS

Check the order status every ~5 seconds until it's no longer PENDING.

3

Trigger crypto deposit

Only after confirmed SUCCESS, call POST /api/deposit to release crypto.

Initiate STK Push

POSThttps://pool.swypt.io/api/onramp-orders

Interactive Playground

ParameterTypeRequiredDescription
partyAstringYes
User's M-Pesa phone number
Example:"254703710518"
amountstringYes
Amount in KES
Example:"5000"
sidestringYes
Transaction direction
Example:"onramp"
userAddressstringYes
User's blockchain wallet address
Example:"0x742d35..."
tokenAddressstringYes
Token contract address or Algorand asset ID
Example:"0xc2132D..."
js
400 font-semibold">const 300">axios = 300">require(400 font-semibold">class="text-emerald-300">'300">axios');

400 font-semibold">const 300">response = 400 font-semibold">await 300">axios.post(400 font-semibold">class="text-emerald-300">'https:400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">//pool.swypt.io/api/onramp-orders', {
  400 font-semibold">class="text-emerald-300">"partyA": 400 font-semibold">class="text-emerald-300">"254703710518",
  400 font-semibold">class="text-emerald-300">"amount": 400 font-semibold">class="text-emerald-300">"5000",
  400 font-semibold">class="text-emerald-300">"side": 400 font-semibold">class="text-emerald-300">"onramp",
  400 font-semibold">class="text-emerald-300">"userAddress": 400 font-semibold">class="text-emerald-300">"0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
  400 font-semibold">class="text-emerald-300">"tokenAddress": 400 font-semibold">class="text-emerald-300">"0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
}, {
  300">headers: {
    400 font-semibold">class="text-emerald-300">'x-api-key': 400 font-semibold">class="text-emerald-300">'YOUR_API_KEY',
    400 font-semibold">class="text-emerald-300">'x-api-secret': 400 font-semibold">class="text-emerald-300">'YOUR_API_SECRET'
  }
});

Check Status

GEThttps://pool.swypt.io/api/onramp-order-status/:orderID
Polling recommendation: Poll every 5 seconds. Do not call /api/deposit until status is SUCCESS.
javascript
400 font-semibold">const pollStatus = 400 font-semibold">async (orderID) => {
  400 font-semibold">let status = 400 font-semibold">class="text-emerald-300">'PENDING';
  while (status === 400 font-semibold">class="text-emerald-300">'PENDING') {
    400 font-semibold">await new Promise(res => setTimeout(res, 5000));
    400 font-semibold">const { 300">data } = 400 font-semibold">await 300">axios.get(
      `https:400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">//pool.swypt.io/api/onramp-order-status/${orderID}`,
      { 300">headers }
    );
    status = 300">data.300">data.status;
  }
  400 font-semibold">return status; 400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">// 400 font-semibold">class="text-emerald-300">"SUCCESS" | 400 font-semibold">class="text-emerald-300">"FAILED"
};
js
400 font-semibold">const 300">axios = 300">require(400 font-semibold">class="text-emerald-300">'300">axios');

400 font-semibold">const 300">response = 400 font-semibold">await 300">axios.get(400 font-semibold">class="text-emerald-300">'https:400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">//pool.swypt.io/api/onramp-order-status/D-rclsg-VL', {
  300">headers: {
    400 font-semibold">class="text-emerald-300">'x-api-key': 400 font-semibold">class="text-emerald-300">'YOUR_API_KEY',
    400 font-semibold">class="text-emerald-300">'x-api-secret': 400 font-semibold">class="text-emerald-300">'YOUR_API_SECRET'
  }
});

Process Transfer

POSThttps://pool.swypt.io/api/deposit
Caution: Only call this after receiving SUCCESS from step 2. Calling it on a PENDING order will fail.

Interactive Playground

js
400 font-semibold">const 300">axios = 300">require(400 font-semibold">class="text-emerald-300">'300">axios');

400 font-semibold">const 300">response = 400 font-semibold">await 300">axios.post(400 font-semibold">class="text-emerald-300">'https:400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">//pool.swypt.io/api/deposit', {
  400 font-semibold">class="text-emerald-300">"chain": 400 font-semibold">class="text-emerald-300">"celo",
  400 font-semibold">class="text-emerald-300">"address": 400 font-semibold">class="text-emerald-300">"0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
  400 font-semibold">class="text-emerald-300">"orderID": 400 font-semibold">class="text-emerald-300">"D-ri3b1-7H",
  400 font-semibold">class="text-emerald-300">"project": 400 font-semibold">class="text-emerald-300">"my-project"
}, {
  300">headers: {
    400 font-semibold">class="text-emerald-300">'x-api-key': 400 font-semibold">class="text-emerald-300">'YOUR_API_KEY',
    400 font-semibold">class="text-emerald-300">'x-api-secret': 400 font-semibold">class="text-emerald-300">'YOUR_API_SECRET'
  }
});

Create Ticket

POSThttps://pool.swypt.io/api/onramp-ticket
Tip: Only failed or cancelled onramp transactions can use orderID shorthand.
js
400 font-semibold">const 300">axios = 300">require(400 font-semibold">class="text-emerald-300">'300">axios');

400 font-semibold">const 300">response = 400 font-semibold">await 300">axios.post(400 font-semibold">class="text-emerald-300">'https:400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">//pool.swypt.io/api/onramp-ticket', {
  400 font-semibold">class="text-emerald-300">"orderID": 400 font-semibold">class="text-emerald-300">"D-rm3qn-3Q",
  400 font-semibold">class="text-emerald-300">"description": 400 font-semibold">class="text-emerald-300">"Refund for failed STK push"
}, {
  300">headers: {
    400 font-semibold">class="text-emerald-300">'x-api-key': 400 font-semibold">class="text-emerald-300">'YOUR_API_KEY',
    400 font-semibold">class="text-emerald-300">'x-api-secret': 400 font-semibold">class="text-emerald-300">'YOUR_API_SECRET'
  }
});

Transaction History

Both endpoints return paginated results sorted newest-first. All timestamps are ISO 8601 UTC.

Onramp Transactions

GEThttps://pool.swypt.io/api/deposit-transactions/{userAddress}
js
400 font-semibold">const 300">axios = 300">require(400 font-semibold">class="text-emerald-300">'300">axios');

400 font-semibold">const 300">response = 400 font-semibold">await 300">axios.get(400 font-semibold">class="text-emerald-300">'https:400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">//pool.swypt.io/api/deposit-transactions/0xb4da1bab9089BeE775577B3c6e27133aaf3946aA', {
  300">headers: {
    400 font-semibold">class="text-emerald-300">'x-api-key': 400 font-semibold">class="text-emerald-300">'YOUR_API_KEY',
    400 font-semibold">class="text-emerald-300">'x-api-secret': 400 font-semibold">class="text-emerald-300">'YOUR_API_SECRET'
  }
});

Offramp Transactions

GEThttps://pool.swypt.io/api/withdrawal-transactions/{userAddress}
js
400 font-semibold">const 300">axios = 300">require(400 font-semibold">class="text-emerald-300">'300">axios');

400 font-semibold">const 300">response = 400 font-semibold">await 300">axios.get(400 font-semibold">class="text-emerald-300">'https:400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">//pool.swypt.io/api/withdrawal-transactions/0xb4da1bab9089BeE775577B3c6e27133aaf3946aA', {
  300">headers: {
    400 font-semibold">class="text-emerald-300">'x-api-key': 400 font-semibold">class="text-emerald-300">'YOUR_API_KEY',
    400 font-semibold">class="text-emerald-300">'x-api-secret': 400 font-semibold">class="text-emerald-300">'YOUR_API_SECRET'
  }
});

Full Examples

End-to-end code for the two most common flows.

Algorand Offramp — Complete Flow

javascript
400 font-semibold">import algosdk 400 font-semibold">from 400 font-semibold">class="text-emerald-300">'algosdk';
400 font-semibold">import 300">axios 400 font-semibold">from 400 font-semibold">class="text-emerald-300">'300">axios';

400 font-semibold">const algodClient = new algosdk.Algodv2(400 font-semibold">class="text-emerald-300">'', 400 font-semibold">class="text-emerald-300">'https:400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">//mainnet-api.algonode.cloud', 443);
400 font-semibold">const SWYPT_WALLET = 400 font-semibold">class="text-emerald-300">'XEI2YQ47YAEDJEOYE3KQTYJNRCA2G2TO7U4STRYMOOXAZMIHRQ7HEEPGOE';
400 font-semibold">const HEADERS = { 400 font-semibold">class="text-emerald-300">'x-api-key': 400 font-semibold">class="text-emerald-300">'YOUR_KEY', 400 font-semibold">class="text-emerald-300">'x-api-secret': 400 font-semibold">class="text-emerald-300">'YOUR_SECRET' };

400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">// Step 1 — Get quote
400 font-semibold">const quote = 400 font-semibold">await 300">axios.post(400 font-semibold">class="text-emerald-300">'https:400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">//pool.swypt.io/api/fx-quotes', {
  400 font-semibold">type: 400 font-semibold">class="text-emerald-300">"offramp", fiatAmount: 400 font-semibold">class="text-emerald-300">"1000", cryptoCurrency: 400 font-semibold">class="text-emerald-300">"USDC",
  fiatCurrency: 400 font-semibold">class="text-emerald-300">"KES", network: 400 font-semibold">class="text-emerald-300">"algorand", category: 400 font-semibold">class="text-emerald-300">"B2C"
}, { 300">headers: HEADERS });

400 font-semibold">const { inputAmount, fee } = quote.300">data.300">data;
400 font-semibold">const totalUSDC = parseFloat(inputAmount) + parseFloat(fee.amount);

400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">// Step 2 — Send USDC to Swypt on-chain
400 font-semibold">const suggestedParams = 400 font-semibold">await algodClient.getTransactionParams().do();
400 font-semibold">const txn = algosdk.makeAssetTransferTxnWithSuggestedParamsFromObject({
  sender: userAddress, receiver: SWYPT_WALLET,
  amount: Math.floor(totalUSDC * 1_000_000),
  assetIndex: 31566704, suggestedParams,
  note: new Uint8Array(Buffer.400 font-semibold">from(400 font-semibold">class="text-emerald-300">'Swypt Offramp'))
});
400 font-semibold">const { txId } = 400 font-semibold">await algodClient.sendRawTransaction(400 font-semibold">await wallet.signTransaction(txn)).do();
400 font-semibold">await algosdk.waitForConfirmation(algodClient, txId, 4);

400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">// Step 3 — Notify Swypt
400 font-semibold">const { 300">data } = 400 font-semibold">await 300">axios.post(400 font-semibold">class="text-emerald-300">'https:400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">//pool.swypt.io/api/offramp-orders', {
  chain: 400 font-semibold">class="text-emerald-300">"algorand", hash: txId, partyB: 400 font-semibold">class="text-emerald-300">"254703710518",
  tokenAddress: 400 font-semibold">class="text-emerald-300">"31566704", project: 400 font-semibold">class="text-emerald-300">"my-project", userAddress
}, { 300">headers: HEADERS });

300">console.300">log(400 font-semibold">class="text-emerald-300">'Order ID:', 300">data.300">data.orderID);

Algorand Onramp — Complete Flow

javascript
400 font-semibold">const HEADERS = { 400 font-semibold">class="text-emerald-300">'x-api-key': 400 font-semibold">class="text-emerald-300">'YOUR_KEY', 400 font-semibold">class="text-emerald-300">'x-api-secret': 400 font-semibold">class="text-emerald-300">'YOUR_SECRET' };

400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">// Step 1 — Trigger STK Push
400 font-semibold">const { 300">data: stkData } = 400 font-semibold">await 300">axios.post(400 font-semibold">class="text-emerald-300">'https:400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">//pool.swypt.io/api/onramp-orders', {
  partyA: 400 font-semibold">class="text-emerald-300">"254703710518", amount: 400 font-semibold">class="text-emerald-300">"5000", side: 400 font-semibold">class="text-emerald-300">"onramp",
  userAddress: 400 font-semibold">class="text-emerald-300">"XEI2YQ47YAEDJEOYE3KQTYJNRCA2G2TO7U4STRYMOOXAZMIHRQ7HEEPGOE",
  tokenAddress: 400 font-semibold">class="text-emerald-300">"31566704"
}, { 300">headers: HEADERS });
400 font-semibold">const orderID = stkData.300">data.orderID;

400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">// Step 2 — Poll every 5s until settled
400 font-semibold">let status = 400 font-semibold">class="text-emerald-300">'PENDING';
while (status === 400 font-semibold">class="text-emerald-300">'PENDING') {
  400 font-semibold">await new Promise(r => setTimeout(r, 5000));
  400 font-semibold">const { 300">data } = 400 font-semibold">await 300">axios.get(
    `https:400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">//pool.swypt.io/api/onramp-order-status/${orderID}`,
    { 300">headers: HEADERS }
  );
  status = 300">data.300">data.status;
}
if (status !== 400 font-semibold">class="text-emerald-300">'SUCCESS') throw new Error(`Payment ${status}`);

400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">// Step 3 — Push crypto to user400 font-semibold">class="text-emerald-300">'s wallet
400 font-semibold">const deposit = 400 font-semibold">await 300">axios.post('https:400 font-semibold">class=400 font-semibold">class="text-emerald-300">"text-gray-500 italic">//pool.swypt.io/api/deposit400 font-semibold">class="text-emerald-300">', {
  chain: 400 font-semibold">class="text-emerald-300">"algorand",
  address: 400 font-semibold">class="text-emerald-300">"XEI2YQ47YAEDJEOYE3KQTYJNRCA2G2TO7U4STRYMOOXAZMIHRQ7HEEPGOE",
  orderID, project: 400 font-semibold">class="text-emerald-300">"my-project"
}, { 300">headers: HEADERS });

300">console.300">log('Tx hash:', deposit.300">data.hash);