npm install @stream-io/node-sdk
// or using yarn
yarn add @stream-io/node-sdkInstallation
GitHub repository: https://github.com/GetStream/stream-node. Feel free to submit bug reports and feature requests.
The package is tested against these environments:
- Node.js@18
- Node.js@20
- Node.js@22
- Bun@1
Node@16 is not supported.
The package can be used with both JavaScript and TypeScript.
To create a server-side client, you'll need your API key and secret. Both of them can be found in your Stream Dashboard.
You can optionally pass a timeout for the API requests, the default timeout is 3000ms.
import { StreamClient } from "@stream-io/node-sdk";
// or
// const { StreamClient } = require("@stream-io/node-sdk");
const apiKey = "";
const secret = "";
client = new StreamClient(apiKey, secret);
// optionally add timeout to API requests
// the default timeout is 3000ms
client = new StreamClient(apiKey, secret, { timeout: 3000 });Custom HTTP agent
The SDK uses the built-in fetch. To control connection pooling and keep-alive, pass a custom undici Agent as the agent option; it is used as the dispatcher for all requests:
import { StreamClient } from "@stream-io/node-sdk";
import { Agent } from "undici";
const agent = new Agent({
connections: 10, // max connections per origin
keepAliveTimeout: 55_000, // idle socket timeout in ms
});
const client = new StreamClient(apiKey, secret, { timeout: 3000, agent });