npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@dycast/core

v1.0.6

Published

Core library for DyCast - Douyin live streaming message handling

Downloads

50

Readme

@dycast/core

Core library for DyCast - Douyin live streaming message handling with server proxy support.

Features

  • 🚀 Real-time connection to Douyin live streams
  • 💬 Parse chat messages, gifts, likes, and social interactions
  • 🔄 Event-driven architecture with built-in emitter
  • �️ Built-in proxy server for handling CORS and API access
  • �📦 TypeScript support with full type definitions
  • 🛠 Modular design for easy integration

Installation

npm install @dycast/core
# or
yarn add @dycast/core
# or
pnpm add @dycast/core

Quick Start

Client Usage

import { DyCast } from '@dycast/core';

const dycast = new DyCast();

// Connect to a live room
dycast.connect('room_id_here').then(() => {
  console.log('Connected to live room!');
});

// Listen for chat messages
dycast.on('chat', (message) => {
  console.log(`${message.user?.nickname}: ${message.content}`);
});

// Listen for gifts
dycast.on('gift', (gift) => {
  console.log(`${gift.user?.nickname} sent ${gift.giftName}`);
});

Server Usage (Proxy for Web Applications)

import { createDyCastServer } from '@dycast/core';

const server = createDyCastServer({
  port: 3001,
  host: '0.0.0.0',
  debug: true
});

server.start().then(() => {
  console.log('🚀 DyCast proxy server started!');
  console.log('📡 /dylive -> https://live.douyin.com');
  console.log('📡 /socket -> wss://webcast5-ws-web-lf.douyin.com');
});

Web Integration

Include mssdk.js in your HTML and use the proxy endpoints:

<!DOCTYPE html>
<html>
<head>
    <script src="./node_modules/@dycast/core/public/mssdk.js"></script>
</head>
<body>
    <script>
        // Use proxy endpoints for web development
        fetch('http://localhost:3001/dylive/148108118778')
          .then(response => response.text())
          .then(data => console.log('Live room data:', data));

        // WebSocket connection through proxy
        const ws = new WebSocket('ws://localhost:3001/socket/webcast/im/push/v2/');
    </script>
</body>
</html>

API Documentation

Core Classes

  • DyCast: Main class for connecting to live streams
  • DyCastServer: Proxy server for web applications
  • Emitter: Event emitter for handling real-time messages
  • Relay: WebSocket relay functionality

Message Types

  • Chat messages
  • Gift messages
  • Like messages
  • Member join/leave messages
  • Social interactions
  • Room statistics

Server Configuration

interface ServerConfig {
  port?: number;           // Default: 3001
  host?: string;           // Default: '0.0.0.0'
  dyliveTarget?: string;   // Default: 'https://live.douyin.com'
  socketTarget?: string;   // Default: 'wss://webcast5-ws-web-lf.douyin.com'
  cors?: boolean;          // Default: true
  debug?: boolean;         // Default: false
}

Proxy Endpoints

When running the server, the following endpoints are available:

  • Health Check: GET /health
  • Live API Proxy: GET /dylive/*https://live.douyin.com/*
  • WebSocket Proxy: ws://host:port/socket/*wss://webcast5-ws-web-lf.douyin.com/*

Assets

The library includes the following public assets:

  • public/mssdk.js: Required JavaScript SDK for web integration

Development

# Install dependencies
npm install

# Build the library
npm run build

# Type checking
npm run type-check

License

MIT