How to hit the Upstash Redis API

Every Upstash Redis database has a REST URL. Redis commands map to paths: /set/key/value, /get/key, or POST a command array.

Authentication

Copy the REST URL and token from your database's page in the Upstash console. Send the token as Authorization: Bearer <token>. In the examples they're written {{UPSTASH_REDIS_HOST}} and {{UPSTASH_REDIS_TOKEN}}.

Full reference: https://upstash.com/docs/redis/features/restapi

SET a key

curl https://{{UPSTASH_REDIS_HOST}}/set/greeting/hello \
  -H "Authorization: Bearer {{UPSTASH_REDIS_TOKEN}}"
Run in PostTaco

GET a key

curl https://{{UPSTASH_REDIS_HOST}}/get/greeting \
  -H "Authorization: Bearer {{UPSTASH_REDIS_TOKEN}}"
Run in PostTaco

Any command as JSON

curl -X POST https://{{UPSTASH_REDIS_HOST}} \
  -H "Authorization: Bearer {{UPSTASH_REDIS_TOKEN}}" \
  -d '["INCR", "visits"]'
Run in PostTaco