Skip to main content

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.

ParameterTypeDescription
idnumberToken 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.

ParameterTypeDescription
idnumberToken ID
pagenumberPage number (query param, default: 1)
limitnumberResults 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 CodeMeaning
200Success
400Bad request — check parameters
401Unauthorized — invalid/missing token
404Resource not found
429Rate limited — slow down
500Server 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.