RedisGate provides a comprehensive Redis HTTP API that allows you to interact with Redis instances through HTTP requests. All Redis operations are secured with API key authentication and scoped to your organization.
All Redis API requests require authentication using an API key. You can provide the API key in two ways:
-
Authorization Header (Recommended):
Authorization: Bearer your-api-key-here
-
Query Parameter:
?_token=your-api-key-here
All Redis API endpoints follow this pattern:
/redis/{instance_id}/{command}/...
Where instance_id is the UUID of your Redis instance.
Retrieve the value of a key.
GET /redis/{instance_id}/get/{key}Example:
curl "http://localhost:8080/redis/123e4567-e89b-12d3-a456-426614174000/get/mykey" \
-H "Authorization: Bearer your-api-key"Set a key to a value.
GET /redis/{instance_id}/set/{key}/{value}Example:
curl "http://localhost:8080/redis/123e4567-e89b-12d3-a456-426614174000/set/mykey/myvalue" \
-H "Authorization: Bearer your-api-key"Delete a key.
GET /redis/{instance_id}/del/{key}Example:
curl "http://localhost:8080/redis/123e4567-e89b-12d3-a456-426614174000/del/mykey" \
-H "Authorization: Bearer your-api-key"Increment a key's value by 1.
GET /redis/{instance_id}/incr/{key}Example:
curl "http://localhost:8080/redis/123e4567-e89b-12d3-a456-426614174000/incr/counter" \
-H "Authorization: Bearer your-api-key"Set a field in a hash.
GET /redis/{instance_id}/hset/{key}/{field}/{value}Example:
curl "http://localhost:8080/redis/123e4567-e89b-12d3-a456-426614174000/hset/user:1/name/john" \
-H "Authorization: Bearer your-api-key"Get a field from a hash.
GET /redis/{instance_id}/hget/{key}/{field}Example:
curl "http://localhost:8080/redis/123e4567-e89b-12d3-a456-426614174000/hget/user:1/name" \
-H "Authorization: Bearer your-api-key"Push a value to the left (head) of a list.
GET /redis/{instance_id}/lpush/{key}/{value}Example:
curl "http://localhost:8080/redis/123e4567-e89b-12d3-a456-426614174000/lpush/mylist/item1" \
-H "Authorization: Bearer your-api-key"Pop a value from the left (head) of a list.
GET /redis/{instance_id}/lpop/{key}Example:
curl "http://localhost:8080/redis/123e4567-e89b-12d3-a456-426614174000/lpop/mylist" \
-H "Authorization: Bearer your-api-key"Test connectivity to the Redis instance.
GET /redis/{instance_id}/pingExample:
curl "http://localhost:8080/redis/123e4567-e89b-12d3-a456-426614174000/ping" \
-H "Authorization: Bearer your-api-key"For advanced use cases, you can send any Redis command using the generic POST endpoint:
POST /redis/{instance_id}
Content-Type: application/jsonRequest Body Format:
["COMMAND", "arg1", "arg2", "..."]SET with expiration:
curl -X POST "http://localhost:8080/redis/123e4567-e89b-12d3-a456-426614174000" \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '["SETEX", "session:123", "3600", "user_data"]'Get multiple keys:
curl -X POST "http://localhost:8080/redis/123e4567-e89b-12d3-a456-426614174000" \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '["MGET", "key1", "key2", "key3"]'Hash operations:
curl -X POST "http://localhost:8080/redis/123e4567-e89b-12d3-a456-426614174000" \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '["HGETALL", "user:1"]'List operations:
curl -X POST "http://localhost:8080/redis/123e4567-e89b-12d3-a456-426614174000" \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '["LRANGE", "mylist", "0", "-1"]'Set operations:
curl -X POST "http://localhost:8080/redis/123e4567-e89b-12d3-a456-426614174000" \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '["SADD", "myset", "member1", "member2"]'The generic endpoint supports a comprehensive set of Redis commands:
GET,SET,DEL,EXISTS,INCR,DECR,APPEND,STRLENEXPIRE,TTL(key expiration)
HSET,HGET,HDEL,HEXISTS,HGETALL,HKEYS,HVALS
LPUSH,RPUSH,LPOP,RPOP,LLEN,LRANGE
SADD,SREM,SISMEMBER,SMEMBERS,SCARD
PING
Any Redis command not explicitly listed above can still be executed through the generic endpoint. The system will attempt to execute it using Redis's native command interface.
All API responses follow this JSON structure:
{
"result": <redis_response>
}Where <redis_response> is the actual Redis response converted to appropriate JSON types:
- Strings remain as strings
- Integers become JSON numbers
- Lists become JSON arrays
- Hashes become JSON objects
- Null values become JSON null
Errors are returned with appropriate HTTP status codes and JSON error messages:
{
"error": "Error description here"
}Common error status codes:
400 Bad Request- Invalid command or parameters401 Unauthorized- Missing or invalid API key404 Not Found- Redis instance not found500 Internal Server Error- Redis connection or execution error
API requests are subject to rate limiting based on your organization's plan. Exceeded rate limits will return 429 Too Many Requests.
This API is compatible with the Upstash Redis client. Here's how to configure it:
import { Redis } from '@upstash/redis'
const redis = new Redis({
url: 'http://localhost:8080/redis/your-instance-id',
token: 'your-api-key'
})
// Use standard Redis operations
await redis.set('key', 'value')
const value = await redis.get('key')
await redis.hset('hash', { field: 'value' })
const hash = await redis.hgetall('hash')- Always use HTTPS in production to protect your API keys in transit
- Rotate API keys regularly using the management API
- Use the minimum required scopes when creating API keys
- Monitor API usage through the management dashboard
- Store API keys securely and never commit them to version control
For development environments, you can use the debug mode which provides additional logging and request information. The API includes comprehensive logging for debugging authentication and Redis operation issues.
To enable debug logging, set the RUST_LOG environment variable:
RUST_LOG=debug ./redisgateThis will show detailed information about API key validation, Redis connections, and command execution.