$npx -y skills add aklofas/kicad-happy --skill digikeySearch DigiKey for electronic components and download datasheets — primary source for prototype orders and the preferred API method for fetching datasheets. Find parts by keyword or MPN, check pricing/stock, download datasheets via API, analyze specifications. Sync and maintain a
| 1 | # DigiKey Parts Search & Analysis |
| 2 | |
| 3 | ## Related Skills |
| 4 | |
| 5 | | Skill | Purpose | |
| 6 | |-------|---------| |
| 7 | | `kicad` | Schematic analysis — extracts MPNs for datasheet sync | |
| 8 | | `bom` | BOM management — orchestrates sourcing across distributors | |
| 9 | | `spice` | Uses DigiKey parametric data for behavioral SPICE models | |
| 10 | |
| 11 | DigiKey is the **primary source for prototype orders** (Mouser is secondary). Its API returns direct PDF datasheet links, making it the preferred datasheet source. For production orders, see `lcsc`/`jlcpcb`. For BOM management and export workflows, see `bom`. |
| 12 | |
| 13 | ## API Credential Setup |
| 14 | |
| 15 | The DigiKey API requires OAuth 2.0 credentials. Here's how to set them up: |
| 16 | |
| 17 | 1. **Create a DigiKey account** at [digikey.com](https://www.digikey.com) if you don't have one |
| 18 | 2. **Register an API app** at [developer.digikey.com](https://developer.digikey.com): |
| 19 | - Sign in with your DigiKey account |
| 20 | - Go to "My Apps" → "Create App" |
| 21 | - App name: anything (e.g., "kicad-happy") |
| 22 | - Select **"Product Information v4"** API |
| 23 | - OAuth type: **Client Credentials** (2-legged, no user login needed) |
| 24 | - Callback URL: `https://localhost` (not used for client credentials, but required) |
| 25 | - After creation, note the **Client ID** and **Client Secret** |
| 26 | 3. **Set the environment variables** before running the scripts: |
| 27 | ```bash |
| 28 | export DIGIKEY_CLIENT_ID=your_client_id_here |
| 29 | export DIGIKEY_CLIENT_SECRET=your_client_secret_here |
| 30 | ``` |
| 31 | If credentials are stored in a central secrets file (e.g., `~/.config/secrets.env`), load them first: |
| 32 | ```bash |
| 33 | export $(grep -v '^#' ~/.config/secrets.env | grep -v '^$' | xargs) |
| 34 | ``` |
| 35 | |
| 36 | The client credentials flow has no user interaction — once configured, API calls work automatically. |
| 37 | |
| 38 | ## DigiKey Product Information API v4 |
| 39 | |
| 40 | The API is the preferred way to search DigiKey. It returns structured JSON with full product details, pricing, stock, datasheets, and parametric data. |
| 41 | |
| 42 | **Base URL:** `https://api.digikey.com` |
| 43 | |
| 44 | ### Authentication |
| 45 | |
| 46 | All API requests require OAuth 2.0. Use the **client credentials flow** (2-legged). Credentials must be loaded as environment variables (see "API Credential Setup" above). |
| 47 | |
| 48 | ```bash |
| 49 | curl -s -X POST https://api.digikey.com/v1/oauth2/token \ |
| 50 | -H "Content-Type: application/x-www-form-urlencoded" \ |
| 51 | -d "client_id=${DIGIKEY_CLIENT_ID}&client_secret=${DIGIKEY_CLIENT_SECRET}&grant_type=client_credentials" |
| 52 | ``` |
| 53 | |
| 54 | The response returns an `access_token` valid for **10 minutes**. Cache the token in a shell variable and reuse it for subsequent calls in the same session. If you get a 401 error mid-session, the token has expired — re-authenticate to get a fresh one. |
| 55 | |
| 56 | ### Required Headers |
| 57 | |
| 58 | Every API call needs: |
| 59 | ``` |
| 60 | X-DIGIKEY-Client-Id: ${DIGIKEY_CLIENT_ID} |
| 61 | Authorization: Bearer <access_token> |
| 62 | ``` |
| 63 | |
| 64 | Optional locale headers: |
| 65 | - `X-DIGIKEY-Locale-Language`: `en` (default), `ja`, `de`, `fr`, `ko`, `zhs`, `zht`, `it`, `es` |
| 66 | - `X-DIGIKEY-Locale-Currency`: `USD` (default), `CAD`, `EUR`, `GBP`, `JPY`, etc. |
| 67 | - `X-DIGIKEY-Locale-Site`: `US` (default), `CA`, `UK`, `DE`, etc. |
| 68 | |
| 69 | ### KeywordSearch — Find Parts |
| 70 | |
| 71 | ``` |
| 72 | POST /products/v4/search/keyword |
| 73 | ``` |
| 74 | |
| 75 | This is the primary search endpoint. Search by MPN, DigiKey part number, description, or keywords. |
| 76 | |
| 77 | Request body: |
| 78 | ```json |
| 79 | { |
| 80 | "Keywords": "GRM155R71C104KA88D", |
| 81 | "Limit": 25, |
| 82 | "Offset": 0, |
| 83 | "FilterOptionsRequest": { |
| 84 | "MinimumQuantityAvailable": 1, |
| 85 | "SearchOptions": ["InStock", "HasDatasheet", "RoHSCompliant"], |
| 86 | "ManufacturerFilter": [{"Id": "..."}], |
| 87 | "CategoryFilter": [{"Id": "..."}], |
| 88 | "StatusFilter": [{"Id": "..."}], |
| 89 | "MarketPlaceFilter": "ExcludeMarketPlace" |
| 90 | }, |
| 91 | "SortOptions": { |
| 92 | "Field": "Price", |
| 93 | "SortOrder": "Ascending" |
| 94 | } |
| 95 | } |
| 96 | ``` |
| 97 | |
| 98 | Key request fields: |
| 99 | - `Keywords` (string, max 250 chars) — search term (MPN, DK PN, description) |
| 100 | - `Limit` (int, 1-50) — results per page |
| 101 | - `Offset` (int) — pagination offset |
| 102 | - `SearchOptions` — array of: `InStock`, `HasDatasheet`, `RoHSCompliant`, `NormallyStocking`, `Has3DModel`, `HasCadModel`, `HasProductPhoto`, `NewProduct` |
| 103 | - `SortOptions.Field` — `Price`, `QuantityAvailable`, `Man |