NutriSwap Logo NutriSwap

API Documentation

Integrate with NutriSwap's Powerful API

Access comprehensive on-chain and off-chain data across multiple blockchains. Build powerful applications with our reliable and high-performance API endpoints.

Get Started

Introduction

The NutriSwap API provides developers with programmatic access to NutriSwap's multi-chain data, including market information, token details, liquidity pools, historical prices, and user-specific data. Our API combines on-chain and off-chain sources to deliver the most comprehensive and accurate data for your applications.

Key Features

  • Multi-Chain Support - Access data from NutriEmp-Chain, Polygon, sgb, and more
  • Real-Time Updates - Get the latest market data with minimal latency
  • Historical Data - Access historical price and volume data for analysis
  • Comprehensive Token Information - Detailed metadata for thousands of tokens
  • User-Specific Data - Query user positions, transactions, and more
  • WebSocket Support - Subscribe to real-time updates for instant notifications

Authentication

To use the NutriSwap API, you'll need an API key. This key should be included in all API requests to the server in the header.

Get Your API Key

Sign up for a NutriSwap developer account to obtain your API key. Different tiers are available based on your usage requirements.

Using Your API Key

Include your API key in the X-API-KEY header of all your requests:

HTTP Header
X-API-KEY: your_api_key_here

Rate Limits

To ensure fair usage and system stability, the NutriSwap API implements rate limiting. The limits vary based on your subscription tier.

Tier Rate Limit Burst Limit WebSocket Connections
Free 100 requests/minute 200 requests/minute 2
Basic 500 requests/minute 1,000 requests/minute 5
Pro 2,000 requests/minute 4,000 requests/minute 20
Enterprise Custom Custom Custom

Base URLs

The NutriSwap API is available through multiple base URLs, depending on the chain you're querying and the environment you're working in.

REST API

Base URLs
# Production
https://api.nutriswap.link/v1

# Chain-Specific Endpoints
https://api.nutriswap.link/v1/chains/nutriemp
https://api.nutriswap.link/v1/chains/polygon
https://api.nutriswap.link/v1/chains/sgb

# Testnet
https://testnet-api.nutriswap.link/v1

WebSocket API

WebSocket URLs
# Production
wss://ws.nutriswap.link/v1

# Chain-Specific WebSockets
wss://ws.nutriswap.link/v1/chains/nutriemp
wss://ws.nutriswap.link/v1/chains/polygon
wss://ws.nutriswap.link/v1/chains/sgb

Market Data

Access real-time and historical market data across multiple chains. These endpoints provide information about trading volumes, liquidity, and other market metrics.

GET
/markets/summary

Get a summary of all markets across supported chains.

GET
/markets/{chain_id}/summary

Get a summary of markets for a specific chain.

GET
/markets/volume

Get trading volume data across all supported chains.

GET
/markets/liquidity

Get liquidity data across all supported chains.

Example Request

Request
GET https://api.nutriswap.link/v1/markets/summary
X-API-KEY: your_api_key_here

Token Data

Access detailed information about tokens across all supported chains. These endpoints provide token metadata, price data, and trading metrics.

GET
/tokens

Get a list of all tokens across supported chains.

GET
/tokens/{chain_id}/{address}

Get detailed information about a specific token.

GET
/tokens/{chain_id}/{address}/price

Get the current price of a specific token.

GET
/tokens/trending

Get a list of trending tokens based on volume and price action.

Example Request

Request
GET https://api.nutriswap.link/v1/tokens/420000/0x1234567890abcdef1234567890abcdef12345678
X-API-KEY: your_api_key_here

Pair Data

Access information about trading pairs across all supported chains. These endpoints provide details about liquidity pools, trading volumes, and price data.

GET
/pairs

Get a list of all trading pairs across supported chains.

GET
/pairs/{chain_id}/{address}

Get detailed information about a specific trading pair.

GET
/pairs/top

Get a list of top trading pairs based on volume and liquidity.

