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

@dwk/mastodon-api

v1.0.0-beta.2

Published

Mastodon-compatible client API subset: app OAuth login, instance metadata, and read-only account/timeline endpoints for off-the-shelf fediverse clients.

Downloads

1,322

Readme

@dwk/mastodon-api

A Mastodon-compatible client API subset for Cloudflare Workers: log in with an off-the-shelf fediverse client (Pixelfed's app, Tusky, Elk) and browse this deployment's account — read-only. Publishing stays with Micropub/MCP; this package adds no write path.

What phase 1 ships

  • POST /api/v1/apps + GET /api/v1/apps/verify_credentials — Mastodon's pre-RFC-7591 dynamic app registration, layered on @dwk/oauth's metadata validation.
  • GET /oauth/authorize, POST /oauth/token (authorization_code + client_credentials), POST /oauth/revoke — the Mastodon app OAuth flow. Owner authentication/consent is a config-injected approval hook; the package ships no login UI and stores no password.
  • GET /api/v1/instance, GET /api/v2/instance — instance metadata with a GoToSocial-style compatibility version string.
  • GET /api/v1/accounts/verify_credentials — the owner account (live counts arrive with the phase-2 backend; zeros until then).
  • GET/POST /api/v1/markers — saved read positions, persisted in D1.
  • A data-driven roster of valid-but-empty stubs (filters, lists, custom_emojis, …) that real clients call at startup.

The read surface (timelines, notifications, statuses) arrives in phase 2 via the MastodonBackend seam, implemented by @dwk/activitypub's createActivitypubMastodonApi adapter.

Usage

import { createMastodonApi } from "@dwk/mastodon-api";

const handler = createMastodonApi({
  baseUrl: "https://example.com",
  instance: { title: "My site", contactEmail: "[email protected]" },
  account: { username: "me", displayName: "Me" },
  approveAuthorization: async (request, httpRequest) => {
    // Authenticate the owner and obtain consent (render a page by returning
    // a Response), then:
    return { approved: true };
  },
});

export default {
  fetch: (request: Request, env: { AUTH_DB: D1Database }, ctx: ExecutionContext) =>
    handler(request, env, ctx),
};

Bindings: one D1 database, AUTH_DB (the shared auth-database binding name; tables are mastodon_-prefixed and coexist with other packages').

Token model

Access tokens are opaque 256-bit random strings stored as SHA-256 hashes in D1 — plain Bearer, because compatibility with real Mastodon clients is the point. This is the repo's documented, mitigated exception to the DPoP-everywhere rule: the surface is read-only, the tokens are accepted by no other package, and RFC 7009 revocation is the lifecycle. See spec/mastodon-client-api.md.

Spec

spec/packages/mastodon-api.md — authoritative requirements. Design: spec/mastodon-client-api.md (issue #327).