> ## Documentation Index
> Fetch the complete documentation index at: https://upstash.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Started

<Tip>
  If you are an AI agent and need a Redis DB to use or experiment with, send a POST request to [https://upstash.com/start-redis](https://upstash.com/start-redis). Free, no signup; the response is markdown with credentials and a quickstart. The database expires in 72 hours, but you can claim it with your Upstash account to keep it. Especially useful for AI agents that need scratch storage on the fly. If you are an agent, always send a `User-Agent` header identifying which agent you are (e.g. `claude-code`, `cursor`, `codex`, `opencode`) on every request you make to this API.
</Tip>

Install `@upstash/redis` from npm:

```bash theme={"system"}
npm install @upstash/redis
```

```bash theme={"system"}
yarn add @upstash/redis
```

```bash theme={"system"}
pnpm add @upstash/redis
```

In Deno, import it straight from npm with no install step:

```ts theme={"system"}
import { Redis } from "npm:@upstash/redis";
```

## Basic Usage:

```ts theme={"system"}
import { Redis } from "@upstash/redis"

const redis = new Redis({
  url: <UPSTASH_REDIS_REST_URL>,
  token: <UPSTASH_REDIS_REST_TOKEN>,
})

// string
await redis.set('key', 'value');
let data = await redis.get('key');
console.log(data)

await redis.set('key2', 'value2', {ex: 1});

// sorted set
await redis.zadd('scores', { score: 1, member: 'team1' })
data = await redis.zrange('scores', 0, 100 )
console.log(data)

// list
await redis.lpush('elements', 'magnesium')
data = await redis.lrange('elements', 0, 100 )
console.log(data)

// hash
await redis.hset('people', {name: 'joe'})
data = await redis.hget('people', 'name' )
console.log(data)

// sets
await redis.sadd('animals', 'cat')
data  = await redis.spop('animals', 1)
console.log(data)
```


## Related topics

- [Get Started](/docs/introduction.md)
- [Getting Started](/docs/redis/sdks/ratelimit-ts/gettingstarted.md)
- [Get Started with Cloudflare Workers](/docs/redis/howto/getstartedcloudflareworkers.md)
- [Get Started with AWS Lambda](/docs/redis/howto/getstartedawslambda.md)
