WebSocket SDK

Real-time TikTok LIVE event streaming with the Euler Stream WebSocket SDK for TypeScript.

The WebSocket SDK provides a typed client for the Euler Stream WebSocket server at wss://ws.eulerstream.com. It works in both Node.js and browser environments.

View the full source on GitHub.

What You Get

  • Importable TypeScript types for all TikTok LIVE event schemas
  • createWebSocketURL helper for building authenticated WebSocket URLs
  • Utility functions for encoding and decoding protobuf messages
  • Typed WebSocket close codes
  • Cross-platform: works in Node.js and browsers

Quickstart

Install the package

npm i @eulerstream/euler-websocket-sdk

Connect from a backend (API Key)

On a secure backend, connect directly with your API key:

import WebSocket from "ws";
 
const uniqueId = "tv_asahi_news";
const ws = new WebSocket(
  `wss://ws.eulerstream.com?uniqueId=${uniqueId}&apiKey=${process.env.EULER_API_KEY}`
);
 
ws.on("message", (data) => {
  console.log("Received event:", data.toString());
});

Connect from a frontend (JWT)

For client-facing apps, provision a JWT from your backend and use it to connect:

// Frontend
const jwtKey = "JWT_FROM_YOUR_BACKEND";
const uniqueId = "tv_asahi_news";
const ws = new WebSocket(
  `wss://ws.eulerstream.com?uniqueId=${uniqueId}&jwtKey=${jwtKey}`
);

See JWT Authentication for how to provision JWTs from your backend.

Next Steps