digikey

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

DigiKey Parts Search & Analysis

DigiKey 元器件搜索与分析

Related Skills

相关技能

SkillPurpose
kicad
Schematic analysis — extracts MPNs for datasheet sync
bom
BOM management — orchestrates sourcing across distributors
spice
Uses DigiKey parametric data for behavioral SPICE models
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
.
技能用途
kicad
原理图分析——提取MPN用于数据手册同步
bom
BOM管理——协调多分销商采购
spice
使用DigiKey参数数据生成行为SPICE模型
DigiKey是原型订单的主要供应商(Mouser为次要供应商)。其API返回直接的PDF数据手册链接,使其成为首选的数据手册来源。如需生产订单,请查看
lcsc
/
jlcpcb
。如需BOM管理与导出工作流,请查看
bom

API Credential Setup

API凭证设置

The DigiKey API requires OAuth 2.0 credentials. Here's how to set them up:
  1. Create a DigiKey account at digikey.com if you don't have one
  2. Register an API app at developer.digikey.com:
    • Sign in with your DigiKey account
    • Go to "My Apps" → "Create App"
    • App name: anything (e.g., "kicad-happy")
    • Select "Product Information v4" API
    • OAuth type: Client Credentials (2-legged, no user login needed)
    • Callback URL:
      https://localhost
      (not used for client credentials, but required)
    • After creation, note the Client ID and Client Secret
  3. Set the environment variables before running the scripts:
    bash
    export DIGIKEY_CLIENT_ID=your_client_id_here
    export DIGIKEY_CLIENT_SECRET=your_client_secret_here
    If credentials are stored in a central secrets file (e.g.,
    ~/.config/secrets.env
    ), load them first:
    bash
    export $(grep -v '^#' ~/.config/secrets.env | grep -v '^$' | xargs)
The client credentials flow has no user interaction — once configured, API calls work automatically.
DigiKey API需要OAuth 2.0凭证。设置步骤如下:
  1. 若还没有DigiKey账户,请在digikey.com创建一个
  2. developer.digikey.com注册API应用:
    • 使用DigiKey账户登录
    • 进入“我的应用”→“创建应用”
    • 应用名称:任意名称(例如“kicad-happy”)
    • 选择**“Product Information v4”** API
    • OAuth类型:Client Credentials(双端认证,无需用户登录)
    • 回调URL:
      https://localhost
      (客户端凭证模式下不使用,但为必填项)
    • 创建完成后,记录Client IDClient Secret
  3. 运行脚本前设置环境变量:
    bash
    export DIGIKEY_CLIENT_ID=your_client_id_here
    export DIGIKEY_CLIENT_SECRET=your_client_secret_here
    若凭证存储在中央密钥文件中(例如
    ~/.config/secrets.env
    ),请先加载:
    bash
    export $(grep -v '^#' ~/.config/secrets.env | grep -v '^$' | xargs)
客户端凭证模式无需用户交互——配置完成后,API调用将自动运行。

DigiKey Product Information API v4

DigiKey产品信息API v4

The API is the preferred way to search DigiKey. It returns structured JSON with full product details, pricing, stock, datasheets, and parametric data.
Base URL:
https://api.digikey.com
该API是搜索DigiKey的首选方式。它返回包含完整产品详情、价格、库存、数据手册和参数数据的结构化JSON。
基础URL:
https://api.digikey.com

Authentication

认证

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).
bash
curl -s -X POST https://api.digikey.com/v1/oauth2/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "client_id=${DIGIKEY_CLIENT_ID}&client_secret=${DIGIKEY_CLIENT_SECRET}&grant_type=client_credentials"
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.
所有API请求都需要OAuth 2.0。使用客户端凭证模式(双端认证)。凭证必须作为环境变量加载(见上文“API凭证设置”)。
bash
curl -s -X POST https://api.digikey.com/v1/oauth2/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "client_id=${DIGIKEY_CLIENT_ID}&client_secret=${DIGIKEY_CLIENT_SECRET}&grant_type=client_credentials"
响应会返回一个有效期为10分钟
access_token
。将令牌缓存到shell变量中,并在同一会话的后续调用中复用。如果会话中出现401错误,说明令牌已过期——重新认证获取新令牌即可。

Required Headers

必填请求头

