swarm-keydb

HTTP REST API Gateway

SwarmKeyDb exposes Redis-compatible commands over HTTP JSON so any developer can use curl or fetch() without a Redis client.

Configuration

Quick curl examples

curl -sS -X POST http://localhost:8080/set/hello \
  -H 'Content-Type: application/json' \
  -d '{"value":"world"}'
# {"result":"OK"}

curl -sS http://localhost:8080/get/hello
# {"result":"world"}

curl -sS -X DELETE http://localhost:8080/del/hello
# {"result":1}

Additional endpoints:

All responses use:

RESP3 content negotiation

Set Accept: application/json; resp=3 to request RESP3-typed JSON shapes.

Request Accept: application/json (default / RESP2 shape) Accept: application/json; resp=3
GET /exists/{key} {"result":0} / {"result":1} {"result":false} / {"result":true}
POST /cmd with {"cmd":"CONFIG","args":["GET","*"]} {"result":["key","value",...]} {"result":{"key":"value",...}}
POST /cmd with {"cmd":"ZSCORE",...} {"result":"1.5"} {"result":1.5}

When the header is omitted, existing RESP2-compatible JSON remains unchanged.

OpenAPI and interactive docs

Browser fetch() example

const baseUrl = "http://localhost:8080";

await fetch(`${baseUrl}/set/demo`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ value: "from-fetch" })
});

const getResponse = await fetch(`${baseUrl}/get/demo`);
const payload = await getResponse.json();
console.log(payload.result);