Skip to content

Configuration

0neShot edited this page Sep 9, 2026 · 1 revision

Configuration & API Keys

Once the SmartParts plugin is enabled, all operational settings, distributor credentials, merging priorities, and parameter rules are managed directly within the InvenTree Web UI under Plugin Settings > Smart Parts.


Accessing Plugin Settings

  1. In the InvenTree navigation bar, open the Settings Center (gear icon).
  2. Select Plugin Settings from the sidebar menu.
  3. Click on Smart Parts (smartparts) to open the settings inspector.

📸 TODO (Screenshot): [InvenTree Plugin Settings page displaying the SmartParts configuration panel.]


🔌 Distributor API Credentials

SmartParts connects to five major component distributors. Enable only the suppliers you have accounts or interest in.

1. Mouser Electronics

  • API Service: Mouser Search API v2 (Search By Part Number).
  • Settings:
    • MOUSER_ENABLED (boolean, default: True): Enable or disable Mouser searches.
    • MOUSER_API_KEY (string): 36-character GUID API key.
  • How to Obtain:
    1. Register for an account at Mouser.com.
    2. Apply for a Search API key at Mouser API Hub.

🔑 TODO (Configuration): [Enter your registered Mouser Search API v2 key in MOUSER_API_KEY.]


2. DigiKey

  • API Service: DigiKey Product Information API v4.
  • Authentication: OAuth2 Client Credentials flow (automatic token caching and renewal).
  • Settings:
    • DIGIKEY_ENABLED (boolean, default: True): Enable or disable DigiKey queries.
    • DIGIKEY_CLIENT_ID (string): Production Client ID from DigiKey Developer Portal.
    • DIGIKEY_CLIENT_SECRET (string): Production Client Secret.
  • How to Obtain:
    1. Create an organization account at DigiKey Developer Portal.
    2. Create a Production App subscribed to the Product Information API v4.
    3. Copy your Client ID and Client Secret.

🔑 TODO (Configuration): [Enter your DigiKey DIGIKEY_CLIENT_ID and DIGIKEY_CLIENT_SECRET.]


3. LCSC Electronics

  • API Service: LCSC Electronics Search Service.
  • Authentication: None required (uses public catalog search endpoints).
  • Settings:
    • LCSC_ENABLED (boolean, default: True): Enable or disable LCSC lookup.
  • Operational Notes:
    • SmartParts enforces a minimum request interval of 1.0 second to respect LCSC's public infrastructure.

4. element14 / Farnell / Newark

  • API Service: element14 Product Search REST API.
  • Settings:
    • ELEMENT14_ENABLED (boolean, default: False): Enable or disable element14 lookup.
    • ELEMENT14_API_KEY (string): Global API key.
    • ELEMENT14_STORE (string, default: uk.farnell.com): Regional store endpoint.
  • Supported Storefronts:
    • Europe: uk.farnell.com, de.farnell.com, fr.farnell.com
    • North America: www.newark.com
    • Asia-Pacific: au.element14.com, sg.element14.com, in.element14.com
  • How to Obtain:

🔑 TODO (Configuration): [Enter your element14 API Key and configure ELEMENT14_STORE for your target currency/region.]


5. TME (Transfer Multisort Elektronik)

  • API Service: TME REST API v2.0.
  • Authentication: OAuth2 Client Credentials / Bearer token authentication.
  • Settings:
    • TME_ENABLED (boolean, default: False): Enable or disable TME searches.
    • TME_API_TOKEN (string): TME API Application Token.
    • TME_API_SECRET (string): TME HMAC API Secret.
    • TME_COUNTRY (string, default: DE): Two-letter ISO 3166-1 alpha-2 country code for local inventory and pricing.
    • TME_CURRENCY (string, default: EUR): ISO 4217 currency code (e.g. EUR, USD, GBP, PLN).
  • How to Obtain:

🔑 TODO (Configuration): [Enter your TME API Token, Secret, and target country/currency settings.]


🔀 Multi-Supplier Priority & Merging

When multiple distributors return data for the same MPN, SmartParts merges them into a single record based on:

  • API_PRIORITY (string, default: mouser,digikey,element14,tme,lcsc):
    • Comma-separated list of distributor tokens.
    • First source with a non-empty value wins for core fields (Manufacturer, Description, Datasheet, Image).
    • Technical parameters from all sources are merged and deduplicated.
    • All unique supplier cards and price breaks are preserved.

✍️ TODO (User Input): [Customize API_PRIORITY to prioritize distributors with your preferred pricing contracts.]


🏷️ Category Mapping & Fuzzy Resolution

SmartParts uses a multi-signal token overlap engine to match distributor categories to your internal InvenTree category tree.

Setting Type Default Description
FUZZY_THRESHOLD int 45 Minimum confidence score (0–100) required to auto-select an InvenTree category. Recommended range: 40–55.
DEFAULT_CATEGORY string "Uncategorized" Fallback category name if no category meets the threshold. Leave empty to require manual operator selection.
CATEGORY_SYNONYMS json {} JSON map of distributor terms to InvenTree equivalents. Example: {"MLCC": "Ceramic Capacitor", "MCU": "Microcontroller"}.
LEARNED_CATEGORY_MAPPINGS json {} Automatically populated when an operator manually corrects a category during import. Acts as a 100% confidence override.

⚙️ Parameter Engine & Category Filtering

SmartParts keeps your InvenTree parameter database clean by preventing distributor parameter bloat:

Setting Type Default Description
LIMIT_PARAMETERS_TO_CATEGORY bool True Critical setting. When enabled, only parameters that match an active ParameterTemplate in the chosen category (or its ancestor categories) are saved. Dropped parameters are recorded in an audit trail.
LEARNED_PARAMETER_MAPPINGS json {} JSON dictionary mapping raw distributor parameter names to canonical InvenTree template names. Example: {"ic mounting": "Mounting Type", "capacitance - value": "Capacitance"}.
TRACKED_UNKNOWN_PARAMETERS json {} Automatically populated with unmapped parameter names and frequency counts. Review this to discover candidates for canonical mapping.

Tip

Keep LIMIT_PARAMETERS_TO_CATEGORY=True in production. This ensures your InvenTree parts only receive parameters relevant to their category hierarchy (e.g. Resistors only receive Resistance, Power Rating, and Tolerance, dropping irrelevant distributor noise).


🔄 Duplicate Handling & General Behaviors

Setting Type Default Description
DUPLICATE_ACTION string "ask" Action when an existing part with matching MPN/Manufacturer is found: "ask" (prompt user), "update" (merge new supplier data into existing part), or "skip" (refuse import).
AUTO_CREATE_MANUFACTURERS bool True Automatically create Company records (as Manufacturer) if they do not already exist in InvenTree.
AUTO_CREATE_SUPPLIERS bool True Automatically create Company records (as Supplier) for enabled distributors if missing.
LOG_RETENTION_DAYS int 30 Number of days activity logs are kept before automated rotation.

🖨️ Stock Locations & Label Printing

Setting Type Default Description
DEFAULT_STOCK_LABEL int 0 ID of the InvenTree stock item label template to pre-select for new part stock creation (0 = none).
DEFAULT_PRINT_PLUGIN string "" Slug of the label printer plugin (e.g. "inventreelabelmachine" or "inventree-dymo-plugin").

Next Steps

Clone this wiki locally