Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Latest commit

 

History

52 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Api-server

Nad.fun Api-server is a high-performance data processing system designed to efficiently handle real-time updates and ordering of cryptocurrency-related data. It's built with Rust for optimal speed and reliability.

Features

  • Real-time data processing for cryptocurrency events
  • Efficient ordering algorithms for various crypto metrics
  • WebSocket support for live updates
  • Integration with PostgreSQL for data persistence
  • Redis caching for improved performance
  • Modular architecture for easy maintenance and scalability

Rest API

For detailed usage, refer to the API documentation.

WebSocket RPC Interface

Api-server provides a WebSocket-based RPC interface for real-time data subscription and updates.

Connection

To connect to the WebSocket server: wss://api-server.nad.fun/wss

RPC Methods

The WebSocket interface supports the following RPC methods:

  1. Order Subscribe

  2. Coin Subscribe

  3. Order Subscribe Subscribe to real-time updates for a specific order type. Request:

{
  "jsonrpc": "2.0",
  "method": "order_subscribe",
  "params": {
    "order_type": "creation_time"
  },
  "id": 1
}

Response:

{
  "jsonrpc": "2.0",
  "method": "order_subscribe",
  "result": {
    "status": "subscribed",
    "data": {
      "message_type": "ALL",
      "new_token": { ... },
      "new_swap": { ... },
      "order_type": "creation_time",
      "order_token": [ ... ]
    }
  }
}
  1. Coin Subscribe Subscribe to real-time updates for a specific coin. Request:
{
  "jsonrpc": "2.0",
  "method": "coin_subscribe",
  "params": {
    "coin_id": "example_coin_id"
  },
  "id": 2
}

Response:

{
  "jsonrpc": "2.0",
  "method": "coin_subscribe",
  "result": {
    "status": "subscribed",
    "data": {
      "message_type": "ALL",
      "new_token": { ... },
      "new_swap": { ... },
      "coin": { ... }
    }
  }
}

Usage Example Here's a simple JavaScript example using the WebSocket API:

const ws = new WebSocket("ws://read-engine.nad.fun/ws");

ws.onopen = () => {
  console.log("Connected to Api-server WebSocket");

  // Subscribe to creation time order updates
  ws.send(
    JSON.stringify({
      jsonrpc: "2.0",
      method: "order_subscribe",
      params: { order_type: "creation_time" },
      id: 1,
    })
  );
};

ws.onmessage = (event) => {
  const response = JSON.parse(event.data);
  console.log("Received update:", response);
  // Handle the update in your application
};

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

ws.onclose = () => {
  console.log("Disconnected from Api-server WebSocket");
};

About

Nad.fun api server

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages