Skip to main content


Everything you will need to get up and running in 2 mins or less!


// Install Libraries
npm install @pushprotocol/restapi@latest @pushprotocol/socket@latest ethers@^5.7

Import libraries

// Import restapi for function calls
// Import socket for listening for real time messages
import { PushAPI, CONSTANTS } from "@pushprotocol/restapi";

// Ethers v5 or Viem, both are supported
import { ethers } from "ethers";

Initialize Chat

// Creating a random signer from a wallet, ideally this is the wallet you will connect
const signer = ethers.Wallet.createRandom();

// Initialize wallet user
// 'CONSTANTS.ENV.PROD' -> mainnet apps | 'CONSTANTS.ENV.STAGING' -> testnet apps
const userAlice = await PushAPI.initialize(signer, { env: CONSTANTS.ENV.STAGING });

Send Message

// This will be the wallet address of the recipient
const toWalletAddress = ethers.Wallet.createRandom().address;

// Send a message to Bob
const aliceMessagesBob = await, {
content: "Hello Bob!",
type: "Text",

Stream / Real time updates / Socket

// Initialize Stream
const stream = await userAlice.initStream([CONSTANTS.STREAM.CHAT]);

// Configure stream listen events and what to do
stream.on(CONSTANTS.STREAM.CHAT, (message) => {

// Connect Stream