Skip to content
Fully functional API for Stream Chat (REST) – Includes Auth, User/Member Creation & More!
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Example API in Node.js for Stream Chat 💬


This API will quickly get you up to speed on best practices for deploying an auth API for Stream Chat. The API can be deployed Heroku with a single click or to any other hosting environment that supports Node.js.

Quick Instructions (localhost)

  1. Create an free chat trial with Stream
  2. Clone repo with git clone
  3. Run yarn to install dependencies cd stream-chat-api && yarn
  4. Create a .env file and reference the .env.example file
  5. Start the API with yarn dev for development mode or yarn start for production mode
  6. Use Postman to hit the API with a POST on port 8080 (e.g. http://localhost:8080/v1/auth/init) using a variation of the following JSON payload:
	"name": {
		"first": "First Name",
		"last": "Last Name"
	"email": "foo@bar.baz",
	"password": "qux"

Technology Used

The following technologies were used to build this API:


  • User storage via MongoDB database
  • Mongoose schema with validation for user profiles
  • Password validation and hashing with bcrypt
  • Find or create for users within the MongoDB database
  • Easy deployment to Heroku (optional) or any other environment
  • Token generation for existing and new users (for Stream Chat)
  • Creation of a new channel named General if one does not exist
  • Automatic adding of users to the General channel
  • Heavily commented modern JavaScript

Please see below for installation requirements.


  • Node.js (latest)
  • Yarn (latest)


This section covers the various requirements for deploying this API in different environments. When in doubt, have a look at the .env.example file which outlines what required variables you will need to supply in order for the API to run properly.


The easiest method to deploy this API to Heroku is to click the deploy button below:


Note: You will need to spin up a MongoDB cluster and add your MongoDB URI to your environment variables under the Settings section of your applications dashboard on Heroku. Ensure that the environment variable is named MONGODB_URI. For local installations, you will need to add your MongoDB URI to the .env file in the root of this project.

Heroku Settings


├── controllers
│   └── v1
│       └── auth
│           ├── index.js
│           └── init.action.js
├── index.js
├── models
│   └── user.js
├── routes
│   └── init.js
└── utils
    ├── controllers.js
    └── db
        └── index.js
You can’t perform that action at this time.