Skip to main content

Developer Documentation

Integrate GO Swap into your application using smart contracts, REST APIs, or real-time data streams.

Integration Methods

1. Smart Contracts (On-chain)

Direct interaction with GO Swap smart contracts for trustless integration.

Contract Addresses

BSC Mainnet:

LiquidityPool: TBA
Factory: TBA (future)
Router: TBA (future)
Token GO: TBA

BSC Testnet:

LiquidityPool: TBA
Token GO: TBA

Example: Execute a Swap

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface ILiquidityPool {
function swap(
uint256 amountIn,
address tokenIn,
address tokenOut,
uint256 minAmountOut,
uint256 deadline
) external returns (uint256 amountOut);
}

contract MyDApp {
ILiquidityPool public pool;

function executeSwap(
uint256 amount,
address tokenIn,
address tokenOut
) external {
// Approve tokens first
IERC20(tokenIn).approve(address(pool), amount);

// Execute swap
pool.swap(
amount,
tokenIn,
tokenOut,
0, // minAmountOut (set slippage in production)
block.timestamp + 300 // 5 minute deadline
);
}
}

2. REST API (Historical Data)

Query historical swap data and analytics.

Base URL: https://api.goswap.io (TBA)

Core Endpoints

GET /health

Check API health status.

Response:

{
"status": "ok",
"timestamp": "2026-02-18T10:00:00Z"
}
GET /swaps

Get all historical swaps with pagination.

Query Parameters:

  • limit (optional) - Number of results (default: 100, max: 1000)
  • offset (optional) - Pagination offset (default: 0)

Response:

{
"swaps": [
{
"id": "0x123...",
"blockNumber": 12345678,
"timestamp": "2026-02-18T10:00:00Z",
"sender": "0xabc...",
"tokenIn": "0xdef...",
"tokenOut": "0x789...",
"amountIn": "1000000000000000000",
"amountOut": "2000000000000000000"
}
],
"total": 50000,
"limit": 100,
"offset": 0
}
GET /swaps/latest

Get the most recent swap.

Response:

{
"id": "0x123...",
"blockNumber": 12345678,
"timestamp": "2026-02-18T10:00:00Z",
"sender": "0xabc...",
"tokenIn": "0xdef...",
"tokenOut": "0x789...",
"amountIn": "1000000000000000000",
"amountOut": "2000000000000000000"
}
GET /pools

Get information about all liquidity pools.

Response:

{
"pools": [
{
"address": "0x123...",
"tokenA": "0xabc...",
"tokenB": "0xdef...",
"reserveA": "1000000000000000000000",
"reserveB": "500000000000000000000",
"totalLiquidity": "707106781186547524",
"volume24h": "100000000000000000000"
}
]
}

3. SSE Streams (Real-time Data)

Subscribe to real-time swap events via Server-Sent Events.

GET /swaps/stream

Receive real-time swap notifications as they happen on-chain.

Example (JavaScript):

const eventSource = new EventSource('https://api.goswap.io/swaps/stream');

eventSource.onmessage = (event) => {
const swap = JSON.parse(event.data);
console.log('New swap:', swap);

// Handle swap data
updateUI(swap);
};

eventSource.onerror = (error) => {
console.error('SSE error:', error);
// Reconnect logic
};

Event Data:

{
"id": "0x123...",
"blockNumber": 12345678,
"timestamp": "2026-02-18T10:00:00Z",
"sender": "0xabc...",
"tokenIn": "0xdef...",
"tokenOut": "0x789...",
"amountIn": "1000000000000000000",
"amountOut": "2000000000000000000"
}

SDK Libraries (Coming Soon)

Official SDKs for easy integration:

  • JavaScript/TypeScript - React, Vue, Node.js
  • Python - Data analysis and bots
  • Go - High-performance integrations
  • Rust - On-chain programs and validators

Code Examples

Web3.js Integration

const Web3 = require('web3');
const web3 = new Web3('https://bsc-dataseed.binance.org/');

const poolABI = [...]; // LiquidityPool ABI
const poolAddress = '0x...';
const pool = new web3.eth.Contract(poolABI, poolAddress);

// Get current reserves
const reserves = await pool.methods.getReserves().call();
console.log('Reserve A:', reserves[0]);
console.log('Reserve B:', reserves[1]);

// Execute swap
const amountIn = web3.utils.toWei('1', 'ether');
await pool.methods.swap(
amountIn,
tokenInAddress,
tokenOutAddress,
minAmountOut,
deadline
).send({ from: userAddress });

Ethers.js Integration

const { ethers } = require('ethers');

const provider = new ethers.providers.JsonRpcProvider(
'https://bsc-dataseed.binance.org/'
);
const signer = provider.getSigner();

const pool = new ethers.Contract(poolAddress, poolABI, signer);

// Get reserves
const [reserveA, reserveB] = await pool.getReserves();

// Execute swap
const tx = await pool.swap(
amountIn,
tokenInAddress,
tokenOutAddress,
minAmountOut,
deadline
);

await tx.wait();
console.log('Swap complete:', tx.hash);

Rate Limits

API rate limits:

  • Free tier: 60 requests/minute
  • Developer tier: 600 requests/minute
  • Enterprise tier: Custom limits

SSE connections are not rate-limited but limited to 5 concurrent connections per IP.

Error Handling

HTTP Error Codes

CodeMeaning
200Success
400Bad Request - Invalid parameters
429Too Many Requests - Rate limit exceeded
500Internal Server Error
503Service Unavailable

Smart Contract Errors

Common revert reasons:

  • INSUFFICIENT_LIQUIDITY - Pool doesn't have enough tokens
  • EXPIRED - Transaction deadline passed
  • SLIPPAGE_EXCEEDED - Output less than minimum
  • INVALID_AMOUNT - Zero or invalid amount provided

Support