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

@kash-88/alerts

v1.2.1

Published

A lightweight library for easy integration with the DonationAlerts API: authorization, token management, and user info in a few lines.

Downloads

3

Readme

DonationAlerts API

A lightweight library for easy integration with the DonationAlerts API: authorization, token management, and user info in a few lines.

npm version npm downloads install size

Available in: RU, EN

Installation

Using npm:

$ npm install @kash-88/alerts

Using yarn:

$ yarn add @kash-88/alerts

Using pnpm:

$ pnpm add @kash-88/alerts

Using bun:

$ bun add @kash-88/alerts

Available Methods (Quick Overview)

| Function | Purpose | |---------------------|--------------------------------------------------------------| | getAuthorizeLink | Generate OAuth authorization link | | getOauthToken | Exchange code for access_token and refresh_token | | getUser | Fetch user profile by access_token | | getUserChannel | Get user channel by user_id | | updateAccessToken | Refresh access_token using refresh_token | | getPrivateToken | Get private token for channel subscription |


getAuthorizeLink (Sync)

Purpose: Generate OAuth authorization link for DonationAlerts.

  • Params:
    • client_id: string — Your app"s client ID
    • scope: string[] — Array of access scopes
  • Endpoint: https://www.donationalerts.com/oauth/authorize
  • API Docs: Authorization Request

Example:

import { getAuthorizeLink } from "@kash-88/alerts";

const client_id = "YOUR_CLIENT_ID"; // Get on https://www.donationalerts.com/application/clients
const scope = ["oauth-user-show"];

try {
    const link = getAuthorizeLink({ client_id, scope });
    console.log("Authorize link:", link);
} catch (error) {
    console.error("Error:", error.message);
} 

getOauthToken (Async)

Purpose: Exchange authorization code for access_token and refresh_token.

  • Params:
    • client_id: string — Your app's client ID
    • client_secret: string — Your app's client secret
    • code: string — Authorization code
  • Endpoint: https://www.donationalerts.com/oauth/token
  • API Docs: Getting Access Token

Example:

import { getOauthToken } from "@kash-88/alerts";

// Get on https://www.donationalerts.com/application/clients
const client_id = "YOUR_CLIENT_ID";
const client_secret = process.env.CLIENT_SECRET!;
const code = "USER_CODE";

(async () => {
    try {
        const token = await getOauthToken({ client_id, client_secret, code });
        console.log("Oauth token:", token);
    } catch (error) {
        console.error("Error:", error.message);
    }
})(); 

getUser (Async)

Purpose: Fetch user profile information by access_token.

  • Params:
    • access_token: string — User's access token
  • Endpoint: https://www.donationalerts.com/api/v1/user/oauth
  • API Docs: User Info

Example:

import { getUser } from "@kash-88/alerts";

const user_access_token = "USER_ACCESS_TOKEN";

(async () => {
    try {
        const user = await getUser(user_access_token);
        console.log("User data:", user);
    } catch (error) {
        console.error("Error:", error.message);
    }
})(); 

getUserChannel (Sync)

Purpose: Get user channel by user_id.

  • Params:
    • user_id: string — User ID
  • Endpoint:
  • API Docs:

Example:

import { getUserChannel } from "@kash-88/alerts";

const user_id = "USER_ID";

const channel = getUserChannel(user_id);
console.log("User channel:", channel);

updateAccessToken (Async)

Purpose: Refresh access_token using refresh_token.

  • Params:
    • client_id: string — Your app's client ID
    • client_secret: string — Your app's client secret
    • refresh_token: string — Refresh token
  • Endpoint: https://www.donationalerts.com/oauth/token
  • API Docs: Refreshing Access Tokens

Example:

import "dotenv/config";
import { getOauthToken } from "@kash-88/alerts";

// Get on https://www.donationalerts.com/application/clients
const client_id = "YOUR_CLIENT_ID";
const client_secret = process.env.CLIENT_SECRET!;

const refresh_token = "USER_REFRESH_TOKEN";

(async () => {
    try {
        const token = await getOauthToken({ client_id, client_secret, refresh_token });
        console.log("Oauth token:", token);
    } catch (error) {
        console.error("Error:", error.message);
    }
})();

getPrivateToken (Async)

Purpose: Get a private token for subscribing to a DonationAlerts channel via Centrifuge.

  • Params:
    • channel: string — Channel name to subscribe
    • uuidv4_client_id: string — UUID v4 client ID (used in WebSocket connection)
    • access_token: string — User's OAuth access token
  • Endpoint: https://www.donationalerts.com/api/v1/centrifuge/subscribe
  • API Docs:

Example:

import { getPrivateToken } from "@kash-88/alerts";

const channel = "USER_CHANNEL"; // Get via getUserChannel
const uuidv4_client_id = "UUIDv4_CLIENT_ID"; // WebSocket client UUID
const access_token = "USER_ACCESS_TOKEN";

(async () => {
    try {
        const token = await getPrivateToken({ channel, uuidv4_client_id, access_token });
        console.log("Private token:", token);
    } catch (error) {
        console.error("Error getting private token:", error.message);
    }
})();