Interactive Swagger API Documentation
The HANA CLI REST API server provides interactive Swagger/OpenAPI documentation accessible directly from the running server.
Accessing Swagger UI
When you start the API server, Swagger documentation is available at:
http://localhost:3010/api/swaggerStarting the API Server
bash
# Start API server
hana-cli server
# Or with custom port
hana-cli server --port 3100
# Then visit
open http://localhost:3010/api/swaggerWhat's Available in Swagger UI
The interactive Swagger interface includes:
1. Complete API Reference
- All 50+ REST endpoints documented
- Request/response schemas
- Parameter information
- Example values
2. Try It Out Feature
- Test endpoints directly from browser
- Configure parameters
- See live responses
- Inspect request/response headers
3. API Tags
- Configuration endpoints
- HANA System information
- HANA Objects (tables, views, functions)
- Inspection tools
- HDI management
- Cloud Services
- Documentation
- Export formats
- WebSocket
- Digital Foundation Adapter (DFA)
4. Schemas
- Request body schemas
- Response object definitions
- Data types and constraints
- Error responses
API Endpoints by Category
Configuration
GET / Get current configuration
PUT / Update configurationHANA System
GET /hana System information
GET /hana/schemas List schemas
GET /hana/version Database version
GET /hana/features Available featuresHANA Objects
GET /hana/tables List tables
GET /hana/views List views
GET /hana/functions List functions
GET /hana/procedures List procedures
GET /hana/indexes List indexes
GET /hana/roles List roles
GET /hana/containers List HDI containersInspection
GET /hana/inspect/table/:name Inspect table
GET /hana/inspect/view/:name Inspect view
GET /hana/inspect/function/:name Inspect functionData Operations
POST /execute Execute SQL query
POST /import Import data
POST /export Export dataCloud Services
GET /hana/btpInfo BTP information
GET /hana/btpSubs BTP subaccounts
GET /hana/hdiServiceInstances HDI instancesDocumentation
GET /docs This documentation
GET /docs/:command Command-specific docsExample API Calls
Using curl
bash
# Get system information
curl http://localhost:3010/hana
# List all tables
curl http://localhost:3010/hana/tables
# Execute SQL query
curl -X POST http://localhost:3010/execute \
-H "Content-Type: application/json" \
-d '{
"sql": "SELECT COUNT(*) FROM MY_TABLE"
}'Using the Try It Out Feature
- Open Swagger UI:
http://localhost:3010/api/swagger - Find endpoint (e.g.,
GET /hana/tables) - Click Try it out
- Enter parameters if needed
- Click Execute
- View response in Responses section
OpenAPI Specification
The complete OpenAPI 3.0 specification is available at:
http://localhost:3010/swagger-output.jsonUse this to:
- Generate client SDKs
- Import into API testing tools (Postman, Insomnia)
- Document in other tools
- Integrate with CI/CD pipelines
Import into Postman
- Open Postman
- Click Import
- Paste:
http://localhost:3010/swagger-output.json - All endpoints automatically added
- Ready to test
Authentication
By default, the API server runs in unsecured mode (development):
bash
hana-cli server
# No authentication requiredEnable Authentication
bash
# With API key
hana-cli server --api-key "my-secret-key"
# With token
hana-cli server --token-required --tokens "token1,token2"
# Then include in requests
curl -H "Authorization: Bearer token1" \
http://localhost:3010/hana/tablesRate Limiting & Performance
bash
# Enable rate limiting (100 req/min)
hana-cli server --rate-limit 100
# Configure connection pool
hana-cli server --pool-size 20
# Set query timeout (30 seconds default)
hana-cli server --timeout 60See Also
API Categories
Database Information
GET /api/v1/dbInfo- Get database informationGET /api/v1/alerts- Get database alertsGET /api/v1/replicationStatus- Check replication status
Tables & Schemas
GET /api/v1/tables- List tables in schemaGET /api/v1/views- List views in schemaGET /api/v1/schemas- List all schemas
Data Operations
POST /api/v1/export- Export table dataPOST /api/v1/import- Import dataPOST /api/v1/dataProfile- Profile table dataPOST /api/v1/dataDiff- Compare dataPOST /api/v1/dataValidator- Validate data
Schema Operations
POST /api/v1/compareSchema- Compare schemasPOST /api/v1/schemaClone- Clone schemaPOST /api/v1/tableCopy- Copy table
Analysis
POST /api/v1/duplicateDetection- Find duplicatesPOST /api/v1/dataLineage- Trace data lineagePOST /api/v1/referentialCheck- Check foreign keys
See full API Documentation for details.
Interactive Testing
Use Swagger UI for interactive API testing:
- Start server:
hana-cli server - Open:
http://localhost:3000/api-docs - Expand endpoint
- Click "Try it out"
- Enter parameters
- Click "Execute"
Command Line Testing
Use curl to test endpoints:
bash
# Get database info
curl http://localhost:3000/api/v1/dbInfo
# List tables
curl 'http://localhost:3000/api/v1/tables?schema=MYSCHEMA'
# Export data
curl -X POST http://localhost:3000/api/v1/export \
-H "Content-Type: application/json" \
-d '{
"schema": "HR",
"table": "EMPLOYEES",
"format": "json"
}'Authentication
All endpoints support:
- Basic Auth:
-u username:password - Bearer Token:
-H "Authorization: Bearer token" - No Auth (default): Open to localhost/configured hosts
Response Format
All responses follow standard format:
Success (200):
json
{
"success": true,
"data": { ... },
"timestamp": "2024-02-16T10:30:00Z"
}Error (400/500):
json
{
"success": false,
"error": "Error message",
"code": "ERROR_CODE",
"timestamp": "2024-02-16T10:30:00Z"
}Integrating with Tools
JavaScript/Node.js
javascript
const axios = require('axios');
async function getTableProfile(schema, table) {
try {
const response = await axios.post('http://localhost:3000/api/v1/dataProfile', {
schema: schema,
table: table
});
return response.data;
} catch (error) {
console.error('Error:', error.message);
}
}Python
python
import requests
def export_table(schema, table):
endpoint = 'http://localhost:3000/api/v1/export'
payload = {
'schema': schema,
'table': table,
'format': 'json'
}
response = requests.post(endpoint, json=payload)
return response.json()