SDKs overview
Stream provides a suite of Software Development Kits (SDKs) and client libraries designed to facilitate the integration of its core services: Chat, Activity Feeds, and Video. These SDKs abstract the underlying Stream Chat REST API, offering language-specific methods and objects that simplify development workflows. Developers can choose from a range of official SDKs tailored for web, mobile, and backend environments, enabling them to build real-time communication and engagement features within their applications.
The SDKs handle aspects such as authentication, real-time event handling (e.g., new messages, feed updates), and data serialization, allowing developers to focus on application logic rather than low-level API interactions. For example, the JavaScript SDK for Chat manages WebSocket connections to deliver messages instantly to connected clients, while backend SDKs often focus on server-side operations like user management and token generation.
Official SDKs by language
Stream maintains a comprehensive set of official SDKs across various programming languages and frameworks, ensuring broad compatibility for different development stacks. These SDKs are actively developed and supported by Stream, offering the most stable and feature-rich integration experience. Each SDK is designed to align with the idiomatic patterns of its respective language or framework, providing a natural development experience.
The table below outlines the key official SDKs, their typical package names, and common installation commands. The 'Maturity' column indicates the general stability and feature completeness, with most official SDKs being production-ready.
| Language/Framework | Package Name(s) | Installation Command | Maturity |
|---|---|---|---|
| JavaScript (Web) | stream-chat, stream-chat-react |
npm install stream-chat or yarn add stream-chat |
Stable, Production Ready |
| React | stream-chat-react |
npm install stream-chat-react stream-chat |
Stable, Production Ready |
| React Native | stream-chat-react-native |
npm install stream-chat-react-native stream-chat |
Stable, Production Ready |
| Flutter | stream_chat_flutter |
flutter pub add stream_chat_flutter |
Stable, Production Ready |
| iOS (Swift) | StreamChat (via CocoaPods/Swift Package Manager) |
pod 'StreamChat' or Swift Package Manager integration |
Stable, Production Ready |
| Android (Kotlin) | stream-chat-android |
Gradle dependency: implementation 'io.getstream:stream-chat-android-client:x.y.z' |
Stable, Production Ready |
| Python | stream-chat, stream-python |
pip install stream-chat or pip install stream-python |
Stable, Production Ready |
| PHP | get-stream/stream-php |
composer require get-stream/stream-php |
Stable, Production Ready |
| Go | github.com/GetStream/stream-go |
go get github.com/GetStream/stream-go/v7 |
Stable, Production Ready |
| Ruby | stream-ruby |
gem install stream-ruby |
Stable, Production Ready |
| .NET | Stream.Chat, Stream.Feeds |
dotnet add package Stream.Chat or dotnet add package Stream.Feeds |
Stable, Production Ready |
For detailed API references and specific versioning information, developers should consult the official Stream documentation portal.
Installation
Installation procedures vary slightly depending on the programming language or framework. Generally, Stream SDKs are distributed through standard package managers for each ecosystem. The following provides general guidance for common environments:
- JavaScript/TypeScript (Web, React, React Native): Use npm or Yarn. For example, to install the core JavaScript Chat SDK and the React components:
npm install stream-chat stream-chat-react. - Flutter: Add the dependency to your
pubspec.yamlfile and runflutter pub get. Example:dependencies: stream_chat_flutter: ^x.y.z. - iOS (Swift): Integrate using CocoaPods or Swift Package Manager. For CocoaPods, add
pod 'StreamChat'to your Podfile. - Android (Kotlin): Add the necessary Gradle dependencies to your app's
build.gradlefile. Example:implementation 'io.getstream:stream-chat-android-client:x.y.z'. - Python: Install via pip. For instance:
pip install stream-chat. - PHP: Use Composer. Example:
composer require get-stream/stream-php. - Go: Use
go getto fetch the module. Example:go get github.com/GetStream/stream-go/v7. - Ruby: Install via RubyGems. Example:
gem install stream-ruby. - .NET: Use NuGet Package Manager. Example:
dotnet add package Stream.Chat.
After installation, it is typically necessary to initialize the SDK with your Stream API key and secret, which can be obtained from your Stream Dashboard. Client-side SDKs often require a user token generated on your backend for secure authentication, following the principle of least privilege as described in security best practices for OAuth 2.0 and similar authorization flows.
Quickstart example
This example demonstrates a basic integration of the Stream Chat JavaScript SDK to initialize a client, connect a user, and send a message. This snippet is for illustrative purposes and typically requires a backend to generate the user token securely.
import { StreamChat } from 'stream-chat';
const api_key = 'YOUR_API_KEY';
const user_id = 'some-user-id';
const user_token = 'YOUR_USER_TOKEN'; // This should be generated on your backend
const chatClient = new StreamChat(api_key);
async function initializeChat() {
try {
await chatClient.connectUser(
{
id: user_id,
name: 'Awesome User',
image: 'https://getstream.io/random_svg/?id=awesome-user&name=Awesome+User',
},
user_token,
);
console.log('User connected successfully!');
// Create or get a channel
const channel = chatClient.channel('messaging', 'general-chat', {
name: 'General Chat',
members: [user_id, 'another-user-id'], // Ensure 'another-user-id' exists or is added
});
await channel.watch();
console.log('Channel watched successfully!');
// Send a message
const response = await channel.sendMessage({
text: 'Hello, Stream Chat!',
});
console.log('Message sent:', response);
// Listen for new messages (example)
channel.on('message.new', (event) => {
console.log('New message received:', event.message.text);
});
} catch (error) {
console.error('Error initializing chat:', error);
}
}
initializeChat();
This quickstart illustrates:
- Client Initialization: Creating an instance of
StreamChatwith your API key. - User Connection: Authenticating and connecting a user with a unique ID and a securely generated token.
- Channel Management: Creating or retrieving a specific channel and subscribing to its updates via
watch(). - Sending Messages: Using the channel instance to send text messages.
- Real-time Events: Demonstrating how to listen for incoming messages using the
on()method.
For server-side operations, such as generating user tokens or managing channels programmatically, the backend SDKs (e.g., Python, Go, PHP) would be used. The Stream Chat Get Started guide provides more comprehensive examples for various languages.
Community libraries
While Stream provides a robust set of official SDKs, the developer community sometimes contributes additional libraries, wrappers, or tools that extend functionality or provide integrations with niche frameworks. These community-driven projects can offer alternative approaches or specialized features not found in the official SDKs.
Community libraries are typically hosted on platforms like GitHub and are often developed independently of Stream. Their maintenance status, feature set, and support can vary significantly. Developers considering community libraries should evaluate their active development, documentation, and community support before integrating them into production environments. For example, some might focus on specific UI components for less common front-end frameworks, or provide utilities for data migration. Always verify the source and licensing of any third-party library.
As of the last update, Stream's official SDK coverage is extensive, meaning most common use cases are addressed by the first-party offerings. Developers looking for specific community contributions can often find them by searching GitHub or relevant package repositories (e.g., npm, PyPI) for stream-chat or getstream related projects. The Stream Community page or forums may also highlight notable community projects.