Workbench developer docs中文

Mouser

Base URL

https://desktop-api.wbench.io/v1/proxy/mouser/

Use https://desktop-api.wbench.io/v1/proxy/mouser/ where Mouser's documentation uses https://api.mouser.com/.

It's Mouser's own API

Everything after the base URL is Mouser's Search API, exactly as Mouser documents it: the same paths, methods, query parameters and JSON bodies. Only the address and the credential change: you send your Workbench token, and Workbench adds your company's Mouser key on the server. You never see that key.

Notes

Examples

Set WB_TOKEN first: export WB_TOKEN=$(wb token).

wb

wb call mouser api/v1/search/partnumber --data '{"SearchByPartRequest": {"mouserPartNumber": "MMBT3904", "partSearchOptions": "None"}}'

curl

curl "https://desktop-api.wbench.io/v1/proxy/mouser/api/v1/search/partnumber" \
  -H "Authorization: Bearer $(wb token)" \
  -H "Content-Type: application/json" \
  -d '{"SearchByPartRequest": {"mouserPartNumber": "MMBT3904", "partSearchOptions": "None"}}'

Python

Mouser has no official SDK for Python or TypeScript, so these examples use plain HTTP.

import os
import requests

headers = {"Authorization": f"Bearer {os.environ['WB_TOKEN']}"}
r = requests.post(
    "https://desktop-api.wbench.io/v1/proxy/mouser/api/v1/search/partnumber",
    headers=headers,
    json={"SearchByPartRequest": {"mouserPartNumber": "MMBT3904", "partSearchOptions": "None"}},
    timeout=60,
)
r.raise_for_status()
print(r.json())

TypeScript

const r = await fetch("https://desktop-api.wbench.io/v1/proxy/mouser/api/v1/search/partnumber", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.WB_TOKEN}`, "Content-Type": "application/json" },
  body: JSON.stringify({"SearchByPartRequest": {"mouserPartNumber": "MMBT3904", "partSearchOptions": "None"}}),
});
if (!r.ok) throw new Error(`${r.status}: ${(await r.json()).message}`);
console.log(await r.json());

See Limits and errors for what a refusal looks like.