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 🙏

© 2026 – Pkg Stats / Ryan Hefner

newchat.js

v1.1.0

Published

Unofficial Node.js wrapper for NewChat API

Readme


Cài đặt

npm install newchat.js

Quickstart

const login = require('newchat.js');

const api = await login('[email protected]', 'password');

await api.listen((err, event) => {
  if (err || event.type !== 'message') return;
  if (event.data.isSelf) return;

  if (event.data.body === '/ping') {
    api.sendMessage(event.data.threadID, 'pong 🏓');
  }
});

Demo: Bot nhận /ping và trả về pong 🏓

Test thành công


AppState — Không cần login lại

const fs = require('fs');
const { loadAppState } = require('newchat.js');

// Lưu session
const api = await login('[email protected]', 'password');
fs.writeFileSync('appstate.json', JSON.stringify(api.getAppState()));

// Lần sau dùng lại
const api = await loadAppState(JSON.parse(fs.readFileSync('appstate.json')));

API

| Hàm | Mô tả | |-----|-------| | login(email, password) | Đăng nhập, trả về api object | | loadAppState({ token }) | Khôi phục session từ token | | api.getAppState() | Lấy { token } để lưu | | api.listen(callback) | Lắng nghe events realtime qua WebSocket | | api.sendMessage(threadID, text) | Gửi tin nhắn văn bản | | api.sendAttachment(threadID, filePath, caption?) | Gửi file/ảnh | | api.markAsRead(threadID) | Đánh dấu đã đọc | | api.getThreadList() | Danh sách cuộc trò chuyện | | api.getThreadHistory(threadID, options?) | Lịch sử tin nhắn | | api.getUserInfo() | Thông tin tài khoản đang đăng nhập | | api.getMyProfile() | Alias của getUserInfo() |

Xem đầy đủ tại docs site.


Cấu trúc dự án

newchat.js/
├── src/
│   ├── index.js          # Entry point — login(), loadAppState()
│   ├── httpUtils.js      # Axios instance + setToken()
│   ├── wsClient.js       # WebSocket — Socket.IO v4 + MessagePack
│   └── api/
│       ├── listen.js
│       ├── sendMessage.js
│       ├── sendAttachment.js
│       ├── markAsRead.js
│       ├── getThreadList.js
│       ├── getThreadHistory.js
│       └── getUserInfo.js
├── docs-site/            # VitePress documentation
├── DOCS.md               # API reference đầy đủ
├── test.js               # Test script
└── package.json

Kiến trúc

REST  →  https://api.newchat.vn   (Bearer JWT)
WS    →  wss://ws.newchat.vn      (Socket.IO v4 + MessagePack binary)

WebSocket auth flow:

  1. Server gửi EIO OPEN (0{sid,...})
  2. Client gửi binary msgpack { type:0, data:{token}, nsp:"/" }
  3. Server xác nhận CONNECT ACK
  4. Server push channel:message events

Thống kê Download

npm downloads npm weekly npm monthly


Build & Phát triển

# Cài dependencies
npm install newchat.js

# Chạy test (ping/pong bot)
node test.js

# Build docs
cd docs-site && npm run build

License

MIT © KaiyoDev

⚠️ Unofficial — không liên kết với đội ngũ newchat.vn. API có thể thay đổi bất kỳ lúc nào.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!