Skip to content

HTTP

  1. Introduction
  2. API Endpoint
  3. General Request Structure
  4. Supported Commands
  5. Examples

DiceDB supports HTTP protocol for clients to connect to the database. This allows clients to connect to DiceDB over the web stack, enabling frontends to have direct access to DiceDB.

All requests should be sent to the base URL of your server, followed by the command name:

http://your-server-address:port/<command>
  • HTTP Method: POST for all operations
  • Path: The DiceDB command name (e.g., /GET, /SET, /HGET)
  • Headers:
    • Content-Type: application/json
  • Body: JSON object containing command arguments

Certain commands may require additional query parameters. For example:

  • key_prefix: Used for the JSON.INGEST command to specify a key prefix

These will be specified in the command documentation.

Our HTTP API supports all DiceDB commands. Please refer to our comprehensive command reference for each command, commands which lack support will be flagged as such.

Request:

POST /SET HTTP/1.1
Host: your-server-address
Content-Type: application/json
{
"key": "mykey",
"value": "Hello, World!"
}

Response:

{
"status": "success",
"data": "OK"
}

Request:

POST /GET HTTP/1.1
Host: your-server-address
Content-Type: application/json
{
"key": "mykey"
}

Response:

{
"status": "success",
"data": "Hello, World!"
}

Request:

POST /HSET HTTP/1.1
Host: your-server-address
Content-Type: application/json
{
"key": "test",
"field": "test",
"value": "test"
}

Response:

{
"status": "success",
"data": 1
}

Request:

POST /HGET HTTP/1.1
Host: your-server-address
Content-Type: application/json
{
"key": "test",
"field": "test"
}

Response:

{
"status": "success",
"data": "test"
}