API Reference
Complete REST API documentation for Stock Exchange
Base URL
All API endpoints are available at:
http://localhost:3000Endpoints
Place Limit Order
Place a new limit order on the exchange.
POST /order
Content-Type: application/json
{
"userID": 6,
"type": "LIMIT",
"bid": true,
"size": 10,
"price": 1000,
"market": "INN"
}{
"OrderID": 60464691
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
userID | integer | Yes | Unique identifier for the user |
type | string | Yes | Order type: LIMIT or MARKET |
bid | boolean | Yes | true for buy orders, false for sell orders |
size | integer | Yes | Number of shares to trade |
price | float | Yes* | Price per share (*required for LIMIT orders only) |
market | string | Yes | Trading symbol/ticker (e.g., "INN", "AAPL") |
Get User Orders
Retrieve all orders for a specific user.
GET /order/{userID}{
"orders": [
{
"ID": 60464691,
"UserID": 6,
"Price": 1000,
"Size": 10,
"Bid": true,
"Timestamp": 1699887123000
},
{
"ID": 85937264,
"UserID": 6,
"Price": 999,
"Size": 44,
"Bid": true,
"Timestamp": 1699887125000
}
]
}Get Best Ask
Get the best (lowest) ask price for a market.
GET /book/{market}/ask{
"Bid": false,
"ID": 0,
"Price": 990,
"Size": 0,
"Timestamp": 0,
"UserID": 8
}Get Best Bid
Get the best (highest) bid price for a market.
GET /book/{market}/bid{
"Bid": true,
"ID": 0,
"Price": 970,
"Size": 0,
"Timestamp": 0,
"UserID": 8
}Get All Trades
Retrieve all executed trades for a specific market.
GET /trades/{market}{
"trades": [
{
"price": 1000,
"size": 100,
"timestamp": 1699887120000,
"bid": true
},
{
"price": 1001,
"size": 50,
"timestamp": 1699887125000,
"bid": false
}
]
}Response Codes
| Code | Description |
|---|---|
200 | Success |
400 | Bad Request - Invalid parameters |
404 | Not Found - Resource doesn't exist |
500 | Internal Server Error |
Rate Limiting
Currently, there are no rate limits implemented. In production, you should implement appropriate rate limiting to prevent abuse.
Error Responses
Error responses follow this format:
{
"error": "Error message description",
"code": "ERROR_CODE"
}