### Setup .env file Source: https://upstash.com/examples/rate-limitingafeedbackform Environment variables required for the example: UPSTASH_REDIS_REST_URL, UPSTASH_REDIS_REST_TOKEN, and RESEND_API_KEY. Fill in the values before starting the app. ```plaintext UPSTASH_REDIS_REST_URL= UPSTASH_REDIS_REST_TOKEN= RESEND_API_KEY= ``` -------------------------------- ### Install dependencies and start dev server Source: https://upstash.com/blog/sveltekit-rate-limiting Commands to install dependencies, initialize git, and start the SvelteKit dev server. ```bash cd sveltekit-rate-limit npm install git init && git add -A && git commit -m "Initial commit" npm run dev -- --open ``` -------------------------------- ### Install Hermes Source: https://upstash.com/blog/personal-assistant-in-messaging-apps-hermes-upstash-box Install Hermes on the box using the official install script. At the end, a setup wizard starts. ```bash curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash ``` -------------------------------- ### CONFIG GET example with go-redis Source: https://upstash.com/docs/redis/commands/server/config-get Example of using CONFIG GET with the go-redis client in Go. ```go package main import ( "context" "fmt" "os" "github.com/redis/go-redis/v9" ) func main() { opts, err := redis.ParseURL(os.Getenv("REDIS_URL")) if err != nil { panic(err) } client := redis.NewClient(opts) result, err := client.ConfigGet(context.Background(), "notify-keyspace-events").Result() if err != nil { panic(err) } fmt.Println(result) } ``` -------------------------------- ### CONFIG GET example with jedis Source: https://upstash.com/docs/redis/commands/server/config-get Example of using CONFIG GET with the jedis client in Java. ```java import java.net.URI; import redis.clients.jedis.Jedis; try (Jedis jedis = new Jedis(new URI(System.getenv("REDIS_URL")))) { Object result = jedis.configGet("notify-keyspace-events"); System.out.println(result); } ``` -------------------------------- ### Install dependencies and run development server Source: https://upstash.com/blog/build-article-research-agent Commands to install npm dependencies and start the development server for both forked repositories. ```bash npm install npm run dev ``` -------------------------------- ### CONFIG GET example with ioredis Source: https://upstash.com/docs/redis/commands/server/config-get Example of using CONFIG GET with the ioredis client in Node.js. ```javascript import Redis from "ioredis"; const redis = new Redis(process.env.REDIS_URL!); const result = await redis.config("GET", "notify-keyspace-events"); console.log(result); ``` -------------------------------- ### Interactive setup answers and install dependencies Source: https://upstash.com/blog/openai-hackernews-summarizer These are the answers to the create-next-app prompts, followed by the command to install required packages: node-html-parser, ky, @upstash/redis, @upstash/ratelimit, @upstash/qstash, and openai. The cd command changes into the project directory before installing. ```bash ✔ What is your project named? … hackernews-summarizer ✔ Would you like to use TypeScript? … No / Yes ✔ Would you like to use ESLint? … No / Yes ✔ Would you like to use Tailwind CSS? … No / Yes ✔ Would you like to use `src/` directory? … No / Yes ✔ Would you like to use App Router? (recommended) … No / Yes ✔ Would you like to customize the default import alias (@/*)? … No / Yes ✔ What import alias would you like configured? … @/* cd hackernews-summarizer && npm i node-html-parser ky @upstash/redis @upstash/ratelimit @upstash/qstash openai ``` -------------------------------- ### Start development server with yarn Source: https://upstash.com/examples/nextjstodoappwithredis Run this command to start the Next.js development server after installing dependencies with yarn. ```bash yarn run dev ``` -------------------------------- ### Set up the starter project with degit Source: https://upstash.com/blog/sveltekit-edge-redis Commands to download the initial state of the SvelteKit Edge Guestbook repo using degit, install dependencies, and start the dev server. ```bash npx degit geoffrich/sveltekit-edge-guestbook#initial sveltekit-edge-guestbook cd sveltekit-edge-guestbook npm i npm run dev ``` -------------------------------- ### Complete Setup Source: https://upstash.com/docs/redis/sdks/py/commands/connection/client_setinfo Sets both library name and version, and notes that this information will appear in CLIENT LIST output. ```python # Set both library name and version redis.client_setinfo("LIB-NAME", "my-redis-wrapper") redis.client_setinfo("LIB-VER", "3.2.1") # Now this information will appear in CLIENT LIST output ``` -------------------------------- ### History options: limit and start Source: https://upstash.com/docs/realtime/features/server-side Fetches messages with a limit of 100 and only those after a Unix timestamp (start). The example uses start: Date.now() - 86400000 to get messages from the last 24 hours. ```typescript const messages = await realtime.channel("room-123").history({ limit: 100, start: Date.now() - 86400000, }) ``` -------------------------------- ### QStash CLI output example Source: https://upstash.com/docs/workflow/howto/local-development/development-server Example output from the QStash CLI when starting the dev server. It shows the QSTASH_TOKEN, signing keys, and a sample cURL request. ```plaintext Upstash QStash development server is runnning at A default user has been created for you to authorize your requests. QSTASH_TOKEN=eyJVc2VySUQiOiJkZWZhdWx0VXNlciIsIlBhc3N3b3JkIjoiZGVmYXVsdFBhc3N3b3JkIn0= QSTASH_CURRENT_SIGNING_KEY=sig_7RvLjqfZBvP5KEUimQCE1pvpLuou QSTASH_NEXT_SIGNING_KEY=sig_7W3ZNbfKWk5NWwEs3U4ixuQ7fxwE Sample cURL request: curl -X POST http://127.0.0.1:8080/v2/publish/https://example.com -H "Authorization: Bearer eyJVc2VySUQiOiJkZWZhdWx0VXNlciIsIlBhc3N3b3JkIjoiZGVmYXVsdFBhc3N3b3JkIn0=" Check out documentation for more details: https://upstash.com/docs/qstash/howto/local-development ``` -------------------------------- ### Build and start the application Source: https://upstash.com/blog/article-recommendation-system Command to build and start the application, then visit localhost:3000. ```bash pnpm run build && pnpm run start ``` -------------------------------- ### CONFIG GET example with redis-rs Source: https://upstash.com/docs/redis/commands/server/config-get Example of using CONFIG GET with the redis-rs client in Rust. ```rust fn main() -> redis::RedisResult<()> { let url = std::env::var("REDIS_URL").expect("REDIS_URL is not set"); let client = redis::Client::open(url)?; let mut connection = client.get_connection()?; let mut command = redis::cmd("CONFIG"); command.arg("GET"); command.arg("notify-keyspace-events"); let result: redis::Value = command.query(&mut connection)?; println!("{result:?}"); Ok(()) } ``` -------------------------------- ### Initialize Fastly Compute project with JavaScript empty starter Source: https://upstash.com/docs/redis/quickstarts/fastlycompute Run `fastly compute init` and select JavaScript and the empty starter kit. The output shows the interactive prompts and selections. ```text > fastly compute initCreating a new Compute project.Press ^C at any time to quit.Name: [fastly-upstash]Description:Author: [enes@upstash.com]Language:[1] Rust[2] JavaScript[3] Go[4] Other ('bring your own' Wasm binary)Choose option: [1] 2Starter kit:[1] Default starter for JavaScript A basic starter kit that demonstrates routing, simple synthetic responses and overriding caching rules. https://github.com/fastly/compute-starter-kit-javascript-default[2] Empty starter for JavaScript An empty application template for the Fastly Compute environment which simply returns a 200 OK response. https://github.com/fastly/compute-starter-kit-javascript-emptyChoose option or paste git URL: [1] 2 ``` -------------------------------- ### Create Strapi app with quickstart Source: https://upstash.com/blog/strapi-semantic-search Run this command to create a new Strapi application named 'bookstore' with the quickstart option. It requires Node.js (Active LTS or Maintenance LTS) and a package manager like npm or yarn. The command opens a browser page for installation and form completion. ```bash npx create-strapi-app@latest bookstore --quickstart ``` -------------------------------- ### CONFIG GET example with redis-py Source: https://upstash.com/docs/redis/commands/server/config-get Example of using CONFIG GET with the redis-py client in Python. ```python import os import redis client = redis.from_url(os.environ["REDIS_URL"]) result = client.config_get("notify-keyspace-events") print(result) ``` -------------------------------- ### Set up Node project and install Ollama client Source: https://upstash.com/blog/ollama-deepseek Initializes a new Node project, installs the ollama library, and creates an index.js file for the application. ```bash npm init -y npm install ollama touch index.js ``` -------------------------------- ### CONFIG GET example with node-redis Source: https://upstash.com/docs/redis/commands/server/config-get Example of using CONFIG GET with the node-redis client in Node.js. ```javascript import { createClient } from "redis"; const client = await createClient({ url: process.env.REDIS_URL }) .on("error", console.error) .connect(); const result = await client.configGet("notify-keyspace-events"); console.log(result); ``` -------------------------------- ### Run setup.py Source: https://upstash.com/docs/box/guides/browser-use Command to execute the setup script that creates the box and schedules the agent. ```bash python setup.py ``` -------------------------------- ### Initialize project and install dependencies Source: https://upstash.com/blog/chat-langchain Commands to create a project directory, initialize a package.json, install TypeScript, ts-node, Upstash Redis, LangChain, and dotenv, and set up git. ```bash mkdir langchain_upstash_redis # Create a project directory cd langchain_upstash_redis # Navigate into the project directory yarn init -y # Initializes a new project with a package.json file yarn add typescript ts-node --dev # Installs TypeScript and TS-Node for running TypeScript files npx tsc --init # Initializes a TypeScript project yarn add @upstash/redis langchain dotenv # Installs Upstash Redis, LangChain and dotenv for our environment variables git init # Initializes a git repository touch .gitignore # Creates a .gitignore file ``` -------------------------------- ### Install with go get Source: https://upstash.com/docs/devops/pulumi/overview Install the Go SDK for the Upstash Pulumi provider using go get. ```bash go get github.com/upstash/pulumi-upstash/sdk/go/... ``` -------------------------------- ### SETRANGE example with Upstash Redis Python SDK Source: https://upstash.com/docs/redis/sdks/py/commands/string/setrange Shows how to use setrange to replace a substring starting at offset 6, then verifies the result with get. The command returns the new length of the string (11). ```python redis.set("key", "Hello World") assert redis.setrange("key", 6, "Redis") == 11 assert redis.get("key") == "Hello Redis" ``` -------------------------------- ### Complete Setup Source: https://upstash.com/docs/redis/sdks/ts/commands/connection/client_setinfo Sets both library name and version, and notes that this information will appear in CLIENT LIST output. ```typescript // Set both library name and version await redis.clientSetInfo("LIB-NAME", "my-redis-wrapper"); await redis.clientSetInfo("LIB-VER", "3.2.1"); // Now this information will appear in CLIENT LIST output ``` -------------------------------- ### Start development server with npm run dev Source: https://upstash.com/examples/guestbookwithsveltekitedge Run the development server after installing dependencies. The --open flag starts the server and opens the app in a new browser tab. ```bash npm run dev # or start the server and open the app in a new browser tab npm run dev -- --open ``` -------------------------------- ### Create public URLs for multiple services (Python) Source: https://upstash.com/docs/box/overall/preview Python equivalent of the multi-port example: creates a Box, writes server files, installs Express, starts both servers, and creates public URLs using get_public_url. ```python from upstash_box import Box box = Box.create(runtime="node") # Start frontend on port 3000 box.files.write( path="/work/frontend.js", content="""const express = require('express') const app = express() app.get('/', (req, res) => res.send('Frontend')) app.listen(3000) """, ) # Start API on port 8080 box.files.write( path="/work/api.js", content="""const express = require('express') const app = express() app.get('/api/status', (req, res) => res.json({ status: 'ok' })) app.listen(8080) """, ) box.exec.command("npm install express") box.exec.command("node /work/frontend.js & node /work/api.js &") # Create a public URL for each service frontend_public_url = box.get_public_url(3000) api_public_url = box.get_public_url(8080) print(f"Frontend: {frontend_public_url.url}") print(f"API: {api_public_url.url}") ``` -------------------------------- ### Create a new project and initialize Go module Source: https://upstash.com/docs/qstash/quickstarts/fly-io/go Commands to create a new folder 'flyio-go', navigate into it, and initialize a Go module. This is the first step in setting up the project. ```bash mkdir flyio-gocd flyio-gogo mod init flyio-go ``` -------------------------------- ### Start the development server Source: https://upstash.com/blog/authenticate-users-nextjs-authjs Move into the project directory and start the app in development mode. The app should run on localhost:3000. ```bash cd my-app npm run dev ``` -------------------------------- ### Run the blog locally Source: https://upstash.com/blog/react-server-components Navigate into the blog directory and start the development server. ```bash cd blog pnpm dev ``` -------------------------------- ### CONFIG GET example with Redis CLI Source: https://upstash.com/docs/redis/commands/server/config-get Example of using CONFIG GET with the Redis CLI to fetch the notify-keyspace-events parameter. ```redis CONFIG GET notify-keyspace-events ``` -------------------------------- ### Create Cloudflare Worker with npm create cloudflare@latest Source: https://upstash.com/blog/rag-chatbot-for-instagram-with-upstash-workflow-and-hono Command to initialize a new Cloudflare Worker project. This installs the Cloudflare packages and guides through setup. Note that a CF worker endpoint is not required for QStash; any endpoint can be used. ```bash # You don’t need CF worker endpoint to implement QStash feature. # You can build on any endpoint. # this will install the CF packages and lead you through setup. npm create cloudflare@latest ``` -------------------------------- ### Create directory and navigate Source: https://upstash.com/docs/redis/quickstarts/koyeb Creates a new directory for the demo application and navigates into it. ```bash mkdir example-koyeb-upstashcd example-koyeb-upstash ``` -------------------------------- ### JavaScript fetch example to get a URL Group Source: https://upstash.com/docs/qstash/api-reference/url-groups/get-a-url-group JavaScript example using fetch to GET a URL Group. Replace {urlGroupName} and with your values. ```javascript const response = await fetch('https://qstash-eu-central-1.upstash.io/v2/topics/{urlGroupName}', { method: 'GET', headers: { 'Authorization': 'Bearer ' } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Start DeepSeek harness Source: https://upstash.com/docs/agent-resources/clients Boots the DeepSeek harness with the 'web' profile. ```bash dsh web ``` -------------------------------- ### JavaScript Fetch Example for Get Index Source: https://upstash.com/docs/devops/developer-api/vector/get_index JavaScript example using fetch to call the Get Index endpoint. Replace {id} and as needed. ```javascript const response = await fetch('https://api.upstash.com/v2/vector/index/{id}', { method: 'GET', headers: { 'Authorization': 'Basic ' } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Python requests example to get a URL Group Source: https://upstash.com/docs/qstash/api-reference/url-groups/get-a-url-group Python example using the requests library to GET a URL Group. Replace {urlGroupName} and with your values. ```python import requests url = "https://qstash-eu-central-1.upstash.io/v2/topics/{urlGroupName}" headers = { "Authorization": "Bearer ", } response = requests.request("GET", url, headers=headers) print(response.text) ``` -------------------------------- ### Python Requests Example for Get Index Source: https://upstash.com/docs/devops/developer-api/vector/get_index Python example using the requests library to call the Get Index endpoint. Replace {id} and as needed. ```python import requests url = "https://api.upstash.com/v2/vector/index/{id}" headers = { "Authorization": "Basic ", } response = requests.request("GET", url, headers=headers) print(response.text) ``` -------------------------------- ### Initialize Bun project and install ioredis Source: https://upstash.com/blog/redis-message-queue Shell commands to create a project directory, initialize a Bun project, and add the ioredis dependency. ```bash mkdir upstash-mq cd upstash-mq bun init > package name (upstash-mq-tutorial): upstash-mq > entry point (index.ts): > Done! bun add ioredis ``` -------------------------------- ### Install dependencies and run unit tests with NPM Source: https://upstash.com/examples/usingawssamwithredis Navigate to the `hello-world` directory, install dependencies with `npm install`, and run unit tests with `npm run test`. Tests are defined in the `hello-world/tests` folder using the Mocha test framework. ```bash using-aws-sam$ cd hello-world hello-world$ npm install hello-world$ npm run test ``` -------------------------------- ### JavaScript fetch example to get database details Source: https://upstash.com/docs/devops/developer-api/redis/get_database JavaScript example using fetch to call the Get Database endpoint. Replace {id} and the Authorization header value with your credentials. ```javascript const response = await fetch('https://api.upstash.com/v2/redis/database/{id}', { method: 'GET', headers: { 'Authorization': 'Basic ' } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Create project directory and navigate Source: https://upstash.com/blog/langchain-caching Creates a new empty directory for the project and navigates into it, as required by create-hono. ```bash mkdir langchain-qstash cd langchain-qstash ``` -------------------------------- ### JavaScript fetch example to get failed workflow run Source: https://upstash.com/docs/workflow/api-reference/dlq/get-failed-workflow-run JavaScript example using fetch to call the GET endpoint for a failed workflow run. Replace {dlqId} and as needed. ```javascript const response = await fetch('https://qstash-eu-central-1.upstash.io/v2/workflows/dlq/{dlqId}', { method: 'GET', headers: { 'Authorization': 'Bearer ' } }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Start the development server Source: https://upstash.com/blog/nextjs-kafka-upstash-cqrs Install dependencies and start the Next.js development server. If running on GitHub Codespaces, make the server's port public so Apollo GraphQL UI can read the schema. ```bash $ npm i $ npm run dev ``` -------------------------------- ### Python requests example to get database details Source: https://upstash.com/docs/devops/developer-api/redis/get_database Python example using the requests library to call the Get Database endpoint. Replace {id} and the Authorization header value with your credentials. ```python import requests url = "https://api.upstash.com/v2/redis/database/{id}" headers = { "Authorization": "Basic ", } response = requests.request("GET", url, headers=headers) print(response.text) ``` -------------------------------- ### Symphony Box Setup Interactive Output Source: https://upstash.com/blog/symphony-on-upstash-box Example terminal output from the setup CLI, showing prompts and completion message. ```text ┌ Symphony Box Setup ◇ Upstash Box API key: **** ◇ OpenAI API key: **** ◇ Linear API key: **** ◇ GitHub token (requires read/write for contents and pull requests): **** ◇ Select a GitHub repo: upstash/my-repo ◇ Select a Linear project: Backend ◇ Keep the box alive for production? (recommended — box stays running even when idle; otherwise it freezes after inactivity) yes ⠹ Cloning and building Symphony (~5 mins)... ✓ Done Symphony is running! Box ID: sparkling-fox-12345 ``` -------------------------------- ### Answer a prompt from an installer (TypeScript) Source: https://upstash.com/docs/box/overall/live-sessions Starts an interactive npm create session with a TTY, collects output, waits for the prompt 'Select a framework', then sends a newline to accept the default. Includes a 30-second deadline. ```typescript let out = "" const session = await box.exec.session({ cmd: "npm create vite@latest my-app", tty: true, onStdout: (data) => (out += Buffer.from(data).toString()), }) const deadline = Date.now() + 30000 while (!out.includes("Select a framework") && Date.now() < deadline) { await new Promise((r) => setTimeout(r, 100)) } session.write("\n") // accept the default await session.wait() ``` -------------------------------- ### Python requests example to get failed workflow run Source: https://upstash.com/docs/workflow/api-reference/dlq/get-failed-workflow-run Python example using the requests library to call the GET endpoint for a failed workflow run. Replace {dlqId} and as needed. ```python import requests url = "https://qstash-eu-central-1.upstash.io/v2/workflows/dlq/{dlqId}" headers = { "Authorization": "Bearer ", } response = requests.request("GET", url, headers=headers) print(response.text) ``` -------------------------------- ### Clone the repository Source: https://upstash.com/examples/rate-limitingafeedbackform Clones the Upstash examples repository to get the feedback form rate-limiting example. ```shell git clone https://github.com/upstash/examples.git ``` -------------------------------- ### Create project directory and initialize npm Source: https://upstash.com/blog/api-key-generator-upstash-redis Commands to create a new directory, navigate into it, and initialize a Node.js project. ```bash mkdir keyflow cd keyflow npm init -y ``` -------------------------------- ### jedis: DISCARD Example Source: https://upstash.com/docs/redis/commands/transactions/discard Example using jedis to start a transaction, set a value, and discard it. ```java import java.net.URI;import redis.clients.jedis.Jedis;import redis.clients.jedis.Transaction;try (Jedis jedis = new Jedis(new URI(System.getenv("REDIS_URL"))); Transaction transaction = jedis.multi()) { transaction.set("balance", "100"); transaction.discard();} ``` -------------------------------- ### Create server folder and navigate into it Source: https://upstash.com/blog/next-chatapp-with-kafka Commands to create and enter the 'server' directory for the chat app. ```bash mkdir server cd server ``` -------------------------------- ### Run the application Source: https://upstash.com/blog/groq-llama3-vercel-ai Starts the Next.js development server. ```bash pnpm run dev ``` -------------------------------- ### ioredis: DISCARD Example Source: https://upstash.com/docs/redis/commands/transactions/discard Example using ioredis to start a transaction, set a value, and discard it. ```typescript import Redis from "ioredis";const client = new Redis(process.env.REDIS_URL!);await client.multi({ pipeline: false });await client.set("balance", "100");await client.discard(); ``` -------------------------------- ### Redis CLI ZRANGEBYLEX Example Source: https://upstash.com/docs/redis/commands/sorted-set/zrangebylex Example using the Redis CLI to get all members from 'my-key'. ```bash ZRANGEBYLEX my-key - + ``` -------------------------------- ### Create project and initialize lambda_function.py Source: https://upstash.com/docs/qstash/quickstarts/aws-lambda/python Commands to create a new folder 'aws-lambda', navigate into it, and create the 'lambda_function.py' file. This is the first step of the tutorial. ```bash mkdir aws-lambda cd aws-lambda touch lambda_function.py ``` -------------------------------- ### redis-rs SRANDMEMBER Example Source: https://upstash.com/docs/redis/commands/set/srandmember Example using the redis-rs client to get a random member from 'my-key'. ```rust use redis::TypedCommands; fn main() -> redis::RedisResult<()> { let url = std::env::var("REDIS_URL").expect("REDIS_URL is not set"); let client = redis::Client::open(url)?; let mut connection = client.get_connection()?; let result = connection.srandmember("my-key")?; println!("{result:?}"); Ok(()) } ``` -------------------------------- ### Create project directory and main.py Source: https://upstash.com/blog/integrating-vector-search-in-e-commerce-platforms-with-upstash-vector Commands to create a new directory named 'ecommerce-vector-search-server' and an empty main.py file. ```bash # Create and move to the new directory mkdir ecommerce-vector-search-server cd ecommerce-vector-search-server # Create a main.py file touch main.py ``` -------------------------------- ### jedis SRANDMEMBER Example Source: https://upstash.com/docs/redis/commands/set/srandmember Example using the jedis client to get a random member from 'my-key'. ```java import java.net.URI; import redis.clients.jedis.Jedis; try (Jedis jedis = new Jedis(new URI(System.getenv("REDIS_URL")))) { Object result = jedis.srandmember("my-key"); System.out.println(result); } ``` -------------------------------- ### Remix setup dialog output Source: https://upstash.com/blog/fast-websites-with-remix-on-cloudflare-and-upstash-redis Example output from the Remix setup dialog showing the prompts and expected selections for creating an app named 'upstash-remix' with Cloudflare Workers and JavaScript. ```text R E M I X - v1.2.3 💿 Welcome to Remix! Let's get you set up with a new project. ? Where would you like to create your app? upstash-remix ? Where do you want to deploy? Choose Remix if you're unsure, it's easy to chang e deployment targets. Cloudflare Workers ? TypeScript or JavaScript? JavaScript ? Do you want me to run `npm install`? Yes ``` -------------------------------- ### go-redis SRANDMEMBER Example Source: https://upstash.com/docs/redis/commands/set/srandmember Example using the go-redis client to get a random member from 'my-key'. ```go package main import ( "context" "fmt" "os" "github.com/redis/go-redis/v9" ) func main() { opts, err := redis.ParseURL(os.Getenv("REDIS_URL")) if err != nil { panic(err) } client := redis.NewClient(opts) result, err := client.SRandMember(context.Background(), "my-key").Result() if err != nil { panic(err) } fmt.Println(result) } ``` -------------------------------- ### Final env file setup Source: https://upstash.com/blog/openai-hackernews-summarizer Complete environment file containing OpenAI API key, Upstash Redis credentials, and Qstash signing keys. ```plaintext OPENAI_API_KEY=XXXX UPSTASH_REDIS_REST_URL="https://us1-XXX-38101.upstash.io" UPSTASH_REDIS_REST_TOKEN="AZTVACQXXXVhOTktYzI0Mi0XXXM4ZmQzMjI3NDY0NTZmNDXXXYjQ0NGY4MGYwNDI=" QSTASH_CURRENT_SIGNING_KEY=XXXX QSTASH_NEXT_SIGNING_KEY=XXXX ``` -------------------------------- ### Initialize Node.js project and install dependencies Source: https://upstash.com/blog/kafka-gaming Commands to initialize a new Node.js project and install kafkajs, socket.io, ejs, and express. ```bash npm init -y npm install kafkajs socket.io ejs express ``` -------------------------------- ### redis-py SRANDMEMBER Example Source: https://upstash.com/docs/redis/commands/set/srandmember Example using the redis-py client to get a random member from 'my-key'. ```python import os import redis client = redis.from_url(os.environ["REDIS_URL"]) result = client.srandmember("my-key") print(result) ``` -------------------------------- ### node-redis SRANDMEMBER Example Source: https://upstash.com/docs/redis/commands/set/srandmember Example using the node-redis client to get a random member from 'my-key'. ```typescript import { createClient } from "redis"; const client = await createClient({ url: process.env.REDIS_URL }) .on("error", console.error) .connect(); const result = await client.sRandMember("my-key"); console.log(result); ``` -------------------------------- ### Create .env file with required environment variables Source: https://upstash.com/blog/automating-website-content-translation-with-openai Create a .env file at the project root with QSTASH_TOKEN, OPENAI_API_KEY, GITHUB_TOKEN, and VERCEL_DEPLOY_HOOK_URL. Replace the placeholder values with your actual tokens. ```bash # .env # Upstash QStash Environment Variable QSTASH_TOKEN="..." # OpenAI Environment Variable OPENAI_API_KEY="sk-proj-..." # GitHub Environment Variable GITHUB_TOKEN="github_pat_..." # Vercel Hook Environment Variable VERCEL_DEPLOY_HOOK_URL="https://api.vercel.com/v1/integrations/deploy/.../..." ``` -------------------------------- ### Initialize Node project and install dependencies Source: https://upstash.com/docs/redis/tutorials/cloud_run_sessions Initializes a Node project and installs express, redis, connect-redis, and express-session. ```bash npm initnpm install express redis connect-redis express-session ``` -------------------------------- ### ioredis SRANDMEMBER Example Source: https://upstash.com/docs/redis/commands/set/srandmember Example using the ioredis client to get a random member from 'my-key'. ```typescript import Redis from "ioredis"; const redis = new Redis(process.env.REDIS_URL!); const result = await redis.srandmember("my-key"); console.log(result); ``` -------------------------------- ### Deploy to Koyeb using the Koyeb CLI Source: https://upstash.com/docs/redis/quickstarts/koyeb Initialize a Koyeb app with the example-koyeb-upstash name, pointing to your GitHub repository and setting environment variables for the Upstash Redis connection. Replace the placeholders with your actual values. ```bash koyeb app init example-koyeb-upstash \ --git github.com// \ --git-branch main \ --ports 3000:http \ --routes /:3000 \ --env PORT=3000 \ --env UPSTASH_REDIS_REST_URL="" \ --env UPSTASH_REDIS_REST_TOKEN="" ``` -------------------------------- ### JSON.MGET example with redis-rs Source: https://upstash.com/docs/redis/commands/json/json-mget Example using redis-rs connection.json_mget to get a path from multiple keys. ```rust use redis::JsonCommands; fn main() -> redis::RedisResult<()> { let url = std::env::var("REDIS_URL").expect("REDIS_URL is not set"); let client = redis::Client::open(url)?; let mut connection = client.get_connection()?; let result: redis::Value = connection.json_mget(&["profile:1", "profile:2"], "$.name")?; println!("{result:?}"); Ok(()) } ``` -------------------------------- ### HTTL example with go-redis Source: https://upstash.com/docs/redis/commands/hash/httl Example using the go-redis Go client. It parses REDIS_URL, creates a client, and calls HTTL. ```go package main import ( "context" "fmt" "os" "github.com/redis/go-redis/v9" ) func main() { opts, err := redis.ParseURL(os.Getenv("REDIS_URL")) if err != nil { panic(err) } client := redis.NewClient(opts) result, err := client.HTTL(context.Background(), "my-key", "1", "field").Result() if err != nil { panic(err) } fmt.Println(result) } ``` -------------------------------- ### JSON.MGET example with jedis Source: https://upstash.com/docs/redis/commands/json/json-mget Example using jedis jedis.jsonMGet to get a path from multiple keys. ```java import java.net.URI; import redis.clients.jedis.JedisPooled; try (JedisPooled jedis = new JedisPooled(new URI(System.getenv("REDIS_URL")))) { Object result = jedis.jsonMGet(new redis.clients.jedis.json.Path2("$.name"), "profile:1", "profile:2"); System.out.println(result); } ``` -------------------------------- ### Run QStash dev server with CLI Source: https://upstash.com/blog/durable-functions-nextjs Use npx to start the QStash dev server. It prints local credentials that you should add to your environment file. ```bash npx @upstash/qstash-cli dev ``` -------------------------------- ### JSON.MGET example with go-redis Source: https://upstash.com/docs/redis/commands/json/json-mget Example using go-redis client.JSONMGet to get a path from multiple keys. ```go package main import ( "context" "fmt" "os" "github.com/redis/go-redis/v9" ) func main() { opts, err := redis.ParseURL(os.Getenv("REDIS_URL")) if err != nil { panic(err) } client := redis.NewClient(opts) result, err := client.JSONMGet(context.Background(), "$.name", "profile:1", "profile:2").Result() if err != nil { panic(err) } fmt.Println(result) } ``` -------------------------------- ### Install necessary packages Source: https://upstash.com/blog/email-scheduler-qstash-python Install QStash Python SDK, Django, SendGrid, python-dotenv, and croniter via pip. ```bash pip install qstash-python django sendgrid python-dotenv croniter ``` -------------------------------- ### JSON.MGET example with node-redis Source: https://upstash.com/docs/redis/commands/json/json-mget Example using node-redis client.json.mGet to get a path from multiple keys. ```javascript import { createClient } from "redis"; const client = await createClient({ url: process.env.REDIS_URL }) .on("error", console.error) .connect(); const result = await client.json.mGet(["profile:1", "profile:2"], "$.name"); console.log(result); ``` -------------------------------- ### JSON.MGET example with @upstash/redis Source: https://upstash.com/docs/redis/commands/json/json-mget Example using the @upstash/redis SDK to get a path from multiple keys. ```typescript import { Redis } from "@upstash/redis"; const redis = Redis.fromEnv(); const values = await redis.json.mget(["key1", "key2"], "$.path.to.somewhere"); ``` -------------------------------- ### go-redis HRANDFIELD example Source: https://upstash.com/docs/redis/commands/hash/hrandfield Example using the go-redis client to get a random field from a hash. ```go package main import ( "context" "fmt" "os" "github.com/redis/go-redis/v9" ) func main() { opts, err := redis.ParseURL(os.Getenv("REDIS_URL")) if err != nil { panic(err) } client := redis.NewClient(opts) result, err := client.HRandField(context.Background(), "my-key", 1).Result() if err != nil { panic(err) } fmt.Println(result) } ``` -------------------------------- ### Run OpenClaw onboarding Source: https://upstash.com/docs/box/guides/openclaw-setup Start the interactive onboarding wizard. The CLI guides through provider selection, authentication, and gateway configuration. After completion, copy the dashboard URL with its token for later use. ```bash openclaw onboard --install-daemon ``` -------------------------------- ### Project setup commands Source: https://upstash.com/blog/redis-qstash-ai Commands to create a new Node.js project and install dependencies: dotenv, express, axios, @upstash/redis, and @upstash/qstash. ```bash $ mkdir history-jokes & cd history-jokes $ npm init -y $ npm i dotenv express axios @upstash/redis @upstash/qstash ``` -------------------------------- ### redis-py HRANDFIELD example Source: https://upstash.com/docs/redis/commands/hash/hrandfield Example using the redis-py client to get a random field from a hash. ```python import os import redis client = redis.from_url(os.environ["REDIS_URL"]) result = client.hrandfield("my-key") print(result) ``` -------------------------------- ### node-redis HRANDFIELD example Source: https://upstash.com/docs/redis/commands/hash/hrandfield Example using the node-redis client to get a random field from a hash. ```typescript import { createClient } from "redis"; const client = await createClient({ url: process.env.REDIS_URL }) .on("error", console.error) .connect(); const result = await client.hRandField("my-key"); console.log(result); ``` -------------------------------- ### TOUCH Example with go-redis Source: https://upstash.com/docs/redis/commands/generic/touch Example of using the Touch method from the go-redis client. It parses the REDIS_URL environment variable, creates a client, and prints the result. ```go package main import ( "context" "fmt" "os" "github.com/redis/go-redis/v9" ) func main() { opts, err := redis.ParseURL(os.Getenv("REDIS_URL")) if err != nil { panic(err) } client := redis.NewClient(opts) result, err := client.Touch(context.Background(), "my-key").Result() if err != nil { panic(err) } fmt.Println(result) } ``` -------------------------------- ### Install flyctl and authenticate Source: https://upstash.com/blog/next-chatapp-with-kafka Installs the Fly.io CLI tool and logs in. ```bash npm install flyctl flyctl auth login ``` -------------------------------- ### ioredis HRANDFIELD example Source: https://upstash.com/docs/redis/commands/hash/hrandfield Example using the ioredis client to get a random field from a hash. ```typescript import Redis from "ioredis"; const redis = new Redis(process.env.REDIS_URL!); const result = await redis.hrandfield("my-key"); console.log(result); ``` -------------------------------- ### GET with Redis CLI Source: https://upstash.com/docs/redis/commands/string/get Example of using GET with the Redis CLI to retrieve the value of 'my-key'. ```bash GET my-key ``` -------------------------------- ### Local server entrypoint (cmd/server/main.go) Source: https://upstash.com/blog/aws-lambda-go-redis Entrypoint for running the server locally. Reads PORT environment variable, defaults to 5000, and starts HTTP server. ```go package main import ( "log" "net/http" "os" "com.upstash/example/aws-lambda-upstash-redis/core" ) func main() { mux := core.NewMux() port := os.Getenv("PORT") if len(port) == 0 { port = "5000" } if err := http.ListenAndServe(":"+port, mux); err != nil { log.Fatal(err) } } ``` -------------------------------- ### GETRANGE Example with Redis CLI Source: https://upstash.com/docs/redis/commands/string/getrange Example of using GETRANGE with the Redis CLI to get a substring from 'my-key'. ```bash GETRANGE my-key 0 1 ``` -------------------------------- ### Run the dashboard locally Source: https://upstash.com/blog/ai-sdk-telemetry-redis-search Three commands to install dependencies, copy the environment file, and start the development server. Requires UPSTASH_REDIS_REST_URL/TOKEN and OPENAI_API_KEY in .env. ```bash npm install cp .env.example .env # UPSTASH_REDIS_REST_URL/TOKEN + OPENAI_API_KEY npm run dev # dashboard at http://localhost:3000 ``` -------------------------------- ### JSON.MGET example with redis-py Source: https://upstash.com/docs/redis/commands/json/json-mget Example using redis-py client.json().mget to get a path from multiple keys. ```python import os import redis client = redis.from_url(os.environ["REDIS_URL"]) result = client.json().mget(["profile:1", "profile:2"], "$.name") print(result) ``` -------------------------------- ### Install server and client packages Source: https://upstash.com/blog/react-file-upload-a-multi-file-drag-and-drop-uploader-with-upstash-blob Install the required packages for the upload route: @upstash/blob, @upstash/redis, hono, @hono/node-server, and react-dropzone. ```bash npm install @upstash/blob @upstash/redis hono @hono/node-server react-dropzone ``` -------------------------------- ### redis-rs HRANDFIELD example Source: https://upstash.com/docs/redis/commands/hash/hrandfield Example using the redis-rs Rust client to get a random field from a hash. ```rust fn main() -> redis::RedisResult<()> { let url = std::env::var("REDIS_URL").expect("REDIS_URL is not set"); let client = redis::Client::open(url)?; let mut connection = client.get_connection()?; let mut command = redis::cmd("HRANDFIELD"); command.arg("my-key"); let result: redis::Value = command.query(&mut connection)?; println!("{result:?}"); Ok(()) } ``` -------------------------------- ### Start the local development environment Source: https://upstash.com/blog/ai-chatbot-nextjs Command to start the local development server after setting up the project and environment variables. ```bash npm run dev ``` -------------------------------- ### Build and run the local server Source: https://upstash.com/blog/aws-lambda-go-redis Build the server and run it locally using make and the build/server executable. ```bash make build-server && ./build/server ``` -------------------------------- ### jedis HRANDFIELD example Source: https://upstash.com/docs/redis/commands/hash/hrandfield Example using the jedis Java client to get a random field from a hash. ```java import java.net.URI; import redis.clients.jedis.Jedis; try (Jedis jedis = new Jedis(new URI(System.getenv("REDIS_URL")))) { Object result = jedis.hrandfield("my-key"); System.out.println(result); } ``` -------------------------------- ### LPUSHX with go-redis Source: https://upstash.com/docs/redis/commands/list/lpushx Example using the go-redis client. Parses REDIS_URL, creates a client, and calls LPushX, printing the result. ```go package main import ( "context" "fmt" "os" "github.com/redis/go-redis/v9" ) func main() { opts, err := redis.ParseURL(os.Getenv("REDIS_URL")) if err != nil { panic(err) } client := redis.NewClient(opts) result, err := client.LPushX(context.Background(), "my-key", "element").Result() if err != nil { panic(err) } fmt.Println(result) } ``` -------------------------------- ### upstash_redis HRANDFIELD example Source: https://upstash.com/docs/redis/commands/hash/hrandfield Example using the upstash_redis Python client to get a random field from a hash. ```python from upstash_redis import Redis redis = Redis.from_env() result = redis.hrandfield("my-key") print(result) ``` -------------------------------- ### Scaffold an Eve project with npx eve@latest init Source: https://upstash.com/docs/box/guides/eve-setup Run this command to create a new Eve project. It installs 'eve' and an AI SDK provider. Use eve 0.65.0 or later. The commented alternative starts with a Next.js app. ```bash npx eve@latest init my-agent # or, to start with a Next.js app: npx eve@latest init my-agent --channel-web-nextjs ``` -------------------------------- ### Install langchain-upstash-box with uv Source: https://upstash.com/docs/box/guides/langchain-deep-agents Alternative installation using uv. Requires the same Box API key setup. ```bash uv add langchain-upstash-box ``` -------------------------------- ### Clone the starter repository and checkout initial branch Source: https://upstash.com/blog/svelte-with-serverless-redis Commands to clone the starter repo and switch to the 'initial' branch to follow along with the tutorial. ```bash git clone https://github.com/geoffrich/movie-search-redis.git cd movie-search-redis git checkout initial ``` -------------------------------- ### Install agent CLI with sudo -n in setup Source: https://upstash.com/docs/box/guides/tanstack-setup Shows how to install a non-default agent CLI in the sandbox setup step using sudo -n because the box runs as non-root boxuser and /usr/local/lib/node_modules is root-owned. Running the CLI in the same step turns a silent npm install failure into a loud bootstrap failure. ```typescript setup: ["sudo -n npm install -g @some/agent-cli --include=optional && some-agent --version"], ``` -------------------------------- ### Create a QStash Client Source: https://upstash.com/docs/qstash/sdks/ts/gettingstarted Import the Client class and instantiate it with your QStash token. This is the basic setup for using the SDK. ```typescript import { Client } from "@upstash/qstash"; const client = new Client({ token: "", }); ``` -------------------------------- ### Clone and install project dependencies Source: https://upstash.com/blog/article-recommendation-system Commands to clone the article-recommendation-system repository and install dependencies using pnpm. ```bash # Clone the project git clone https://github.com/rishi-raj-jain/article-recommendation-system cd article-recommendation-system # Install the dependencies pnpm install ``` -------------------------------- ### VECTOR.INFO example with Redis CLI Source: https://upstash.com/docs/redis/commands/vector/vector-info Example of using VECTOR.INFO with the Redis CLI to get info for index 'my-index'. ```redis VECTOR.INFO my-index ``` -------------------------------- ### redis-rs MULTI Transaction Example Source: https://upstash.com/docs/redis/commands/transactions/multi Example of using redis-rs to start an atomic pipeline, set a balance, and execute. ```rust fn main() -> redis::RedisResult<()> { let url = std::env::var("REDIS_URL").expect("REDIS_URL is not set"); let client = redis::Client::open(url)?; let mut connection = client.get_connection()?; redis::pipe() .atomic() .set("balance", "100") .ignore() .query::<()>(&mut connection)?; Ok(())} ``` -------------------------------- ### jedis MULTI Transaction Example Source: https://upstash.com/docs/redis/commands/transactions/multi Example of using jedis to start a transaction with multi(), set a balance, and execute. ```java import java.net.URI;import redis.clients.jedis.Jedis;import redis.clients.jedis.Transaction;try (Jedis jedis = new Jedis(new URI(System.getenv("REDIS_URL"))); Transaction transaction = jedis.multi()) { transaction.set("balance", "100"); Object result = transaction.exec();} ``` -------------------------------- ### Create a new Node.js project Source: https://upstash.com/blog/qstash-openrouter Initializes a new Node.js project in a directory named qstash-openrouter. Run these commands in your terminal. ```bash $ mkdir qstash-openrouter $ cd qstash-openrouter $ npm init -y ``` -------------------------------- ### go-redis MULTI Transaction Example Source: https://upstash.com/docs/redis/commands/transactions/multi Example of using go-redis to start a transaction with TxPipeline, set a balance, and execute. ```go ctx := context.Background()opts, err := redis.ParseURL(os.Getenv("REDIS_URL"))if err != nil { panic(err) }client := redis.NewClient(opts)pipe := client.TxPipeline()pipe.Set(ctx, "balance", "100", 0)result, err := pipe.Exec(ctx)if err != nil { panic(err) } ``` -------------------------------- ### Create project directory Source: https://upstash.com/docs/redis/tutorials/aws_app_runner_with_redis Commands to create and enter the project directory for the App Runner example. ```bash mkdir app_runner_examplecd app_runner_example ``` -------------------------------- ### Initialize Node project and install ioredis Source: https://upstash.com/docs/redis/tutorials/aws_app_runner_with_redis Initializes a Node.js project and installs the ioredis Redis client dependency. ```bash npm initnpm install ioredis ``` -------------------------------- ### redis-py MULTI Transaction Example Source: https://upstash.com/docs/redis/commands/transactions/multi Example of using redis-py to start a transaction with a pipeline, set a balance, and execute. ```python import osimport redisclient = redis.from_url(os.environ["REDIS_URL"])with client.pipeline(transaction=True) as pipe: result = pipe.set("balance", "100").execute() ```