SmallPlate

Sets API

Unique member collections for tags, memberships, and feature flags

Sets store unique members with no guaranteed order. They are useful for tags, memberships, feature flags, and unique identity collections.

Endpoints

MethodEndpointDescription
POST/{plateId}/sets/addAdd members
POST/{plateId}/sets/removeRemove members
GET/{plateId}/sets/members/{key}Read all members
POST/{plateId}/sets/containsCheck one or many members
GET/{plateId}/sets/count/{key}Count members
GET/{plateId}/sets/random/{key}Read random members
POST/{plateId}/sets/popPop random members
POST/{plateId}/sets/unionUnion or union-store
POST/{plateId}/sets/intersectIntersection or store
POST/{plateId}/sets/diffDifference or store
POST/{plateId}/sets/commandExecute allowed set commands
POST/{plateId}/sets/{key}/commandExecute key-specific set commands

Examples

Add members

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

const response = await fetch(`${baseUrl}/$[id]/sets/add`, {
  method: "POST",
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    key: "tags",
    members: ["red", "blue", "green"]
  })
});

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

Check one member

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

const response = await fetch(`${baseUrl}/$[id]/sets/contains`, {
  method: "POST",
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    key: "tags",
    member: "red"
  })
});

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

Check many members

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

const response = await fetch(`${baseUrl}/$[id]/sets/contains`, {
  method: "POST",
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    key: "tags",
    members: ["red", "black"]
  })
});

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

Union without storing

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

const response = await fetch(`${baseUrl}/$[id]/sets/union`, {
  method: "POST",
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    keys: ["team:a", "team:b"]
  })
});

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

Union and store the result

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

const response = await fetch(`${baseUrl}/$[id]/sets/union`, {
  method: "POST",
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    keys: ["team:a", "team:b"],
    destination: "team:all"
  })
});

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

Command Compatibility

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

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

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

Command Endpoints

POST /[id]/sets/command

Execute allowed set commands across the plate.

Allowed Commands:

CommandDescription
SADDAdd members
SREMRemove members
SMEMBERSGet all members
SISMEMBERCheck one member
SMISMEMBERCheck multiple members
SCARDGet member count
SRANDMEMBERGet random members
SPOPPop random members
SUNIONUnion of sets
SINTERIntersection of sets
SDIFFDifference of sets
SUNIONSTOREUnion and store
SINTERSTOREIntersection and store
SDIFFSTOREDifference and store

Query Parameters for SRANDMEMBER:

  • count (optional): Number of members to return (negative for distinct)

POST /[id]/sets/[key]/command

Execute allowed commands on a specific set 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]/sets/myset/command`, {
  method: "POST",
  headers: {
    "Authorization": apiKey,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    command: "SCARD"
  })
});

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

On this page