Every API call needs:
X-DIGIKEY-Client-Id: ${DIGIKEY_CLIENT_ID}
Authorization: Bearer <access_token>
Optional locale headers:
  • X-DIGIKEY-Locale-Language
    :
    en
    (default),
    ja
    ,
    de
    ,
    fr
    ,
    ko
    ,
    zhs
    ,
    zht
    ,
    it
    ,
    es
  • X-DIGIKEY-Locale-Currency
    :
    USD
    (default),
    CAD
    ,
    EUR
    ,
    GBP
    ,
    JPY
    , etc.
  • X-DIGIKEY-Locale-Site
    :
    US
    (default),
    CA
    ,
    UK
    ,
    DE
    , etc.
每个API调用都需要:
X-DIGIKEY-Client-Id: ${DIGIKEY_CLIENT_ID}
Authorization: Bearer <access_token>
可选区域设置请求头:
  • X-DIGIKEY-Locale-Language
    :
    en
    (默认)、
    ja
    de
    fr
    ko
    zhs
    zht
    it
    es
  • X-DIGIKEY-Locale-Currency
    :
    USD
    (默认)、
    CAD
    EUR
    GBP
    JPY
  • X-DIGIKEY-Locale-Site
    :
    US
    (默认)、
    CA
    UK
    DE

KeywordSearch — Find Parts

KeywordSearch——查找零件

POST /products/v4/search/keyword
This is the primary search endpoint. Search by MPN, DigiKey part number, description, or keywords.
Request body:
json
{
  "Keywords": "GRM155R71C104KA88D",
  "Limit": 25,
  "Offset": 0,
  "FilterOptionsRequest": {
    "MinimumQuantityAvailable": 1,
    "SearchOptions": ["InStock", "HasDatasheet", "RoHSCompliant"],
    "ManufacturerFilter": [{"Id": "..."}],
    "CategoryFilter": [{"Id": "..."}],
    "StatusFilter": [{"Id": "..."}],
    "MarketPlaceFilter": "ExcludeMarketPlace"
  },
  "SortOptions": {
    "Field": "Price",
    "SortOrder": "Ascending"
  }
}
Key request fields:
  • Keywords
    (string, max 250 chars) — search term (MPN, DK PN, description)
  • Limit
    (int, 1-50) — results per page
  • Offset
    (int) — pagination offset
  • SearchOptions
    — array of:
    InStock
    ,
    HasDatasheet
    ,
    RoHSCompliant
    ,
    NormallyStocking
    ,
    Has3DModel
    ,
    HasCadModel
    ,
    HasProductPhoto
    ,
    NewProduct
  • SortOptions.Field
    Price
    ,
    QuantityAvailable
    ,
    Manufacturer
    ,
    ManufacturerProductNumber
    ,
    DigiKeyProductNumber
    ,
    MinimumQuantity
  • MarketPlaceFilter
    NoFilter
    ,
    ExcludeMarketPlace
    ,
    MarketPlaceOnly
