Overview
The current Exchange API implementation does not require authentication for most endpoints. This is a simplified setup intended for development and testing.In a production environment, you should implement proper authentication using JWT tokens, API keys, or session-based authentication.
User identification
Endpoints that require user identification accept auser_id parameter in the request body:
Example order request
User creation
The/api/v1/users endpoint generates a new user with a UUID:
Response
The code comment in
router/src/routes/user.rs:16 notes that the user ID would ideally be fetched from cookies or JWT in a production system.Public endpoints
The following endpoints do not require user identification and are publicly accessible:Health check
GET /api/v1/healthMarket depth
GET /api/v1/depthTrade history
GET /api/v1/tradesKlines data
GET /api/v1/klinesTicker data
GET /api/v1/tickersAuthenticated endpoints
The following endpoints require auser_id in the request body:
Order management
Execute order:Error responses
Missing user ID
If you attempt to call an authenticated endpoint without providing auser_id, the request will fail during deserialization:
Invalid user ID
If you provide auser_id that doesn’t exist in the system, the order processing service will reject the request:
CORS configuration
The API is configured with permissive CORS settings allowing requests from any origin:Future authentication
For production deployment, consider implementing:JWT tokens
Issue tokens on login and validate on each request
API keys
Generate API keys for programmatic access
Session cookies
Use secure HTTP-only cookies for web clients
OAuth 2.0
Integrate with third-party identity providers
Security considerations
The current implementation is designed for development and testing. Before deploying to production:
- Implement proper authentication and authorization
- Restrict CORS to trusted origins
- Use HTTPS for all API communication
- Implement rate limiting per user
- Add request signing for critical operations
- Validate all user inputs thoroughly