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

@bradford-tech/mouser-sdk

v0.0.3

Published

TypeScript SDK for the Mouser Electronics API

Readme

@bradford-tech/mouser-sdk

A fully-typed, tree-shakeable TypeScript client for the Mouser Electronics API, generated from its OpenAPI specs.

Install

npm install @bradford-tech/mouser-sdk

Also works with pnpm add, yarn add, or bun add. From jsr:

deno add jsr:@bradford-tech/mouser-sdk

The client is ESM-only and runs on Node 20+, Deno, Bun, and edge runtimes (it uses the platform fetch, with no runtime dependencies).

Usage

Set your API keys, then call any operation. The base URL (https://api.mouser.com) is preconfigured.

import { searchByKeyword, setApiKeys } from "@bradford-tech/mouser-sdk";

setApiKeys({ search: process.env.MOUSER_SEARCH_API_KEY });

const { data } = await searchByKeyword({
  body: { SearchByKeywordRequest: { keyword: "LM358", records: 5 } },
});
console.log(data?.SearchResults?.Parts?.[0]?.MouserPartNumber);

Every operation returns { data, error, response } — data is the typed response body, error is the typed error body on a non-2xx status, and response is the raw Response. Pass { throwOnError: true } to throw instead. Mouser also reports problems in an Errors array inside data, so check both. Date-time fields are returned as Mouser sends them — offset-less strings such as "2026-11-06T00:00:00" — rather than Date objects, because Mouser does not say which timezone they are in.

Authentication

Mouser issues two API keys, both sent as the apiKey query parameter:

  • a Search API key, for the search operations;
  • an Order API key, for cart, order and order history.

Each operation automatically uses the right one. There are three ways to supply them.

Zero-config: set MOUSER_SEARCH_API_KEY and MOUSER_ORDER_API_KEY in the environment and every request uses them automatically — no code required. They are read per request, so loading .env after import works too.

Explicit, shared client: set keys once for all operations.

import { setApiKeys } from "@bradford-tech/mouser-sdk";

setApiKeys({ search: "your-search-key", order: "your-order-key" });
// either key also accepts a resolver for rotation / secret managers:
setApiKeys({ search: () => loadKeyFromVault("mouser-search") });

A key you leave out keeps falling back to its environment variable. Each setApiKeys call replaces the previous one.

If an operation needs a key that was never supplied, no request is sent: the call returns { error } (or throws with throwOnError: true) with a message such as No Mouser order API key: set MOUSER_ORDER_API_KEY, or pass { order } to setApiKeys() or createMouser().

Isolated clients: for multi-tenant servers, concurrent requests with different keys, or test isolation, create independent clients and pass one per call.

import { createMouser, searchByKeyword } from "@bradford-tech/mouser-sdk";

const mouser = createMouser({ search: "tenant-search-key" });
const { data } = await searchByKeyword({
  client: mouser,
  body: { SearchByKeywordRequest: { keyword: "LM358" } },
});

Isolated clients never read the environment: a client created with only a search key returns a missing-key error for cart and order calls instead of borrowing the process-wide order key.

Request your keys from the Mouser API hub.

Coverage

All 24 current operations are generated as standalone, tree-shakeable functions — import only what you use.

| Area | Functions | | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Search | searchByKeyword, searchByPartNumber, searchByKeywordAndManufacturer, searchByPartNumberAndManufacturer, getManufacturerList | | Cart | getCart, updateCart, addCartItems, updateCartItems, removeCartItem, addScheduledCartItems, updateScheduledCartItems, deleteAllScheduledCartItems | | Order history | getOrderHistoryByDateFilter, getOrderHistoryByDateRange, getOrderHistoryBySalesOrderNumber, getOrderHistoryByWebOrderNumber | | Order | queryOrderOptions, getCurrencies, getCountries, createOrder, createOrderFromOrder, getOrder, createCartFromOrder |

How the spec is built

Mouser publishes two Swagger 2.0 documents: V1 (most operations) and V2 (replacements for three deprecated V1 search operations). npm run spec:update converts both to OpenAPI 3.0 with swagger2openapi and merges them with openapi-merge-cli, dropping the deprecated V1 operations, into spec/openapi.json — a faithful image of upstream.

At generate time, openapi-ts.patch.ts adapts that spec for the SDK: it pins /api/v{version}/… paths to /api/v1/… (the only version Mouser serves for them), replaces the per-operation apiKey parameter with two security schemes, and gives every operation a hand-picked name. An operation without a name fails generation, so new upstream endpoints never ship under an auto-generated name.

Development

git clone https://github.com/bradford-tech/mouser-sdk.git
cd mouser-sdk
npm install
npm run build

Common commands

npm run spec:update  # download, convert and merge the upstream specs
npm run generate     # regenerate the client from spec/openapi.json
npm test             # unit tests (node:test)
npm run type-check   # tsc --noEmit
npm run lint         # eslint (zero warnings tolerance)
npm run fix          # prettier + eslint auto-fix, then type-check
npm run live-check   # read-only calls against the real API (keys from .env)

The client in src/client is generated by @hey-api/openapi-ts. A daily GitHub Actions workflow refreshes the specs, regenerates the client, and opens a PR if anything changed — labelled needs-rename if Mouser added an operation that needs a name.

Contributing

Bug reports and pull requests are welcome on GitHub.

License

MIT