Complete API documentation for ClickHouse OHLCV REST API with ISO 8601 time format support.
http://localhost:8000
Currently, no authentication is required (Phase 1-3). API Key authentication will be added in Phase 5.
Comprehensive health check endpoint with database connectivity verification.
Response (Healthy):
{
"success": true,
"status": "healthy",
"timestamp": "2025-11-29T09:38:47.442042",
"database": {
"connected": true,
"ping_ms": 1.45
},
"version": "1.0.0",
"query_time_ms": 1.47
}Response (Unhealthy):
{
"success": false,
"status": "unhealthy",
"timestamp": "2025-11-29T09:38:47.442042",
"database": {
"connected": false,
"error": "Connection timeout"
},
"version": "1.0.0",
"query_time_ms": 1.47
}Status Codes:
200 OK: Always returns 200, checkstatusfield for health status
Readiness check for Kubernetes and orchestration systems.
Response (Ready):
{
"success": true,
"ready": true,
"timestamp": "2025-11-29T09:38:47.442042"
}Response (Not Ready):
{
"success": false,
"ready": false,
"reason": "Database not initialized",
"timestamp": "2025-11-29T09:38:47.442042"
}Status Codes:
200 OK: Always returns 200, checkreadyfield
Simple liveness probe for Kubernetes.
Response:
{
"success": true,
"alive": true,
"timestamp": "2025-11-29T09:38:47.442042"
}Status Codes:
200 OK: API process is running
Get OHLCV candlestick data for a symbol.
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
symbol |
string | Yes | Trading symbol (e.g., BINANCE:BTCUSDT.P) |
start |
string | Yes | Start time in ISO 8601 format (see Time Format) |
end |
string | No | End time in ISO 8601 format (defaults to now) |
limit |
integer | No | Max records (default: 1000, max: 10000) |
offset |
integer | No | Skip N records (default: 0) |
Example Request (ISO 8601 - Recommended):
curl "http://localhost:8000/api/v1/ohlcv?symbol=BINANCE:BTCUSDT.P&start=2025-07-01T00:00:00Z&end=2025-08-01T00:00:00Z&limit=100"Example Request (Legacy Format - Deprecated):
curl "http://localhost:8000/api/v1/ohlcv?symbol=BINANCE:BTCUSDT.P&start=20250701-0000&end=20250801-0000&limit=100"Response:
{
"success": true,
"data": [
{
"candle_time": "2025-07-01T00:00:00",
"symbol": "BINANCE:BTCUSDT.P",
"open": 50000.0,
"high": 51000.0,
"low": 49500.0,
"close": 50500.0,
"volume": 1234567.89
}
],
"metadata": {
"total_records": 1,
"limit": 100,
"offset": 0,
"has_more": false,
"query_time_ms": 45.2,
"timestamp": "2025-11-13T10:30:45.123Z"
}
}Status Codes:
200 OK: Success422 Unprocessable Entity: Validation error503 Service Unavailable: Database error
Get the most recent candle for a symbol.
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
symbol |
string | Yes | Trading symbol |
Example Request:
curl "http://localhost:8000/api/v1/ohlcv/latest?symbol=BINANCE:BTCUSDT.P"Response:
{
"success": true,
"data": [
{
"candle_time": "2025-07-01T00:00:00",
"symbol": "BINANCE:BTCUSDT.P",
"open": 50000.0,
"high": 51000.0,
"low": 49500.0,
"close": 50500.0,
"volume": 1234567.89
}
],
"metadata": {
"total_records": 1,
"limit": 1,
"offset": 0,
"has_more": false,
"query_time_ms": 12.3,
"timestamp": "2025-11-13T10:30:45.123Z"
}
}Status Codes:
200 OK: Success404 Not Found: No data found for symbol422 Unprocessable Entity: Validation error
All error responses follow this format:
{
"success": false,
"error_code": "ERROR_CODE",
"message": "Human-readable error message",
"details": {
"additional": "context"
},
"timestamp": "2025-11-13T10:30:45.123Z"
}| Code | Description |
|---|---|
VALIDATION_ERROR |
Input validation failed |
INVALID_TIME_FORMAT |
Time format is incorrect |
DATA_NOT_FOUND |
Requested data not found |
DATABASE_ERROR |
Database operation failed |
DATABASE_CONNECTION_ERROR |
Cannot connect to database |
DATABASE_QUERY_ERROR |
Query execution failed |
DATABASE_TIMEOUT_ERROR |
Query timed out |
INTERNAL_ERROR |
Unexpected server error |
Currently no rate limiting (Phase 1-3). Will be added in Phase 5.
All responses include these headers:
X-Request-ID: Unique request identifierX-Process-Time: Request processing time in seconds
Use limit and offset parameters for pagination:
# Get first page (records 0-99)
curl ".../ohlcv?symbol=BINANCE:BTCUSDT.P&start=2025-07-01T00:00:00Z&limit=100&offset=0"
# Get second page (records 100-199)
curl ".../ohlcv?symbol=BINANCE:BTCUSDT.P&start=2025-07-01T00:00:00Z&limit=100&offset=100"The metadata.has_more field indicates if more records are available.
The API supports ISO 8601 format (recommended) with backward compatibility for legacy format.
Supported Formats:
-
Basic Format (assumes UTC if no timezone specified)
2025-07-01T00:00:00 -
UTC Format (recommended for clarity)
2025-07-01T00:00:00Z -
With Timezone Offset
2025-07-01T00:00:00+03:00 # UTC+3 2025-07-01T00:00:00-05:00 # UTC-5 -
With Milliseconds
2025-07-01T00:00:00.000Z 2025-07-01T15:30:45.123Z
Examples:
# UTC format (recommended)
?start=2025-07-01T00:00:00Z&end=2025-08-01T00:00:00Z
# With timezone offset
?start=2025-07-01T00:00:00+03:00&end=2025-08-01T00:00:00+03:00
# With milliseconds
?start=2025-07-01T00:00:00.000Z&end=2025-08-01T23:59:59.999Z
# Basic format (assumes UTC)
?start=2025-07-01T00:00:00&end=2025-08-01T00:00:00For backward compatibility, the old format is still supported but deprecated:
YYYYMMDD-HHmm
Examples:
20250701-0000- July 1, 2025 at midnight20250801-1530- August 1, 2025 at 3:30 PM
Note: This format will be removed in a future version. Please migrate to ISO 8601.
- All times are converted to UTC internally
- If no timezone is specified in ISO 8601 format, UTC is assumed
- Response timestamps are always in UTC
- Timezone offsets are properly handled and converted
All timestamps in responses use ISO 8601 format:
{
"candle_time": "2025-07-01T15:30:00",
"timestamp": "2025-11-13T10:30:45.123Z"
}Valid ISO 8601 Examples:
✓ 2025-07-01T00:00:00
✓ 2025-07-01T00:00:00Z
✓ 2025-07-01T00:00:00+03:00
✓ 2025-07-01T00:00:00-05:00
✓ 2025-07-01T00:00:00.000Z
✓ 2025-07-01T00:00:00.123456Z
Valid Legacy Examples (Deprecated):
✓ 20250701-0000
✓ 20250801-1530
Invalid Examples:
✗ 2025-07-01 # Missing time part
✗ 2025/07/01T00:00:00 # Wrong date separator
✗ 01-07-2025T00:00:00 # Wrong date order
✗ 2025-7-1T00:00:00 # Missing leading zeros
✗ invalid-time # Not a valid format
{
"detail": "Invalid time format: invalid-time. Expected ISO 8601 format (e.g., 2025-07-01T00:00:00Z, 2025-07-01T00:00:00+03:00) or legacy format (YYYYMMDD-HHmm)"
}If you're currently using the legacy format, here's how to migrate:
Before (Legacy):
curl ".../ohlcv?symbol=BINANCE:BTCUSDT.P&start=20250701-0000&end=20250801-0000"After (ISO 8601):
curl ".../ohlcv?symbol=BINANCE:BTCUSDT.P&start=2025-07-01T00:00:00Z&end=2025-08-01T00:00:00Z"Conversion Rules:
20250701-0000→2025-07-01T00:00:00Z20250801-1530→2025-08-01T15:30:00Z
Benefits of ISO 8601:
- ✅ International standard
- ✅ Timezone support
- ✅ Better readability
- ✅ Millisecond precision
- ✅ Compatible with most programming languages and databases
Interactive API documentation is available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- OpenAPI JSON: http://localhost:8000/openapi.json
The interactive documentation includes:
- Try-it-out functionality with ISO 8601 format
- Request/response examples
- Parameter validation
- Schema definitions