Component Search Engine Integration - bglen/wire-harness-core GitHub Wiki
Below is a rough outline of how these features might be implemented:
๐ฆ External Parts Search Integration Guide
Integrate real-time electronic parts search and import features into your wire harness design tool. This feature enables users to find and add manufacturer-verified parts directly to the internal library.wh_lib
component database.
๐ฏ Goals
- Search: Enable part lookup via keywords, MPN, or category.
- Preview: Display real-time part data (image, specs, pricing, etc.).
- Import: Let users import part metadata into your library structure.
- Maintain: Support multiple sources with fallback and rate limiting.
๐ Data Source APIs
Octopart API
- URL:
https://octopart.com/api/v4/
- Auth: API key (free tier available)
- Features: Rich metadata, pricing, distributor links, datasheets
- Docs: https://octopart.com/api/
Findchips API
- URL:
https://findchips.com/api/
- Auth: API key
- Features: Pricing aggregation, stock info
- Docs: https://findchips.com/api/
Digi-Key API
- URL: https://developer.digikey.com/
- Auth: OAuth2 (requires approval)
- Features: Search, pricing, datasheets
- free tier allows 1000 searches / day
Mouser API
- URL: https://api.mouser.com/
- Auth: API key
- Features: Part search and detail lookup
๐ Backend Proxy Architecture
Avoid exposing API keys to the frontend by routing all external API calls through a backend proxy.
Example Node.js (Express) Route
app.get('/api/parts-search', async (req, res) => {
const { query } = req.query;
const response = await fetch(`https://octopart.com/api/v4/parts/search?q=${query}&apikey=YOUR_KEY`);
const data = await response.json();
res.json(data);
});
Proxy Server Responsibilities
- Handle API authentication (keys, OAuth)
- Rate limit and cache requests
- Normalize results from multiple sources
๐ง Frontend Integration
UI Components
- Search Input: Keyword or MPN with debounce
- Result Panel: Shows name, MPN, manufacturer, preview image, specs, pricing, datasheet
- Import Button: Maps selected part into
library.wh_lib
Example Component Import Format
{
"type": "connector_shell",
"mpn": "TE-282834-2",
"manufacturer": "TE Connectivity",
"name": "Superseal 2 Position",
"datasheet": "https://www.te.com/...pdf",
"footprint": "2pos_superseal.stp",
"price": {
"1": 0.93,
"100": 0.74
},
"distributors": {
"digikey": "https://www.digikey.com/en/products/detail/.../123456",
"mouser": "https://www.mouser.com/ProductDetail/.../654321"
}
}
library.wh_lib
๐ Mapping to Create a part mapping module that translates external part data into your internal component schema. Fields may include:
mpn
,manufacturer
,description
component_type
(e.g., terminal, connector, shell)package
,footprint
,library_name
datasheet_url
,distributor_links
price_tiers
,available_stock
๐งช Optional Enhancements
- ๐ Recent Search History
- โญ Favorite Parts / Preferred Distributors
- ๐ต Price Comparison Table
- ๐ Attach STEP / footprint files
- ๐ง Auto-category detection (via Octopart taxonomy)
โ ๏ธ Implementation Notes
- Caching: Store common lookups (e.g. Redis, localStorage)
- Rate Limiting: Use throttling on both client and server
- Error Handling: Fallback gracefully across APIs
- Licensing: Ensure TOS compliance for each API
โ Summary Workflow
- User searches for part
- Backend fetches data from Octopart / Mouser / etc.
- Frontend displays parts with import preview
- User clicks "Import" โ component added to
library.wh_lib