{
  "markdown": "# Upstash QStash SDK\n\n![npm (scoped)](https://img.shields.io/npm/v/@upstash/qstash)\n\n> [!NOTE]  \n> **This project is in GA Stage.**\n> The Upstash Professional Support fully covers this project. It receives regular updates, and bug fixes.\n> The Upstash team is committed to maintaining and improving its functionality.\n\n**QStash** is an HTTP based messaging and scheduling solution for serverless and\nedge runtimes.\n\nIt is 100% built on stateless HTTP requests and designed for:\n\n- Serverless functions (AWS Lambda ...)\n- Cloudflare Workers (see\n  [the example](https://github.com/upstash/sdk-qstash-ts/tree/main/examples/cloudflare-workers))\n- Fastly Compute@Edge\n- Next.js, including [edge](https://nextjs.org/docs/api-reference/edge-runtime)\n- Deno\n- Client side web/mobile applications\n- WebAssembly\n- and other environments where HTTP is preferred over TCP.\n\n## How does QStash work?\n\nQStash is the message broker between your serverless apps. You send an HTTP\nrequest to QStash, that includes a destination, a payload and optional settings.\nWe durably store your message and will deliver it to the destination API via\nHTTP. In case the destination is not ready to receive the message, we will retry\nthe message later, to guarentee at-least-once delivery.\n\n## Quick Start\n\n### Install\n\n#### npm\n\n```bash\nnpm install @upstash/qstash\n```\n\n### Get your authorization token\n\nGo to [Upstash Console](https://console.upstash.com/qstash) and copy the QSTASH_TOKEN.\n\n## Basic Usage:\n\n### Publishing a message\n\n```ts\nimport { Client } from \"@upstash/qstash\";\n/**\n * Import a fetch polyfill only if you are using node prior to v18.\n * This is not necessary for nextjs, deno or cloudflare workers.\n */\nimport \"isomorphic-fetch\";\n\nconst client = new Client({\n  token: \"<QSTASH_TOKEN>\",\n});\n\nconst res = await client.publishJSON({\n  url: \"https://my-api...\",\n  // or urlGroup: \"the name or id of a url group\"\n  body: {\n    hello: \"world\",\n  },\n});\nconsole.log(res);\n// { messageId: \"msg_xxxxxxxxxxxxxxxx\" }\n```\n\n### Receiving a message\n\nHow to receive a message depends on your http server. The `Receiver.verify`\nmethod should be called by you as the first step in your handler function.\n\n```ts\nimport { Receiver } from \"@upstash/qstash\";\n\nconst r = new Receiver({\n  currentSigningKey: \"..\",\n  nextSigningKey: \"..\",\n});\n\nconst isValid = await r.verify({\n  /**\n   * The signature from the `Upstash-Signature` header.\n   *\n   * Please note that on some platforms (e.g. Vercel or Netlify) you might\n   * receive the header in lower case: `upstash-signature`\n   *\n   */\n  signature: \"string\";\n\n  /**\n   * The raw request body.\n   */\n  body: \"string\";\n})\n```\n\n### Publishing a message to an LLM provider\n\nNo need for complicated setup your LLM request. We'll call LLM and schedule it for your serverless needs.\n\n```ts\nimport { Client, openai } from \"@upstash/qstash\";\n\nconst client = new Client({\n  token: \"<QSTASH_TOKEN>\",\n});\n\nconst result = await client.publishJSON({\n  api: { name: \"llm\", provider: openai({ token: process.env.OPENAI_API_KEY! }) },\n  body: {\n    model: \"gpt-3.5-turbo\",\n    messages: [\n      {\n        role: \"user\",\n        content: \"Where is the capital of Turkey?\",\n      },\n    ],\n  },\n  callback: \"https://oz.requestcatcher.com/\",\n});\n```\n\n## Local Development\n\nSet `QSTASH_DEV=true` in your environment variables, and the SDK will download and connect to a local QStash dev server automatically. No tokens or signing keys required: the SDK injects deterministic dev credentials.\n\n```bash .env\nQSTASH_DEV=true\n```\n\nAlternatively, pass `devMode: true` to explicitly enable dev mode:\n\n```ts\nimport { Client } from \"@upstash/qstash\";\n\nconst client = new Client({ devMode: true });\n```\n\nThe same flag works on the receiving side: pass `devMode: true` to `Receiver` or `verifySignature*` to verify signatures with the dev server's keys. Dev mode is automatically a no-op when `NODE_ENV=production` and in browser/edge runtimes.\n\nSee [Local Development](https://docs.upstash.com/qstash/howto/local-development) for the full walkthrough, including the `registerQStashDev()` helper for Next.js edge routes.\n\n## Docs\n\nSee [the documentation](https://docs.upstash.com/qstash) for details.\n\n## Telemetry\n\nThis sdk sends anonymous telemetry headers to help us improve your experience.\nWe collect the following:\n\n- SDK version\n- Platform (Cloudflare, AWS or Vercel)\n- Runtime version (node@18.x)\n\nYou can opt out by setting the `UPSTASH_DISABLE_TELEMETRY` environment variable\nto any truthy value. Or setting `enableTelemetry: false` in the client options.\n\n```ts\nconst client = new Client({\n  token: \"<QSTASH_TOKEN>\",\n  enableTelemetry: false,\n});\n```\n\n## Contributing\n\n### Setup\n\nThis project requires [Bun](https://bun.sh/) to be installed. Please see the [Bun installation documentation](https://bun.sh/docs/installation) for further instructions.\n\nOnce you have cloned the project, you will need to install the dependencies and then you can run the project.\n\n```sh\nbun install\nbun run build\n```\n\n### Testing\n\nTo begin testing, environment variables will need to be setup. First, create a `.env` file in the root of the project. [`.env.template`](/.env.template) can be used as a template. Your values can be found in the [Qstash Console](https://console.upstash.com/qstash).\n\n```sh\nbun run test\n```\n\n### Committing\n\nThis project uses [commitlint](https://commitlint.js.org/). When committing, please ensure your commit message is formatted to include an appropriate prefix with the message.\n\n#### Examples\n\n```\nfix: typescript bug\nfeat: use new logger\nperf: refactor cache\n```\n\nFor a full list of options, please see the [`commitlint.config.js`](/commitlint.config.js) file.\n",
  "bytes": 5678,
  "sha": "e93b990114f08c9a4f278cdfdf86dd85aebfd5a61bd67e249594c85660edeee3",
  "repo_slug": "upstash/qstash-js",
  "fonte": "repo",
  "truncated": false,
  "api": "https://api.agentalog.com/api/listings/skl_upstash_qstash_js_qstash_js_f714d4ae/readme"
}