REST API Reference
Base URL: https://api.unit.network
All endpoints return JSON. Authenticated endpoints require Authorization: Bearer <token> header.
Authentication
Register
POST /auth/register
Content-Type: application/json
{
"email": "[email protected]",
"password": "securePassword123",
"name": "Your Name"
}
Response:
{
"success": true,
"message": "Registration successful",
"data": {
"userId": "abc123",
"token": "eyJhbGciOi..."
}
}
Login
POST /auth/login
Content-Type: application/json
{
"email": "[email protected]",
"password": "securePassword123"
}
Response:
{
"success": true,
"data": {
"token": "eyJhbGciOi...",
"expiresIn": 86400
}
}
caution
Tokens expire after 24 hours. Implement token refresh in your application.
Oracle
Get Asset Value
GET /oracle/value/{id}
Returns the current USD value for a given token ID.
| Parameter | Type | Description |
|---|---|---|
id | number | Token ID (e.g., 0 for UNITCOIN) |
Example:
curl https://api.unit.network/oracle/value/0
Response:
{
"tokenId": 0,
"symbol": "UNITCOIN",
"valueUsd": "0.0142",
"timestamp": 1708300800
}
Assets
Get Asset Metadata
GET /assets/metadata/{id}
Returns token metadata including name, symbol, supply, and treasury info.
Response:
{
"tokenId": 0,
"name": "Unit Coin",
"symbol": "UNITCOIN",
"totalSupply": "1000000000000000000",
"treasuryValue": "50000000",
"decimals": 12
}
Get Asset Holders
GET /assets/holders/{id}
Returns paginated list of token holders.
| Parameter | Type | Description |
|---|---|---|
id | number | Token ID |
page | number | Page number (query param, default: 1) |
limit | number | Results per page (query param, default: 50) |
Example:
curl "https://api.unit.network/assets/holders/0?page=1&limit=10"
Pools
Get Pool Stats
GET /pool/stats
Returns aggregate statistics for all liquidity pools.
Response:
{
"totalPools": 1250,
"totalValueLocked": "12500000",
"volume24h": "350000",
"fees24h": "7000"
}
Get Pool by Token Pair
GET /pool/stats/{tokenA}/{tokenB}
Returns stats for a specific trading pair.
Error Handling
All errors follow a consistent format:
{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid or expired token"
}
}
| HTTP Code | Meaning |
|---|---|
200 | Success |
400 | Bad request — check parameters |
401 | Unauthorized — invalid/missing token |
404 | Resource not found |
429 | Rate limited — slow down |
500 | Server error |
Rate Limiting
The API is rate limited to 100 requests per minute per IP. Use WebSocket connections for real-time data instead of polling.
Related Pages
- WebSocket Guide — Real-time data via Substrate RPC
- SDK Integration — Polkadot.js API usage
- Oracle Pallet — How prices are determined on-chain