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

@bn-shortner/shortener

v0.1.0

Published

Official TypeScript/JavaScript client for the BN Shortener API (b1.lc): links, QR codes, bio pages, analytics, webhooks, OAuth

Readme

@broadnet/shortener (TypeScript / JavaScript)

Official client for the BN Shortener API (b1.lc): short links, QR codes, bio pages, analytics, Launch Check, webhooks and OAuth. Typed from the OpenAPI spec, no dependencies. Node 20+, Deno, Bun, Cloudflare Workers and browsers.

npm install @broadnet/shortener

Quick start

import { BNShortener } from '@broadnet/shortener';

const bn = new BNShortener({ apiKey: process.env.BN_API_KEY });

const link = await bn.links.create({ url: 'https://example.com/spring-sale', title: 'Spring sale' });
console.log(link.short_url); // https://b1.lc/AbC9

const stats = await bn.links.stats(link.id!, { period: '30d' });
console.log(stats.summary?.total_clicks);

for await (const l of bn.paginate(bn.links.list, { search: 'sale' })) console.log(l.short_code);

Create an API key in the dashboard: API Portal → API keys. Do not put an API key in a public web page; browser apps should use OAuth (below) so each person signs in with their own account.

Resources

bn.links, bn.qrCodes, bn.bioPages, bn.webhooks, bn.launchCheck, bn.security, bn.messaging, bn.apiKeys, bn.account, bn.appLinks, bn.system. Every method's doc comment names its endpoint and the permission it needs. Methods resolve to the response's data; list methods to a Page (iterable, .data, .pagination, .nextPage()); files to a BinaryResult (.data Uint8Array, .contentType, .text()).

const qr = await bn.qrCodes.create({ name: 'Menu', content: { url: 'https://example.com/menu' } });
const svg = await bn.qrCodes.image(qr.id!, { format: 'svg', size: 1000 });

Live clicks: for await (const click of bn.links.streamClicks(linkId)) { ... }.

Errors

import { ValidationError, APIError } from '@broadnet/shortener';

try {
  await bn.links.create({ url: 'not a url' });
} catch (e) {
  if (e instanceof ValidationError) console.log(e.errors); // [{ field: 'url', code, message }]
  else if (e instanceof APIError) console.log(e.status, e.type, e.detail, e.requestId);
}

Connection errors, timeouts, 408, 429 and 5xx are retried (maxRetries: 2, waiting as long as Retry-After says). Every write carries an Idempotency-Key, so a retry after a lost answer never creates a second link.

Apps that act for other people (OAuth 2.1)

import { BNShortener, OAuthClient, TokenSession } from '@broadnet/shortener';

const app = new OAuthClient({ clientId: 'bnc_...', redirectUri: 'https://example.com/callback' });
const auth = await app.authorizationUrl({ scope: ['read', 'write'] }); // keep auth.state + auth.codeVerifier
// send the person to auth.url; b1.lc sends them back to your redirect URI
const code = app.parseCallback(callbackUrl, auth.state);
const token = await app.exchangeCode(code, auth.codeVerifier);

const bn = new BNShortener({ oauth: new TokenSession(app, token, { onRefresh: saveToken }) });

Command-line tools: const device = await app.startDeviceFlow({ scope: ['read'] }), show device.verification_uri + device.user_code, then await app.waitForDevice(device).

Webhooks

import { webhooks } from '@broadnet/shortener';

const event = await webhooks.constructEvent(rawBody, req.headers, process.env.BN_WEBHOOK_SECRET!);

Pass the raw body (string or bytes) before JSON parsing. Signatures older than 5 minutes are refused.

Options

new BNShortener({ apiKey, accessToken, oauth, baseUrl, timeout, maxRetries, clientName, defaultHeaders, fetch }). clientName names your integration in the account's usage. bn.lastResponse has the status, request id and rate limit of the latest call. bn.request({ method, path, query, body }) calls any endpoint.

License

MIT