Response — key fields in each
Products[]
item:
json
{
  "ManufacturerProductNumber": "GRM155R71C104KA88D",
  "Manufacturer": {"Id": 563, "Name": "Murata Electronics"},
  "Description": {
    "ProductDescription": "CAP CER 100NF 16V X7R 0402",
    "DetailedDescription": "..."
  },
  "UnitPrice": 0.01,
  "QuantityAvailable": 248000,
  "ProductUrl": "https://www.digikey.com/...",
  "DatasheetUrl": "https://...",
  "PhotoUrl": "https://...",
  "ProductVariations": [
    {
      "DigiKeyProductNumber": "490-10698-1-ND",
      "PackageType": {"Name": "Cut Tape"},
      "StandardPricing": [
        {"BreakQuantity": 1, "UnitPrice": 0.01, "TotalPrice": 0.01},
        {"BreakQuantity": 10, "UnitPrice": 0.008, "TotalPrice": 0.08}
      ],
      "QuantityAvailableforPackageType": 248000,
      "MinimumOrderQuantity": 1,
      "StandardPackage": 10000
    }
  ],
  "Parameters": [
    {"ParameterText": "Capacitance", "ValueText": "100nF"},
    {"ParameterText": "Voltage Rated", "ValueText": "16V"},
    {"ParameterText": "Temperature Coefficient", "ValueText": "X7R"},
    {"ParameterText": "Package / Case", "ValueText": "0402 (1005 Metric)"}
  ],
  "ProductStatus": {"Status": "Active"},
  "Category": {"Name": "Ceramic Capacitors"},
  "Classifications": {"RohsStatus": "ROHS3 Compliant"},
  "Discontinued": false,
  "EndOfLife": false,
  "NormallyStocking": true
}
POST /products/v4/search/keyword
这是主要的搜索端点。通过MPN、DigiKey零件编号、描述或关键词进行搜索。
请求体:
json
{
  "Keywords": "GRM155R71C104KA88D",
  "Limit": 25,
  "Offset": 0,
  "FilterOptionsRequest": {
    "MinimumQuantityAvailable": 1,
    "SearchOptions": ["InStock", "HasDatasheet", "RoHSCompliant"],
    "ManufacturerFilter": [{"Id": "..."}],
    "CategoryFilter": [{"Id": "..."}],
    "StatusFilter": [{"Id": "..."}],
    "MarketPlaceFilter": "ExcludeMarketPlace"
  },
  "SortOptions": {
    "Field": "Price",
    "SortOrder": "Ascending"
  }
}
关键请求字段:
  • Keywords
    (字符串,最多250字符)——搜索词(MPN、DK零件编号、描述)
  • Limit
    (整数,1-50)——每页结果数
  • Offset
    (整数)——分页偏移量
  • SearchOptions
    ——可选值数组:
    InStock
    HasDatasheet
    RoHSCompliant
    NormallyStocking
    Has3DModel
    HasCadModel
    HasProductPhoto
    NewProduct
  • SortOptions.Field
    ——可选值:
    Price
    QuantityAvailable
    Manufacturer
    ManufacturerProductNumber
    DigiKeyProductNumber
    MinimumQuantity
  • MarketPlaceFilter
    ——可选值:
    NoFilter
    ExcludeMarketPlace
    MarketPlaceOnly
响应——每个
Products[]
项中的关键字段:
json
{
  "ManufacturerProductNumber": "GRM155R71C104KA88D",
  "Manufacturer": {"Id": 563, "Name": "Murata Electronics"},
  "Description": {
    "ProductDescription": "CAP CER 100NF 16V X7R 0402",
    "DetailedDescription": "..."
  },
  "UnitPrice": 0.01,
  "QuantityAvailable": 248000,
  "ProductUrl": "https://www.digikey.com/...",
  "DatasheetUrl": "https://...",
  "PhotoUrl": "https://...",
  "ProductVariations": [
    {
      "DigiKeyProductNumber": "490-10698-1-ND",
      "PackageType": {"Name": "Cut Tape"},
      "StandardPricing": [
        {"BreakQuantity": 1, "UnitPrice": 0.01, "TotalPrice": 0.01},
        {"BreakQuantity": 10, "UnitPrice": 0.008, "TotalPrice": 0.08}
      ],
      "QuantityAvailableforPackageType": 248000,
      "MinimumOrderQuantity": 1,
      "StandardPackage": 10000
    }
  ],
  "Parameters": [
    {"ParameterText": "Capacitance", "ValueText": "100nF"},
    {"ParameterText": "Voltage Rated", "ValueText": "16V"},
    {"ParameterText": "Temperature Coefficient", "ValueText": "X7R"},
    {"ParameterText": "Package / Case", "ValueText": "0402 (1005 Metric)"}
  ],
  "ProductStatus": {"Status": "Active"},
  "Category": {"Name": "Ceramic Capacitors"},
  "Classifications": {"RohsStatus": "ROHS3 Compliant"},
  "Discontinued": false,
  "EndOfLife": false,
  "NormallyStocking": true
}

ProductDetails — Full Details for One Part

ProductDetails——单个零件的完整详情

GET /products/v4/search/{productNumber}/productdetails
Use this for expanded information on a specific part.
{productNumber}
can be a DigiKey part number or manufacturer part number.
Query parameters:
  • manufacturerId
    (optional) — disambiguate MPNs that match multiple manufacturers (e.g., "CR2032")
Returns the full
Product
object with all parameters, pricing (including MyPricing if authenticated with account), media links, and related products.
GET /products/v4/search/{productNumber}/productdetails
用于获取特定零件的扩展信息。
{productNumber}
可以是DigiKey零件编号或制造商零件编号。
查询参数:
  • manufacturerId
    (可选)——当MPN匹配多个制造商时(例如“CR2032”),用于区分
