REST API Server
Run HANA CLI as an HTTP server for programmatic access.
Starting the Server
bash
# Start on default port 3000
hana-cli server
# Start on custom port
hana-cli server --port 8080
# With authentication
hana-cli server --auth basicConfiguration
Environment Variables
bash
# Server configuration
HANA_API_PORT=3000
HANA_API_HOST=localhost
HANA_API_AUTH=basic
HANA_API_TIMEOUT=30000Server Options
| Option | Type | Description |
|---|---|---|
--port | number | Server port (default: 3000) |
--host | string | Server host (default: localhost) |
--auth | string | Authentication type: none, basic, bearer |
--timeout | number | Request timeout in ms |
Accessing the API
Swagger UI
http://localhost:3000/api-docsBase URL
http://localhost:3000/api/v1Example Requests
Get Database Info
bash
curl http://localhost:3000/api/v1/dbInfoResponse:
json
{
"database": "HDB",
"version": "2.00.050",
"platform": "SAP HANA"
}List Tables
bash
curl 'http://localhost:3000/api/v1/tables?schema=MYSCHEMA'Run Export
bash
curl -X POST http://localhost:3000/api/v1/export \
-H "Content-Type: application/json" \
-d '{
"schema": "HR",
"table": "EMPLOYEES",
"format": "json"
}'Authentication
Basic Auth
bash
# Start server with basic auth
hana-cli server --auth basic
# Call with credentials
curl -u username:password http://localhost:3000/api/v1/dbInfoBearer Token
bash
# Start server
hana-cli server --auth bearer
# Call with token
curl -H "Authorization: Bearer YOUR_TOKEN" \
http://localhost:3000/api/v1/dbInfoCORS & Headers
The API accepts these headers:
Content-Type: application/json
Accept: application/json
Authorization: Bearer <token>
X-Request-ID: <uuid>Rate Limiting
Default limits per IP:
- 100 requests per minute
- 1000 requests per hour
Configure via environment:
bash
export HANA_API_RATE_LIMIT=200
export HANA_API_RATE_WINDOW=60Error Handling
API returns standard HTTP status codes:
json
{
"error": "Table not found",
"code": "TABLE_NOT_FOUND",
"details": "Schema 'INVALID' not found"
}Status codes:
200- Success400- Bad request401- Unauthorized403- Forbidden404- Not found500- Server error
