Integrations / Upstash Redis
Upstash Redis
Redis over HTTP through the Upstash REST API: read and write keys, scan by pattern, work with hashes and counters, set expiries, or run any Redis command on your own Upstash database. You give the database's REST address and its REST token.
10 actions
API key
5 read3 write2 destructive
Calls upstash.io
Connect
const conn = await setu.connections.initiate({ userId: "user_1", toolkit: "upstash" });
console.log(conn.connectUrl); // show this to your user
await conn.waitUntilActive();Permissions requested
This toolkit uses a single credential and requests no scopes.
Actions
Count keysreadupstash.dbsizeCount the keys in the database (Redis DBSIZE).
No input.
await setu.execute({
userId: "user_1",
action: "upstash.dbsize",
input: {},
});Delete keydestructiveupstash.delete_keyDelete a key and its value (Redis DEL). Returns 1 when the key existed and 0 when it did not.
| Input | Type | Description | |
|---|---|---|---|
key | string | Required | The Redis key |
await setu.execute({
userId: "user_1",
action: "upstash.delete_key",
input: {
"key": "<key>"
},
confirm: true,
});Get keyreadupstash.getRead the string value of a key (Redis GET). The value is null when the key does not exist.
| Input | Type | Description | |
|---|---|---|---|
key | string | Required | The Redis key |
await setu.execute({
userId: "user_1",
action: "upstash.get",
input: {
"key": "<key>"
},
});Get hashreadupstash.hgetallRead every field and value of a hash key (Redis HGETALL). The result is a flat list: field, value, field, value, and so on.
| Input | Type | Description | |
|---|---|---|---|
key | string | Required | The Redis key |
await setu.execute({
userId: "user_1",
action: "upstash.hgetall",
input: {
"key": "<key>"
},
});Increment counterwriteupstash.incrAdd 1 to the integer stored at a key, creating it at 1 if missing (Redis INCR). Returns the new value.
| Input | Type | Description | |
|---|---|---|---|
key | string | Required | The Redis key |
await setu.execute({
userId: "user_1",
action: "upstash.incr",
input: {
"key": "<key>"
},
});Run any Redis commanddestructiveupstash.run_commandRun any Redis command given as a list, command name first, for example ["LRANGE", "queue", 0, 9] or ["HSET", "user:1", "plan", "pro"]. This can read, change or delete data, including FLUSHALL, so it is treated as destructive and needs confirmation: prefer the specific actions. Blocking commands (BLPOP...), WATCH and most connection commands are not supported over HTTP.
| Input | Type | Description | |
|---|---|---|---|
command | array of string,number | Required | The command and its arguments, each a string or number; the command name is the first item |
await setu.execute({
userId: "user_1",
action: "upstash.run_command",
input: {
"command": []
},
confirm: true,
});Scan keysreadupstash.scanList keys matching a glob pattern, one page at a time (Redis SCAN, safe on large databases, unlike KEYS). Start with cursor 0; call again with the returned cursor until it is 0. A page may be empty or hold more keys than usual.
| Input | Type | Description | |
|---|---|---|---|
cursor | string | Required | Cursor: "0" to start, then the cursor returned by the previous call |
match | string | Required | Glob pattern, e.g. user:* (use * for every key) |
await setu.execute({
userId: "user_1",
action: "upstash.scan",
input: {
"cursor": "<cursor>",
"match": "<match>"
},
});Set keywriteupstash.setSet a key to a string value with no expiry (Redis SET). Overwrites any existing value.
| Input | Type | Description | |
|---|---|---|---|
key | string | Required | The Redis key |
value | string | Required | The string value to store |
await setu.execute({
userId: "user_1",
action: "upstash.set",
input: {
"key": "<key>",
"value": "<value>"
},
});Set key with expirywriteupstash.set_with_expirySet a key to a string value that expires after a number of seconds (Redis SETEX). Overwrites any existing value.
| Input | Type | Description | |
|---|---|---|---|
key | string | Required | The Redis key |
seconds | integer | Required | Seconds until the key expires |
value | string | Required | The string value to store |
await setu.execute({
userId: "user_1",
action: "upstash.set_with_expiry",
input: {
"key": "<key>",
"seconds": 1,
"value": "<value>"
},
});Get key time to livereadupstash.ttlGet the seconds left before a key expires (Redis TTL): -1 when the key never expires, -2 when it does not exist.
| Input | Type | Description | |
|---|---|---|---|
key | string | Required | The Redis key |
await setu.execute({
userId: "user_1",
action: "upstash.ttl",
input: {
"key": "<key>"
},
});