SmallPlate

Strings API

Store and manipulate single string values with expiration, increment, and range operations

The Strings API stores single values per key. It is the simplest way to keep text, counters, tokens, feature flags, and cached serialized data.

Endpoints

MethodEndpointDescription
GET/{plateId}/strings/get/{key}Get one value
POST/{plateId}/strings/getGet many values
POST/{plateId}/strings/setSet one value
POST/{plateId}/strings/set-manySet many values
POST/{plateId}/strings/incrementIncrement integer or float
POST/{plateId}/strings/decrementDecrement integer
POST/{plateId}/strings/appendAppend to a string
GET/{plateId}/strings/length/{key}Get string length
GET/{plateId}/strings/range/{key}Read a substring
POST/{plateId}/strings/range/setReplace part of a string
POST/{plateId}/strings/get-and-expireGETEX wrapper
DELETE/{plateId}/strings/get-and-delete/{key}GETDEL wrapper
POST/{plateId}/strings/commandExecute allowed string commands
POST/{plateId}/strings/{key}/commandExecute key-specific string commands

Common Patterns

Store a Value

const plateId = "[id]";
const apiKey = "your-api-key";
const baseUrl = "[base-url]";

const response = await fetch(`${baseUrl}/${plateId}/strings/set`, {
  method: "POST",
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    key: "mykey",
    value: "hello world"
  })
});

const data = await response.json();
console.log(data);

Store with Expiration

const plateId = "[id]";
const apiKey = "your-api-key";
const baseUrl = "[base-url]";

const response = await fetch(`${baseUrl}/${plateId}/strings/set`, {
  method: "POST",
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    key: "session:123",
    value: "abc123",
    ttl_ms: 3600000
  })
});

const data = await response.json();
console.log(data);

Conditional Set

const plateId = "[id]";
const apiKey = "your-api-key";
const baseUrl = "[base-url]";

const response = await fetch(`${baseUrl}/${plateId}/strings/set`, {
  method: "POST",
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    key: "lock:job:42",
    value: "worker-1",
    nx: true,
    ttl_ms: 30000
  })
});

const data = await response.json();
console.log(data);

Get a Value

const plateId = "[id]";
const apiKey = "your-api-key";
const baseUrl = "[base-url]";

const response = await fetch(`${baseUrl}/${plateId}/strings/get/mykey`, {
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  }
});

const data = await response.json();
console.log(data);

Get Multiple Values

const plateId = "[id]";
const apiKey = "your-api-key";
const baseUrl = "[base-url]";

const response = await fetch(`${baseUrl}/${plateId}/strings/get`, {
  method: "POST",
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    keys: ["key1", "key2", "key3"]
  })
});

const data = await response.json();
console.log(data);

Set Multiple Values

const plateId = "[id]";
const apiKey = "your-api-key";
const baseUrl = "[base-url]";

const response = await fetch(`${baseUrl}/${plateId}/strings/set-many`, {
  method: "POST",
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    values: {
      key1: "value1",
      key2: "value2"
    }
  })
});

const data = await response.json();
console.log(data);

Increment Counters

const plateId = "[id]";
const apiKey = "your-api-key";
const baseUrl = "[base-url]";

const response = await fetch(`${baseUrl}/${plateId}/strings/increment`, {
  method: "POST",
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    key: "counter",
    amount: 10
  })
});

const data = await response.json();
console.log(data);

Float increments are supported too:

const plateId = "[id]";
const apiKey = "your-api-key";
const baseUrl = "[base-url]";

const response = await fetch(`${baseUrl}/${plateId}/strings/increment`, {
  method: "POST",
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    key: "price",
    amount: 1.5
  })
});

const data = await response.json();
console.log(data);

Decrement

const plateId = "[id]";
const apiKey = "your-api-key";
const baseUrl = "[base-url]";

const response = await fetch(`${baseUrl}/${plateId}/strings/decrement`, {
  method: "POST",
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    key: "counter",
    amount: 5
  })
});

const data = await response.json();
console.log(data);

Append

const plateId = "[id]";
const apiKey = "your-api-key";
const baseUrl = "[base-url]";

const response = await fetch(`${baseUrl}/${plateId}/strings/append`, {
  method: "POST",
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    key: "greeting",
    value: " world"
  })
});

const data = await response.json();
console.log(data);

Range Operations

Read a substring:

const plateId = "[id]";
const apiKey = "your-api-key";
const baseUrl = "[base-url]";

const response = await fetch(`${baseUrl}/${plateId}/strings/range/greeting?start=0&end=4`, {
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  }
});

const data = await response.json();
console.log(data);

Query parameters:

  • start (optional): Start index (default: 0)
  • end (optional): End index (default: -1, meaning to the end)

Replace part of a string:

const plateId = "[id]";
const apiKey = "your-api-key";
const baseUrl = "[base-url]";

const response = await fetch(`${baseUrl}/$[id]/strings/range/set`, {
  method: "POST",
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    key: "greeting",
    offset: 6,
    value: "world"
  })
});

const data = await response.json();
console.log(data);

Get and Expire

const plateId = "[id]";
const apiKey = "your-api-key";
const baseUrl = "[base-url]";

const response = await fetch(`${baseUrl}/$[id]/strings/get-and-expire`, {
  method: "POST",
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    key: "session:123",
    ttl_ms: 60000
  })
});

const data = await response.json();
console.log(data);

Set ttl_ms to 0 to persist the key while returning the value.

Get and Delete

const plateId = "[id]";
const apiKey = "your-api-key";
const baseUrl = "[base-url]";

const response = await fetch(`${baseUrl}/$[id]/strings/get-and-delete/session:123`, {
  method: "DELETE",
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  }
});

const data = await response.json();
console.log(data);

Command Compatibility

If you need direct command access, use:

const plateId = "[id]";
const apiKey = "your-api-key";
const baseUrl = "[base-url]";

const response = await fetch(`${baseUrl}/$[id]/strings/command`, {
  method: "POST",
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    command: "SET",
    args: ["mykey", "hello world", "EX", "3600"]
  })
});

const data = await response.json();
console.log(data);

Command Endpoints

POST /[id]/strings/command

Execute allowed string commands across the plate.

Allowed Commands:

CommandDescription
GETGet value
SETSet value
MGETGet multiple values
MSETSet multiple values
GETEXGet and optionally set expiry
GETDELGet and delete
INCRIncrement by 1
DECRDecrement by 1
INCRBYIncrement by integer
DECRBYDecrement by integer
INCRBYFLOATIncrement by float
APPENDAppend to string
STRLENGet string length
SETRANGEReplace substring
GETRANGEGet substring

Request:

const plateId = "[id]";
const apiKey = "your-api-key";
const baseUrl = "[base-url]";

const response = await fetch(`${baseUrl}/$[id]/strings/command`, {
  method: "POST",
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    command: "INCR",
    args: ["counter"]
  })
});

const data = await response.json();
console.log(data);

POST /[id]/strings/[key]/command

Execute allowed commands on a specific string key.

Allowed Commands: Same as above.

Request:

const plateId = "[id]";
const apiKey = "your-api-key";
const baseUrl = "[base-url]";

const response = await fetch(`${baseUrl}/$[id]/strings/mykey/command`, {
  method: "POST",
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    command: "STRLEN"
  })
});

const data = await response.json();
console.log(data);

On this page