返回完整的
Product
对象,包含所有参数、价格(如果使用账户认证则包含MyPricing)、媒体链接和相关产品。

Other Useful Endpoints

其他实用端点

EndpointMethodDescription
/products/v4/search/{pn}/productdetails
GETFull product info for one part
/products/v4/search/productpricing/{pn}
GETPricing with MyPricing for a part
/products/v4/search/{pn}/media
GETAll media (images, datasheets) for a part
/products/v4/search/manufacturers
GETAll manufacturers (use IDs in KeywordSearch filters)
/products/v4/search/categories
GETAll categories (use IDs in KeywordSearch filters)
/products/v4/search/{pn}/alternatepackaging
GETAlternate packaging options
/products/v4/search/{pn}/substitutions
GETSubstitute parts
/products/v4/search/{pn}/recommendedproducts
GETRecommended/associated parts
端点请求方法描述
/products/v4/search/{pn}/productdetails
GET单个零件的完整产品信息
/products/v4/search/productpricing/{pn}
GET零件的价格信息(含MyPricing)
/products/v4/search/{pn}/media
GET零件的所有媒体资源(图片、数据手册)
/products/v4/search/manufacturers
GET所有制造商(用于KeywordSearch过滤器中的ID)
/products/v4/search/categories
GET所有分类(用于KeywordSearch过滤器中的ID)
/products/v4/search/{pn}/alternatepackaging
GET可选封装选项
/products/v4/search/{pn}/substitutions
GET替代零件
/products/v4/search/{pn}/recommendedproducts
GET推荐/关联零件

Rate Limits

速率限制

Per-minute and daily quotas apply. HTTP 429 with
Retry-After
header on exceed.
存在每分钟和每日配额限制。超出限制时会返回HTTP 429响应,并附带
Retry-After
请求头。

Error Responses

错误响应

All errors return
DKProblemDetails
:
json
{"type": "...", "title": "...", "status": 401, "detail": "Invalid token", "correlationId": "..."}
所有错误都会返回
DKProblemDetails
json
{"type": "...", "title": "...", "status": 401, "detail": "Invalid token", "correlationId": "..."}

Fallback: Fetch DigiKey Website

备选方案:抓取DigiKey网站

If API credentials are not available or authentication fails, search DigiKey by fetching product pages directly:
https://www.digikey.com/en/products/result?keywords=<url-encoded-query>
Examples:
  • https://www.digikey.com/en/products/result?keywords=GRM155R71C104KA88D
    (by MPN)
  • https://www.digikey.com/en/products/result?keywords=100nF+0402+X7R+16V
    (by specs)
Results from DigiKey can be noisy (JS-heavy pages). Look for the product table rows containing: DigiKey part number, MPN, description, unit price, stock quantity, and datasheet links. If results are truncated or empty, try searching by exact MPN rather than keywords.
如果API凭证不可用或认证失败,可以直接抓取产品页面来搜索DigiKey:
https://www.digikey.com/en/products/result?keywords=<url-encoded-query>
示例:
  • https://www.digikey.com/en/products/result?keywords=GRM155R71C104KA88D
    (通过MPN搜索)
  • https://www.digikey.com/en/products/result?keywords=100nF+0402+X7R+16V
    (通过规格搜索)
DigiKey的搜索结果可能比较杂乱(页面依赖JS)。需查找包含以下信息的产品表格行:DigiKey零件编号、MPN、描述、单价、库存数量和数据手册链接。如果结果被截断或为空,尝试使用精确MPN而非关键词进行搜索。

Datasheet Download & Analysis

数据手册下载与分析

DigiKey's API provides direct PDF URLs for datasheets — this is the preferred method for downloading datasheets because it avoids web scraping and returns reliable, stable links. Other skills (kicad, bom) should use DigiKey API as the first-choice datasheet source.
DigiKey的API提供直接的PDF URL用于下载数据手册——这是下载数据手册的首选方式,因为它避免了网页抓取,返回的链接可靠且稳定。其他技能(kicad、bom)应优先使用DigiKey API作为数据手册来源。

Datasheet Directory Sync (Primary Workflow)

数据手册目录同步(主要工作流)

