API Overview
Polyblock provides a comprehensive API for accessing market data, managing orders, and receiving real-time updates via WebSocket. All endpoints return JSON responses.
Base URLs
Polyblock uses multiple endpoints for different services:
Next.js API (Port 3000)
Frontend API routes for market data and user information.
http://localhost:3000/apiWebSocket Service HTTP (Port 8081)
Direct access to the WebSocket service HTTP endpoints.
http://localhost:8081WebSocket Connection (Port 8081)
Real-time data streaming via WebSocket protocol.
ws://localhost:8081/wsResponse Format
All API responses follow a consistent JSON format:
// Success response
{
"data": { ... },
"success": true
}
// Error response
{
"error": "Error message description",
"success": false
}Rate Limits
API endpoints have rate limits to ensure fair usage:
Public Endpoints
100 requests per minute per IP address. Market data and prices.
Authenticated Endpoints
300 requests per minute per API key. Trading and user data.
X-RateLimit-Remaining andX-RateLimit-Reset to monitor your usage.Error Handling
The API uses standard HTTP status codes:
200 OK — Request succeeded. Response body contains the requested data.
400 Bad Request — Invalid request parameters. Check the error message for details.
401 Unauthorized — Missing or invalid authentication. Verify your API credentials.
429 Too Many Requests — Rate limit exceeded. Wait before retrying.
500 Internal Server Error — Server-side error. Retry with exponential backoff.
