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

@packiko/sdk

v0.2.0

Published

Typed client for the Packiko API, generated from a pinned OpenAPI contract.

Readme

@packiko/sdk

Typed client for the Packiko API, generated from a pinned OpenAPI contract.

ESM-only. Node >= 20.

Install

npm install @packiko/sdk

React bindings are exposed separately and React is an optional peer; the core entry does not import React.

Use

The client is split in two phases, because the API resolves a tenant from an X-Account-Id header that only exists once the user has picked an account.

import { createPreAccountClient, createClient, ApiError } from '@packiko/sdk'

// Phase 1: no account yet. Only the pre-account surface is reachable.
const pre = createPreAccountClient({ token: () => accessToken })
const accounts = await pre.request('get', '/Auth/Common/Accounts')

// Phase 2: account chosen. The client sets X-Account-Id on every call.
const api = createClient({ token: () => accessToken, accountId: accounts[0].id })
const product = await api.request('get', '/Product/{id}', { path: { id: '42' } })

Reaching a phase-2 path from the phase-1 client is a type error, and vice versa. X-Account-Id is owned by the client and cannot be set by a caller.

Errors arrive as ApiError with the application/problem+json body parsed onto .problem:

try {
  await api.request('get', '/Product/{id}', { path: { id: 'nope' } })
} catch (e) {
  if (e instanceof ApiError) console.error(e.status, e.problem?.title, e.problem?.detail)
}

token is called per request, so a rotating access token does not need a new client.

Contract pinning

spec/public.json is a byte copy of openapi/public.json from a specific commit on the api repo's main; spec/pin.json records that commit and blob. src/types.gen.ts is generated from the pinned copy and committed.

To move to a newer contract:

# copy the new spec into spec/public.json, update spec/pin.json, then
npm run generate
npm run typecheck && npm run gates

npm run gates refuses a pin whose blob is not present on api's main.

CLI

The package ships packiko, a thin command line over the same client, for coding agents.

npx @packiko/sdk login                     # device code; approve in the browser
npx @packiko/sdk accounts                  # find your account id
npx @packiko/sdk login --account <id>      # bind the account (approve in the browser again)
npx @packiko/sdk get /Sku --json
npx @packiko/sdk get /Sku/{id} --path id=42

The account id is stored with the offline refresh token in ~/.packiko/credentials.json and is the only source of X-Account-Id. There is no env var or flag to change it. PACKIKO_API_URL overrides the API base URL. v1 is read-only.

Git Bash on Windows rewrites a leading / in arguments to a Windows path; run with MSYS_NO_PATHCONV=1 or use PowerShell.