Use
sync_datasheets_digikey.py
to maintain a
datasheets/
directory alongside a KiCad project. It extracts components from the schematic, searches DigiKey for datasheet URLs, downloads missing PDFs, and writes an
manifest.json
manifest. Subsequent runs are incremental — only new or changed parts are fetched.
bash
undefined
使用
sync_datasheets_digikey.py
脚本在KiCad项目旁维护一个
datasheets/
目录。它会从原理图中提取元器件,在DigiKey上搜索数据手册URL,下载缺失的PDF,并生成
manifest.json
清单文件。后续运行为增量式——仅获取新零件或已变更的零件。
bash
undefined

Sync datasheets for a KiCad project (creates datasheets/ next to the schematic)

同步KiCad项目的数据手册(在原理图旁创建datasheets/目录)

python3 <skill-path>/scripts/sync_datasheets_digikey.py <file.kicad_sch>
python3 <skill-path>/scripts/sync_datasheets_digikey.py <file.kicad_sch>

Preview what would be downloaded

预览将要下载的内容

python3 <skill-path>/scripts/sync_datasheets_digikey.py <file.kicad_sch> --dry-run
python3 <skill-path>/scripts/sync_datasheets_digikey.py <file.kicad_sch> --dry-run

Retry previously failed downloads

重试之前下载失败的内容

python3 <skill-path>/scripts/sync_datasheets_digikey.py <file.kicad_sch> --force
python3 <skill-path>/scripts/sync_datasheets_digikey.py <file.kicad_sch> --force

Custom output directory

指定自定义输出目录

python3 <skill-path>/scripts/sync_datasheets_digikey.py <file.kicad_sch> -o ./my-datasheets
python3 <skill-path>/scripts/sync_datasheets_digikey.py <file.kicad_sch> -o ./my-datasheets

Use pre-computed analyzer JSON instead of running the analyzer

使用预计算的分析器JSON而非运行分析器

python3 <skill-path>/scripts/sync_datasheets_digikey.py analyzer_output.json
python3 <skill-path>/scripts/sync_datasheets_digikey.py analyzer_output.json

Parallel downloads (3 workers)

并行下载(3个工作进程)

python3 <skill-path>/scripts/sync_datasheets_digikey.py <file.kicad_sch> --parallel 3
python3 <skill-path>/scripts/sync_datasheets_digikey.py <file.kicad_sch> --parallel 3

Batch mode — sync from a plain MPN list (no KiCad project required)

批量模式——从纯MPN列表同步(无需KiCad项目)

python3 <skill-path>/scripts/sync_datasheets_digikey.py --mpn-list mpns.txt --output ./datasheets

**MPN-list batch mode** (KH-312) — when you have a list of MPNs but no KiCad
project to point at (harness datasheet seeding, bulk seeding a new part
library). The file format is one MPN per line. Blank lines and `#`
comments (full-line and inline) are skipped. Non-MPN strings (generic
values like `100nF` or `DNP`) are filtered via `is_real_mpn()` and
de-duplicated. Output defaults to `./datasheets/` in the current working
directory when `--output` is omitted.

The script:
- **Runs the kicad schematic analyzer** automatically to extract components and MPNs
- **Filters generic passives** — skips entries without real MPNs (e.g., "100nF", "10K")
- **Tries schematic URLs first** — uses the datasheet URL embedded in the KiCad symbol before hitting the DigiKey API, saving API calls
- **Writes `manifest.json` manifest** — maps each MPN to its PDF file, manufacturer, description, download status, and URL. The kicad skill reads this during design review to cross-reference datasheets with the schematic.
- **Tracks failures** — failed downloads are recorded with error details and not retried on subsequent runs unless `--force` is used
- **Rate-limited** — 1 second between DigiKey API calls (configurable with `--delay`)
- **Saves progress incrementally** — if interrupted, already-downloaded files are preserved

The `manifest.json` manifest structure:
```json
{
  "schematic": "/path/to/file.kicad_sch",
  "last_sync": "2026-03-09T04:44:30+00:00",
  "parts": {
    "TPS61023DRLR": {
      "file": "TPS61023DRLR.pdf",
      "manufacturer": "Texas Instruments",
      "description": "Boost converter",
      "datasheet_url": "https://...",
      "status": "ok",
      "references": ["U3", "U2"],
      "size_bytes": 2392725
    }
  }
}
python3 <skill-path>/scripts/sync_datasheets_digikey.py --mpn-list mpns.txt --output ./datasheets

**MPN列表批量模式**(KH-312)——当你有MPN列表但没有对应的KiCad项目时(例如批量导入数据手册、为新零件库批量导入)。文件格式为每行一个MPN。空行和`#`注释(整行或行内)会被跳过。非MPN字符串(如`100nF`或`DNP`这类通用值)会通过`is_real_mpn()`过滤并去重。如果省略`--output`参数,默认输出到当前工作目录的`./datasheets/`。

