Onyx Predictions Market — Developer Hub
Sports prediction exchange for NBA, MLB, NFL & NHL binary contracts. This is the API server running on port 3000.
Swagger API Docs
Interactive REST API documentation. Try endpoints, see request/response schemas.
Trading Portal
User-facing Next.js web app on port 3001. Browse markets, place bets, view portfolio.
Health Check
System status — PostgreSQL, Redis, NJT bridge connectivity and contract counts.
OpenAPI Spec
Raw OpenAPI 3.0 JSON specification. Import into Postman, Insomnia, or any client.
💰 How Pricing Works
Binary Contracts
Every prediction market has two contracts: YES and NO. Each contract trades between $0.01 and $0.99, representing the probability of the outcome.
Payouts
If your contract wins, it pays out $1.00. If it loses, it pays $0.00.
Order Book
Prices are set by limit orders from traders. The best bid/ask form the spread. Orders match using FIFO price-time priority.
Settlement
Markets settle automatically when the game ends. YES = $1.00 if the outcome occurred, NO = $1.00 otherwise. Voided markets refund at original cost.
Live prices stream from the NJT Market Data WebSocket (staging) via the Bridge process. The bridge subscribes to all NBA, MLB, NFL, and NHL products and publishes quote updates to Redis in real-time. The API WS server at /ws (port 3000) forwards these to connected browser clients.
📚 Documentation
⚡ Quick Start
# Check API health
curl http://localhost:3000/api/health
# List markets
curl http://localhost:3000/api/markets?sport=NBA&limit=5
# Register a user
curl -X POST http://localhost:3000/api/auth/register \
-H 'Content-Type: application/json' \
-d '{"email":"test@example.com","username":"testuser","password":"password123"}'
# Place an order (with auth token)
curl -X POST http://localhost:3000/api/orders \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{"contract_id":"uuid","side":"buy","order_type":"limit","price":0.50,"qty":5}'