HTTP API

Authentication

GreptimeDB supports the built-in Basic authentication scheme in HTTP API for SQL language and OpenTSDB protocol. To set up authentication, do the following:

  1. Encode your username and password using Base64 algorithm.
  2. Attach your encoded credentials to the HTTP request header using the format Authorization: Basic <base64-encoded-credentials>.

Here’s an example:

shell

  1. curl -X POST \
  2. -H 'Authorization: Basic Z3JlcHRpbWVfdXNlcjpncmVwdGltZV9wd2Q=' \
  3. -H 'Content-Type: application/x-www-form-urlencoded' \
  4. -d 'sql=show tables' \
  5. http://localhost:4000/v1/sql?db=public

json

  1. {
  2. "code": 0,
  3. "output": [
  4. {
  5. "records": {
  6. "schema": {
  7. "column_schemas": [
  8. {
  9. "name": "Tables",
  10. "data_type": "String"
  11. }
  12. ]
  13. },
  14. "rows": [
  15. ["numbers"]
  16. ]
  17. }
  18. }
  19. ],
  20. "execution_time_ms": 1
  21. }
  • Z3JlcHRpbWVfdXNlcjpncmVwdGltZV9wd2Q= is greptime_user:greptime_pwd encoded using Base64. Remember to replace it with your own configured username and password and encode them using Base64.
  • The public in the URL is the name of your database, which is required with authorization.

NOTE

InfluxDB uses its own authentication format, see InfluxDB for details.

Write Data

Query Data