Example Request

Request
GET https://api.nutriswap.link/v1/pairs/420000/0xabcdef1234567890abcdef1234567890abcdef12
X-API-KEY: your_api_key_here

Historical Data

Access historical price, volume, and liquidity data for tokens and pairs. These endpoints are useful for building charts, performing analysis, and tracking performance over time.

GET
/tokens/{chain_id}/{address}/history

Get historical price and volume data for a specific token.

GET
/pairs/{chain_id}/{address}/history

Get historical data for a specific trading pair.

GET
/markets/{chain_id}/history

Get historical market data for a specific chain.

Example Request

Request
GET https://api.nutriswap.link/v1/tokens/420000/0x1234567890abcdef1234567890abcdef12345678/history?interval=1d&from=1620000000&to=1625000000
X-API-KEY: your_api_key_here

User Data

Access user-specific data such as positions, transactions, and balances. These endpoints require authentication and are useful for building portfolio trackers and trading interfaces.

GET
/users/{address}/positions

Get all liquidity positions for a specific user.

GET
/users/{address}/transactions

Get transaction history for a specific user.

GET
/users/{address}/balances

Get token balances for a specific user.

Example Request

Request
GET https://api.nutriswap.link/v1/users/0x9876543210abcdef9876543210abcdef98765432/positions
X-API-KEY: your_api_key_here

SDK Integration

The NutriSwap API can be easily integrated into your applications using our official SDK. The SDK provides a convenient wrapper around the API endpoints and handles authentication, rate limiting, and error handling for you.

Installation

npm
npm install @nutriswap/sdk

Basic Usage

JavaScript
import { NutriSwapSDK } from '@nutriswap/sdk';

// Initialize the SDK with your API key
const nutriswap = new NutriSwapSDK({
  apiKey: 'your_api_key_here',
  environment: 'production' // or 'testnet'
});

// Get market summary
const getMarketSummary = async () => {
  try {
    const marketSummary = await nutriswap.markets.getSummary({ timeframe: '7d' });
    console.log('Market Summary:', marketSummary);
    return marketSummary;
  } catch (error) {
    console.error('Error fetching market summary:', error);
  }
};

getMarketSummary();

WebSockets

The NutriSwap API provides WebSocket endpoints for real-time updates. WebSockets are useful for applications that require instant notifications about price changes, new trades, or other events.

Basic Usage

JavaScript
// Connect to the WebSocket API
const ws = new WebSocket('wss://ws.nutriswap.link/v1');

ws.onopen = () => {
  console.log('Connected to NutriSwap WebSocket API');
  
  // Authenticate with your API key
  ws.send(JSON.stringify({
    type: 'auth',
    payload: {
      api_key: 'your_api_key_here'
    }
  }));
  
  // Subscribe to market updates
  ws.send(JSON.stringify({
    type: 'subscribe',
    channel: 'markets',
    payload: {
      chain_id: 420000
    }
  }));
};

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  console.log('Received WebSocket message:', data);
};

ws.onerror = (error) => {
  console.error('WebSocket error:', error);
};

ws.onclose = (event) => {
  console.log('Disconnected from WebSocket API:', event.code, event.reason);
};

Error Handling

The NutriSwap API uses standard HTTP status codes to indicate the success or failure of an API request. In addition, the response body will contain more detailed information about the error.

Error Response Format

JSON
{
  "success": false,
  "error": {
    "code": "rate_limit_exceeded",
    "message": "Rate limit exceeded. Please try again later or upgrade your plan.",
    "status": 429
  }
}

Support

If you need help with the NutriSwap API, there are several resources available to you:

  • Documentation - This documentation provides comprehensive information about the API endpoints, parameters, and responses.
  • Discord Community - Join our Discord server to connect with other developers and get help from the community.
  • GitHub Issues - Report bugs or request features on our GitHub repository.
  • Email Support - Contact our support team at [email protected] for personalized assistance.