HTTP Query API
Each cluster runs the Hydrolix HTTP query API. The API endpoint is https://hostname.hydrolix.live/query.
The API provides both a recommended POST and alternate GET endpoint.
This interface supports
Clients may authenticate with credentials or present an authorization token.
Streaming results⚓︎
Use query option hdx_query_streaming_result to request a streamed response as soon as any data become available. By default this setting is false.
The server only accepts this query option as an HTTP header or query parameter. It chooses a buffer allocation strategy for streaming before parsing the SQL, so it doesn't accept hdx_query_streaming_result in an SQL SETTINGS clause.
Response data from the server begins streaming to the client as data is available. This reduces the time before the client application can begin reading data.
When beginning a streaming response, the X-Hdx-Query-Stats aren't complete, so the response header is omitted. To analyze query performance stats, correlate the X-Clickhouse-Query-Id with logs, for example Hydrologs or active queries.
These examples demonstrate an HTTP client sending a query and receiving a response. The logs are timestamped with the ts -i "%.T" tool to record incremental time passing between lines.
- Example time differential is 1.8 seconds.
In this example using streaming, the elapsed time to client's receipt of initial data after sending the query is 1.8 seconds.
- Example query time differential is 11.6 seconds.
In this example, without streaming, the elapsed time to initial data is 11.6 seconds after the client sends the query. The server used the time to collect the entire result set.
Present an authorization token⚓︎
The HTTP query API supports auth tokens and authentication via local user credentials.
Get the bearer token, which is good for the next 24 hours, to authenticate future API calls. This command assumes you've set the $HDX_HOSTNAME, $HDX_USER, and $HDX_PASSWORD environment variables:
If the token is valid, the HTTP Query API returns an HTTP 200 and the response.
If the token is invalid, the HTTP Query API returns an HTTP 400 and the following error.
If the token is empty, the HTTP Query API returns an HTTP 400 and the following error.
Authenticate with credentials⚓︎
If the credentials are valid, the HTTP Query API returns an HTTP 200 and the response.
If the credentials are invalid, the HTTP Query API returns an HTTP 400 and the following error.