Getting started overview

Getting started with Stream involves a sequence of steps designed to enable rapid integration of its chat, activity feed, or video functionalities. The process typically begins with account creation, followed by the generation and secure handling of API credentials. Subsequently, developers can utilize Stream's SDKs to initiate a first authenticated API call, confirming connectivity and proper setup. This foundational process ensures the development environment is correctly configured for building applications that leverage Stream's services.

Stream offers distinct APIs for different use cases, including Chat API, Activity Feed API, and Video API. While the core process for obtaining credentials is similar, the specific endpoints and SDK methods will vary based on the chosen product. The following guide focuses on the general steps applicable across Stream's offerings.

Here's a quick reference table outlining the getting started process:

Step What to do Where
1. Create Account Sign up for a Stream account. Stream Signup Page
2. Get API Keys Locate your Application ID, API Key, and API Secret in the Stream Dashboard. Stream Dashboard (select your application)
3. Install SDK Install the relevant SDK for your chosen programming language/framework. Stream SDK Documentation
4. First Request Make an authenticated API call using your credentials and SDK. Your local development environment

Create an account and get keys

To begin using Stream, you must first create an account. This provides access to the Stream Dashboard, where you manage your applications and retrieve necessary API credentials.

  1. Sign Up for a Stream Account: Navigate to the Stream signup page and complete the registration process. Stream offers a free tier for development and small projects, supporting up to 500 monthly active users (MAU) for Chat and 10,000 MAU for Feeds.

  2. Create a New Application: After signing up, you will be redirected to the Stream Dashboard. You may be prompted to create your first application. Provide a name for your application and select the desired region.

  3. Retrieve API Credentials: Once your application is created, access its settings within the Stream Dashboard. Here you will find three critical pieces of information:

    • Application ID: A unique identifier for your Stream application.
    • API Key: Used to identify your application when making API requests.
    • API Secret: A secret key used for server-side authentication and to generate user tokens. This key should be kept confidential and never exposed in client-side code.

    The API key and secret serve as credentials for authenticating with Stream's services, similar to how OAuth tokens function for other APIs. For client-side operations, Stream often uses user tokens generated server-side with the API Secret to ensure secure access without exposing the master secret.

  4. Store Credentials Securely: It is critical to store your API Key and API Secret securely. For server-side applications, use environment variables or a secret management service. Avoid hardcoding credentials directly into your codebase, especially for client-side applications where the API Secret should never be present.

Your first request

Making your first request typically involves installing a Stream SDK and then using your API credentials to initialize a client and perform a basic operation. This example will demonstrate a simple server-side interaction using a common SDK, such as Python or Node.js, for the Chat API.

Example: Initializing the Stream Chat Client (Python)

First, install the Stream Python SDK:

pip install stream-chat

Then, initialize the client and perform a simple check, such as retrieving application settings:

import stream_chat

# Your Stream API credentials
API_KEY = "YOUR_STREAM_API_KEY"
API_SECRET = "YOUR_STREAM_API_SECRET"
APP_ID = "YOUR_STREAM_APP_ID"

# Initialize the Stream Chat client
server_client = stream_chat.StreamChat(api_key=API_KEY, api_secret=API_SECRET, app_id=APP_ID)

try:
    # Example: Get application settings (requires APP_ID for some operations)
    # For many operations, APP_ID is implicitly handled by the client during initialization
    # A simpler first call might be to create a user or channel, but getting app settings
    # directly confirms a valid connection and authentication with the core service.
    app_settings = server_client.get_app_settings()
    print("Successfully connected to Stream!")
    print(f"Application Name: {app_settings['app']['name']}")
    print("App settings retrieved successfully:", app_settings)
except Exception as e:
    print(f"Error connecting to Stream: {e}")

Example: Initializing the Stream Chat Client (Node.js/JavaScript)

First, install the Stream JavaScript SDK:

npm install stream-chat

Then, initialize the client and perform a simple check:

const StreamChat = require('stream-chat').StreamChat;

// Your Stream API credentials
const API_KEY = "YOUR_STREAM_API_KEY";
const API_SECRET = "YOUR_STREAM_API_SECRET";
const APP_ID = "YOUR_STREAM_APP_ID";

// Initialize the Stream Chat client
const serverClient = StreamChat.getInstance(API_KEY, API_SECRET, { timeout: 6000 });

async function getAppSettings() {
  try {
    // For Node.js, getAppSettings requires the app_id in the client instance
    // or can be implicitly handled. This call confirms basic connectivity.
    const response = await serverClient.getAppSettings();
    console.log("Successfully connected to Stream!");
    console.log(`Application Name: ${response.app.name}`);
    console.log("App settings retrieved successfully:", response);
  } catch (error) {
    console.error("Error connecting to Stream:", error);
  }
}

getAppSettings();

Replace "YOUR_STREAM_API_KEY", "YOUR_STREAM_API_SECRET", and "YOUR_STREAM_APP_ID" with your actual credentials from the Stream Dashboard. A successful execution of this code indicates that your application can authenticate and communicate with Stream's services.

Common next steps

After successfully making your first API call, you can proceed with more advanced integrations based on your project's requirements. Common next steps include:

  • User Management: Create and manage users within your Stream application. This involves assigning unique user IDs and potentially providing additional metadata, such as names or profile pictures. Stream Chat User Guide

  • Channel Creation: For chat applications, create different types of channels (e.g., direct messages, group chats, public channels) and manage their members and permissions. Stream Chat Channel Guide

  • Frontend Integration: Integrate Stream's client-side SDKs (e.g., React, iOS, Android) to build the user interface for chat or feed experiences. This often involves securely generating user tokens on your backend and passing them to the frontend for client-side authentication. The security implications of exposing API keys are significant, and using short-lived tokens generated server-side is a standard practice for protecting client applications, as detailed in OAuth 2.0 client credentials flow.

  • Webhooks: Set up webhooks to receive real-time notifications about events happening within your Stream application, such as new messages or user status changes. This enables your backend to react to events without constant polling. Stream Chat Webhook Guide

  • Explore Advanced Features: Depending on your product (Chat, Feeds, Video), explore advanced functionalities like message moderation, custom commands, rich media attachments, activity grouping, or live streaming controls. Stream Documentation

Troubleshooting the first call

Encountering issues during your initial API call is common. Here are some troubleshooting steps:

  • Verify API Credentials: Double-check that your API Key, API Secret, and Application ID are copied correctly from the Stream Dashboard. Even minor typos can lead to authentication failures.

  • Check SDK Installation: Ensure the Stream SDK for your chosen language/framework is correctly installed and up to date. Refer to the Stream SDK installation guides.

  • Network Connectivity: Confirm that your development environment has outbound network access to Stream's API endpoints. Proxy settings or firewalls can sometimes block connections.

  • Error Messages: Pay close attention to the error messages returned by the SDK or the API. They often provide specific details about what went wrong (e.g., Authentication failed, Invalid API Key, Not Found).

  • Server-Side vs. Client-Side: Remember that your API Secret should only be used on your secure backend. If you are attempting to use the API Secret directly in client-side code, it will likely fail and is a significant security risk. For client-side operations, generate user tokens on your server and pass them to your frontend. The Stream Authentication Guide provides details on secure practices.

  • Consult Documentation: The official Stream documentation is a comprehensive resource for specific error codes, SDK usage, and best practices. Check the relevant section for your chosen product (Chat, Feeds, Video) and programming language.

  • Community and Support: If you're still stuck, consider reaching out to Stream's community forums or support channels, if available. Providing specific error messages and code snippets can help others assist you.