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

@widgetic/api-sdk

v1.0.21

Published

Official JavaScript/TypeScript client for the Widgetic API (ESM & CJS)

Readme

@widgetic/api-sdk

TypeScript/JavaScript client for the Widgetic API generated from OpenAPI. Works in browsers (ESM) and Node (CJS/ESM) using the Fetch API.

Usage

ES example:

// Import one of the APIs from api-sdk module
import { UsersApi } from '@widgetic/api-sdk';

// Static token copied from your account
const usersApi = new UsersApi('API_TOKEN');

// Ephemeral/rotating token (optional)
const usersEphemeral = new UsersApi({ apiKey: async () => getTokenFromYourApp() });

// Method use
const me = await usersApi.getCurrentUserProfile();

Authentication: API keys vs ephemeral tokens

  • API key (recommended for most users):

    • Generate in the dashboard → API Keys page (Personal workspace or Team).
    • Click "Create Key", copy the value, and use it as shown above:
      • new UsersApi('API_TOKEN')
    • API keys are long‑lived until you revoke or rotate them in the same page.
  • Ephemeral token (advanced, for your apps):

    • Short‑lived tokens issued by your backend/auth flow.
    • Provide a function that returns the current token; the SDK attaches it per request:
      • new UsersApi({ apiKey: async () => getTokenFromYourApp() })
    • Useful when you don’t want to expose a long‑lived key in the client.

Security tips:

  • Keep tokens secret; never commit to source control.
  • Rotate/revoke tokens from the API Keys page if leaked.

Supported environments

  • Browsers with native fetch (ESM)
  • Node.js 18+ (native fetch) or earlier Node with a fetch polyfill

Versioning

  • Follows API releases. Breaking changes will be noted in release notes.

Authentication and access levels

Widgetic issues multiple API key types. The prefix determines the role:

  • wgt_usr_… or wdg_org_… → role: user
  • wgt_prt_… → role: partner
  • wgt_adm_… → role: admin

Routes are annotated with an access level in the API (x-access-level):

  • user: any authenticated user key can call (e.g., GET /users/me)
  • partner: partner or admin keys only
  • admin: admin keys only

Common auth errors and fixes:

  • 401 Unauthorized: token missing/invalid/expired. Ensure Authorization: Bearer <token> is set. The SDK sets it automatically when you pass a token or async function.
  • 403 Insufficient permissions: the key’s role can’t access this endpoint. Check prefix and use a key with higher privileges if appropriate.
  • Local dev: ensure the API server is running at the expected BASE_PATH. For browser examples, override base path if needed when not using defaults.

Browser (ESM) example:

<script type="module">
  
  import { UsersApi } from '@widgetic/api-sdk';
  
  const usersApi = new UsersApi('API_TOKEN');
  
  const me = await usersApi.getCurrentUserProfile();
  console.log(me);
</script>

License

MIT © Widgetic