该脚本:
- **自动运行kicad原理图分析器**以提取元器件和MPN
- **过滤通用无源器件**——跳过没有真实MPN的条目(例如“100nF”、“10K”)
- **优先使用原理图中的URL**——先使用KiCad符号中嵌入的数据手册URL,再调用DigiKey API,节省API调用次数
- **生成`manifest.json`清单文件**——将每个MPN映射到对应的PDF文件、制造商、描述、下载状态和URL。kicad技能在设计评审时会读取此文件,将数据手册与原理图进行交叉引用
- **记录失败情况**——下载失败的内容会记录错误详情,后续运行时不会重试,除非使用`--force`参数
- **速率限制**——DigiKey API调用之间间隔1秒(可通过`--delay`参数配置)
- **增量保存进度**——如果中断,已下载的文件会被保留

`manifest.json`清单文件结构:
```json
{
  "schematic": "/path/to/file.kicad_sch",
  "last_sync": "2026-03-09T04:44:30+00:00",
  "parts": {
    "TPS61023DRLR": {
      "file": "TPS61023DRLR.pdf",
      "manufacturer": "Texas Instruments",
      "description": "Boost converter",
      "datasheet_url": "https://...",
      "status": "ok",
      "references": ["U3", "U2"],
      "size_bytes": 2392725
    }
  }
}

Single Datasheet Download

单个数据手册下载

Use
fetch_datasheet_digikey.py
for one-off datasheet downloads. It handles manufacturer-specific quirks automatically.
bash
undefined
使用
fetch_datasheet_digikey.py
脚本进行一次性数据手册下载。它会自动处理制造商特有的兼容问题。
bash
undefined

Search by MPN (uses DigiKey API, requires credentials)

通过MPN搜索(使用DigiKey API,需要凭证)

python3 <skill-path>/scripts/fetch_datasheet_digikey.py --search "TPS61023" -o datasheet.pdf
python3 <skill-path>/scripts/fetch_datasheet_digikey.py --search "TPS61023" -o datasheet.pdf

Direct URL download

直接通过URL下载

python3 <skill-path>/scripts/fetch_datasheet_digikey.py "https://www.ti.com/lit/gpn/tps61023" -o datasheet.pdf
python3 <skill-path>/scripts/fetch_datasheet_digikey.py "https://www.ti.com/lit/gpn/tps61023" -o datasheet.pdf

JSON output for script integration

输出JSON格式用于脚本集成

python3 <skill-path>/scripts/fetch_datasheet_digikey.py --search "ADP1706" --json

The script:
- **OS-agnostic** — uses Python `requests` library (no wget/curl dependency). Falls back to `urllib` if `requests` isn't installed.
- **Normalizes redirect URLs** — DigiKey's `DatasheetUrl` for TI parts points to a JS redirect page; the script extracts the direct PDF link. Also fixes protocol-relative `//mm.digikey.com/...` URLs.
- **Sets proper User-Agent** — many manufacturer sites (Nexperia, Lite-On, STMicro, Molex) block bare `urllib` or `curl` requests but serve PDFs fine with a browser User-Agent
- **Validates PDF headers** — rejects HTML error pages or Cloudflare challenge pages that masquerade as downloads
- **Falls back to alternative sources** — tries known URL patterns for Microchip when the primary URL fails
- **Headless browser fallback** — if `playwright` is installed, automatically uses a headless Chromium browser as a last resort for sites that serve PDFs via JavaScript (Broadcom doc viewer, Espressif download redirects). Intercepts download events and reads response bodies directly.
- **Exit codes**: 0 = success, 1 = download failed, 2 = search/API error
- **Dependencies**:
  - `pip install requests` (strongly recommended; urllib fallback can't handle HTTP/2 sites like analog.com)
  - `pip install playwright && playwright install chromium` (optional; enables headless browser fallback for JS-heavy sites)
python3 <skill-path>/scripts/fetch_datasheet_digikey.py --search "ADP1706" --json

该脚本:
- **跨平台兼容**——使用Python `requests`库(无需依赖wget/curl)。如果未安装`requests`,会回退到`urllib`
- **标准化重定向URL**——TI零件的DigiKey `DatasheetUrl`指向JS重定向页面,脚本会提取直接的PDF链接。同时修复协议相对的`//mm.digikey.com/...` URL
- **设置正确的User-Agent**——许多制造商网站(Nexperia、Lite-On、STMicro、Molex)会阻止裸`urllib`或`curl`请求,但会响应带有浏览器User-Agent的请求
- **验证PDF头**——拒绝伪装成下载文件的HTML错误页面或Cloudflare验证页面
- **备选来源回退**——当主URL失败时,尝试Microchip的已知URL模式
- **无头浏览器回退**——如果安装了`playwright`,会自动使用无头Chromium浏览器作为最后手段,处理通过JS提供PDF的网站(Broadcom文档查看器、Espressif下载重定向)。拦截下载事件并直接读取响应体
- **退出码**:0 = 成功,1 = 下载失败,2 = 搜索/API错误
- **依赖项**:
  - `pip install requests`(强烈推荐;urllib回退无法处理analog.com这类HTTP/2网站)
  - `pip install playwright && playwright install chromium`(可选;为依赖JS的网站启用无头浏览器回退)

Manufacturer Compatibility

制造商兼容性

Tested against 240 components across 8 open-source KiCad projects (96% download success rate, 94% without Playwright):
ManufacturerStatusNotes
TIWorksURL normalization strips JS redirect wrapper
ADI / AnalogWorks
requests
handles HTTP/2 transparently
STMicroWorksRequires User-Agent header
NexperiaWorksRequires User-Agent header
Lite-OnWorksRequires User-Agent header
MolexWorksRequires User-Agent header
RenesasWorksDirect download
ON SemiWorksDirect download
NXPWorksDirect download
Diodes IncWorksDirect download
MicrochipWorksDirect download via API URLs
YAGEO, Samsung, MurataWorksDigiKey-hosted PDFs (
mm.digikey.com
)
BroadcomWorks*Requires Playwright —
docs.broadcom.com
serves PDFs via JS download
EspressifWorks*Requires Playwright — download redirect needs JS execution
LatticeMixedSome URLs require cookies/auth
* Requires
playwright
package — falls back gracefully to user notification if not installed.
已在8个开源KiCad项目的240个元器件上测试(下载成功率96%,未使用Playwright时为94%):
制造商状态说明
TI可用URL标准化会去除JS重定向包装
ADI / Analog可用
requests
会透明处理HTTP/2
STMicro可用需要User-Agent请求头
Nexperia可用需要User-Agent请求头
Lite-On可用需要User-Agent请求头
Molex可用需要User-Agent请求头
Renesas可用直接下载
ON Semi可用直接下载
NXP可用直接下载
Diodes Inc可用直接下载
Microchip可用通过API URL直接下载
YAGEO, Samsung, Murata可用DigiKey托管的PDF(
mm.digikey.com
Broadcom可用*需要Playwright —
docs.broadcom.com
通过JS提供PDF下载
Espressif可用*需要Playwright — 下载重定向需要执行JS
Lattice部分可用部分URL需要Cookie/认证
* 需要安装
playwright
包——如果未安装,会优雅地回退到通知用户。

When Download Fails

下载失败时的处理

If the script or inline download fails (exit code 1), tell the user and provide the URL so they can open it in a real browser. Some manufacturer sites (Lattice, TDK InvenSense) require interactive login, cookies, or CAPTCHA that even a headless browser can't handle. With Playwright installed, Broadcom and Espressif now download automatically.
Example message to the user:
I couldn't download the datasheet for ICE40UP5K-SG48I automatically — Lattice's site requires browser authentication. Here's the direct link: https://www.latticesemi.com/-/media/LatticeSemi/Documents/DataSheets/iCE/FPGA-DS-02008-1-9-iCE40-Ultra-Plus-Family-Data-Sheet.ashx
You can open it in your browser and save it locally, then I can read and analyze it.
The
--json
output always includes the
datasheet_url
field even on failure, so you can extract the URL programmatically.
如果脚本或内置下载失败(退出码1),告知用户并提供URL,以便他们在真实浏览器中打开。部分制造商网站(Lattice、TDK InvenSense)需要交互式登录、Cookie或验证码,即使无头浏览器也无法处理。安装Playwright后,Broadcom和Espressif的下载现在可自动完成。
给用户的示例消息:
我无法自动下载ICE40UP5K-SG48I的数据手册——Lattice的网站需要浏览器认证。以下是直接链接: https://www.latticesemi.com/-/media/LatticeSemi/Documents/DataSheets/iCE/FPGA-DS-02008-1-9-iCE40-Ultra-Plus-Family-Data-Sheet.ashx
你可以在浏览器中打开并保存到本地,之后我可以读取并分析它。
即使下载失败,
--json
输出始终包含
datasheet_url
字段,因此你可以通过编程方式提取该URL。

Manual Download Workflow

手动下载工作流

If the script isn't available or you need to do it inline:
  1. Search for the part using KeywordSearch or ProductDetails
  2. Extract
    DatasheetUrl
    from the API response
  3. Normalize the URL — if it starts with
    //
    , prepend
    https:
    . If it contains
    ti.com/general/docs/suppproductinfo
    , extract the
    gotoUrl
    query parameter.
  4. Download with
    requests
    (Python) or
    wget
    /
    curl
    with a browser User-Agent
  5. Verify it's a PDF: first 4 bytes should be
    %PDF
If the
DatasheetUrl
field is empty or all download methods fail:
  • Provide the URL to the user for manual browser download
  • Try the
    /products/v4/search/{pn}/media
    endpoint for alternative media links
  • Web search as a last resort:
    "<MPN> datasheet filetype:pdf"
如果脚本不可用或需要手动操作:
  1. 使用KeywordSearch或ProductDetails搜索零件
  2. 从API响应中提取
    DatasheetUrl
  3. 标准化URL——如果以
    //
    开头,添加
    https:
    前缀。如果包含
    ti.com/general/docs/suppproductinfo
    ,提取
    gotoUrl
    查询参数。
  4. 使用
    requests
    (Python)或带浏览器User-Agent的
    wget
    /
    curl
    下载
  5. 验证是否为PDF:前4个字节应为
    %PDF
如果
DatasheetUrl
字段为空或所有下载方法都失败:
  • 提供URL给用户手动在浏览器中下载
  • 尝试
    /products/v4/search/{pn}/media
    端点获取备选媒体链接
  • 最后手段:网页搜索
    "<MPN> datasheet filetype:pdf"

What to Extract from Datasheets

从数据手册中提取的内容

When analyzing a datasheet for a KiCad design review (see
kicad
skill):
  • Absolute maximum ratings — voltage, current, temperature limits
  • Recommended operating conditions — typical operating ranges
  • Pinout and pin descriptions — verify against KiCad symbol
  • Package dimensions — verify against KiCad footprint
  • Typical application circuit — compare against the user's schematic
  • Thermal characteristics — θJA, θJC for power dissipation calculations
  • Electrical characteristics — key parameters (Vout, Iq, PSRR, etc.)
当为KiCad设计评审分析数据手册时(见
kicad
技能):
  • 绝对最大额定值——电压、电流、温度限制
  • 推荐工作条件——典型工作范围
  • 引脚定义和引脚描述——与KiCad符号进行验证
  • 封装尺寸——与KiCad封装进行验证
  • 典型应用电路——与用户的原理图进行对比
  • 热特性——θJA、θJC用于功耗计算
  • 电气特性——关键参数(输出电压、静态电流、电源抑制比等)

Tips

提示

  • DigiKey PN suffixes:
    -ND
    standard,
    -1-ND
    cut tape,
    -2-ND
    digi-reel,
    -6-ND
    full reel
  • Use
    ExcludeMarketPlace
    filter to avoid third-party seller listings
  • Price breaks in
    ProductVariations[].StandardPricing[]
    — check
    BreakQuantity
    thresholds
  • Check
    ProductStatus
    and
    Discontinued
    /
    EndOfLife
    before selecting parts
  • DigiKey零件编号后缀:
    -ND
    标准包装,
    -1-ND
    截带包装,
    -2-ND
    Digi-Reel包装,
    -6-ND
    整卷包装
  • 使用
    ExcludeMarketPlace
    过滤器避免第三方卖家列表
  • ProductVariations[].StandardPricing[]
    中的价格阶梯——查看
    BreakQuantity
    阈值
  • 选择零件前检查
    ProductStatus
    Discontinued
    /
    EndOfLife
    状态