HttpServer resource creates an HTTP API endpoint for your Ditto database, allowing any HTTP client (including web browsers) to query and manipulate data using standard REST methods. This enables integration with systems that cannot use the Ditto SDK directly.
Basic Configuration
Required Fields
| Field | Type | Description |
|---|---|---|
resource_type | string | Must be "HttpServer" |
listen_addr | string | Address and port to listen on (format: "host:port") |
databases | object | Map of database configurations to expose via HTTP. Each key is the database name, and the value is an HttpDbConfig object |
Database Configuration (HttpDbConfig)
Each entry in thedatabases map has the following fields:
Required Fields
| Field | Type | Description |
|---|---|---|
db_id | string | The database ID (UUIDv4 format) to expose via HTTP. Must match an existing DittoDatabase resource |
http_api | boolean/object | Enable HTTP API endpoints. Use true to enable all, false to disable, or an object for fine-grained control |
Optional Fields
| Field | Type | Default | Description |
|---|---|---|---|
base_path | string/null | Uses the YAML key name | URL path prefix for the API endpoints. Must match pattern ^[A-Za-z0-9_-]+$ |
default_timeout_ms | integer | 5000 | Default timeout for HTTP requests in milliseconds. Used when timeout header is 0 or null and max_timeout_ms is not null (min: 0, max: 18446744073709551615) |
max_timeout_ms | integer/null | 10000 | Maximum timeout allowed for operations in milliseconds. Set to null to allow operations to hang forever. To indicate infinite timeout per request, use timeout header of 0 (min: 0, max: 18446744073709551615) |
Listen Address Configuration
Thelisten_addr field specifies where the HTTP server listens for connections:
- IPv4 localhost:
"127.0.0.1:PORT"or"localhost:PORT" - IPv6 localhost:
"[::1]:PORT"or"[::]:PORT"
HTTP API Configuration
Thehttp_api field controls which endpoints are enabled:
Simple Configuration
Enable or disable all endpoints:Fine-Grained Configuration
Control individual endpoints:| Field | Type | Default | Description |
|---|---|---|---|
enable_execute | boolean | true | Enable the /execute endpoint for DQL queries |
enable_healthcheck | boolean | false | Enable the health check endpoint |
enable_presence | boolean | true | Enable the GET presence endpoint |
enable_get_logs | boolean | true | Enable the GET /logs endpoint |
max_body_size_mb | integer | 2 | Maximum body size for HTTP requests in MB (0-65535). Increase for large attachment uploads |
attachments | object | See below | Attachments API configuration |
Attachments Configuration
| Field | Type | Default | Description |
|---|---|---|---|
enable_download | boolean | true | Enable downloading attachments via HTTP |
enable_upload | boolean | true | Enable uploading attachments via HTTP |
API Endpoints
All endpoints are prefixed with/<base_path> where base_path defaults to the database key name in the databases configuration.
Execute Endpoint
Path:POST /<base_path>/execute
Execute DQL queries against the database.
Request body:
- Timeout header: Specify custom timeout for the request
- Success (200): Query results in JSON format
- Error (4xx/5xx): Error details with appropriate HTTP status code
Health Check Endpoint
Path:GET /<base_path>
Simple health check that returns HTTP 200 if the server is running.
Presence Endpoint
Path:GET /<base_path>/presence
Get information about connected peers and their presence status.
Logs Endpoint
Path:GET /<base_path>/logs
Retrieve logs from the Edge Server.
Attachments Endpoints
Download: Retrieve attachments from the database Upload: Upload new attachments to the databaseComplete Examples
Basic HTTP Server
http://127.0.0.1:8080/my_api/execute
Custom Base Path
http://localhost:3000/my_server/execute
Multiple Databases on One HTTP Server
Expose multiple databases on a single HTTP server with different base paths:- Production:
http://127.0.0.1:8080/prod/execute - Staging:
http://127.0.0.1:8080/staging/execute
Multiple HTTP Servers
Expose databases on different ports:- Production:
http://127.0.0.1:8080/api/execute - Staging:
http://127.0.0.1:8081/api/execute
Health Check Only Server
Minimal configuration for monitoring:http://127.0.0.1:9090/health
Advanced Attachments Configuration with Timeouts
Using the HTTP API
Query Execution Example
Health Check Example
Security Considerations
While Ditto Edge Server is in private preview, no deployments should be considered secure. Use is for development purposes only.Important Notes
- Database ID Matching: The
db_idmust exactly match a DittoDatabase resource in your configuration - Port Conflicts: Ensure each HttpServer uses a unique port to avoid binding conflicts
- Restart Required: Changes to HTTP server configuration require Edge Server restart
- IPv6 Support: Use bracketed notation for IPv6 addresses (e.g.,
"[::1]:8080")