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

@titanabrian/chatdaddy-client

v0.1.0

Published

Typescript client for interacting with all ChatDaddy services. You can use this client to authenticate, send & receive messages, update chats, create groups & everything you expect from the ChatDaddy APIs.

Readme

ChatDaddy Typescript Client

Typescript client for interacting with all ChatDaddy services. You can use this client to authenticate, send & receive messages, update chats, create groups & everything you expect from the ChatDaddy APIs.

API Docs

You can find the full API docs for the service here

Installing the Client

Using NPM:

npm i git+https://github.com/chatdaddy/typescript-client

Using yarn:

yarn add git+https://github.com/chatdaddy/typescript-client

You can then import in your code like:

import { MessagesApi } from '@chatdaddy/client'

Refresh Tokens and Generating Them

We recommend you use refresh tokens to generate these short lived access tokens. The refresh token is immune to password changes & prevents you from ever entering the password in plaintext. The refresh token automatically becomes invalid after 14 Days of inactivity.

You do have to use your password to generate a refresh token.

import { OAuthApi, encodeSHA256 } from '@chatdaddy/client'

const getRefreshToken = async() => {
	const oAuthApi = new OAuthApi()
	const {
      data: { refresh_token },
    } = await oAuthApi.tokenPost({
      phoneNumber: 85212345678, // use your own ChatDaddy registered phone number
	  password: encodeSHA256('plaintextPassword'), // pass the SHA encoded password
      returnRefreshToken: true,
    })
	return refresh_token
}
console.log(getRefreshToken()) // prints something like "676be3ff-8d6e-4e74-8b0a-16e769d1ee80"

Generating Access Tokens and Using Them

All of ChatDaddy's APIs rely on a single access point using the short lived JWT access token. The access token's schema can be read about here.

Presently, all access tokens last for 1 hour.

This SDK includes functions to easily generate and persist access tokens from refresh tokens

import { makeAccessTokenFactory, MessagesApi } from '@chatdaddy/client'
// create a factory that takes care of auto-renewing access tokens when they expire
const getToken = makeAccessTokenFactory({
	request: {
		refreshToken: '676be3ff-8d6e-4e74-8b0a-16e769d1ee80', // example, use your own refresh token
		scopes: ['MESSAGES_SEND_TO_ALL'] // only add scopes to send messages
	},
})
;(async() => {
	// enter the team ID you want to generate the token for
	// read the section below to see how to get your team ID
	const { token } = await getToken('976bf2fe-ar6e-4e74-8b0a-16e769d1ee80')
	console.log(token)
	// above line would print something like "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"

	// send using WA API
	const config = new Configuration(
		{ accessToken: token },
	)
	const messagesApi = new MessagesApi(config)
	const { data: messages } = await messagesApi.messagesPost({
		// use a random channel (API term -- account) in your team
		accountId: 'random',
		// send to phone number
		chatId: '1234667772',
		messageCompose: {
			text: 'Hello from API',
		}
	})
})()

Finding Out your Team ID

  1. Login & open ChatDaddy App from https://app.chatdaddy.tech
  2. Navigate to https://app.chatdaddy.tech/settings/api
  3. Copy team ID from there

Example: example

Examples

The library has a list of examples of how to use this client, you can find them here.

Running the examples

  1. Clone this repository

  2. Run yarn or npm i (whichever package you prefer)

  3. Create a .env file in the repository folder with the following params:

    REFRESH_TOKEN=<chatdaddy refresh token>
    TEAM_ID=<chatdaddy team id>

    You can get this information from the API page on ChatDaddy.

  4. Run example scripts using yarn ts-node examples/{example-script}

    • Eg. yarn ts-node examples/send-message