Skip to main content

pypi python mit

InvenTree Part Import

This project offers a command line interface to easily import parts from suppliers like DigiKey, LCSC, Mouser, etc. into your InvenTree instance.

Installation

pipx install inventree-part-import

(pip should also work, but pipx is the new recommended way to install standalone applications)

Arch Linux

Latest version from PyPI is available on AUR as python-inventree-part-import.
Git master version is available as python-inventree-part-import-git.
(Thanks to @randrej!)

Getting Started

Initial Configuration

When using the CLI tool for the first time, it will guide you through creating your own configuration.

When configuring suppliers, it's highly recommended to always enable the DigiKey API:

select the suppliers you want to setup: (SPACEBAR to toggle, ENTER to confirm)
> [x] DigiKey
  [ ] LCSC
  [ ] Mouser
  [ ] Reichelt
  [ ] TME

Default categories/parameters configuration

setup default categories/parameters configuration:
> Copy categories from InvenTree
  Copy default categories configuration
  Create empty configuration (manual setup)

If you have already been using InvenTree for some time (so you already have setup your category structure, parts, etc.), select the Copy categories from InvenTree option, to automatically setup a configuration which matches your InvenTree database.

If you are a new user, you can select the Copy default categories configuration to create a basic configuration which you can extend in the future.

You can also create your own configuration from scratch (or manually copy someones existing configuration ) by selecting the Create empty configuration (manual setup) option.

Basic Usage

To import parts, simply use the inventree-part-import command, followed by the supplier or manufacturer part numbers of the parts you want to import.

$ inventree-part-import <part_number_1> <part_number_2> ...

You can also batch import multiple parts from tabular data files (.csv, .xlsx, etc.) like so:

$ inventree-part-import parts.csv

Configuration

inventree.yaml

This file is used to configure authentication to your InvenTree host. It has two parameters:

  • host: the host url to connect to (including port, if required)
  • token: the user token to authenticate with (this will be retrieved automatically by the CLI)

config.yaml

This file is used to configure general settings of the CLI tool, as well as default locales. The following parameters have to be set:

  • currency: the default currency to use when searching suppliers (ISO4217 code)
  • language: the default language to use when searching suppliers (ISO639 code)
  • location: the default location to use when searching suppliers (ISO3166 code)
  • scrape: whether or not web page scraping is allowed (this can get you temporarily blocked)
  • interactive_part_matches: the maximum number of parts to display in interactive mode (set to null to disable)
  • interactive_category_matches: the maximum number of categories to display in interactive mode
  • interactive_parameter_matches: the maximum number of parameters to display in interactive mode
  • part_selection_format: standard python format str used to format each line of the interactive part selection menu (any fields from the ApiPart dataclass can be used, defaults to: "{MPN} | {manufacturer} | {SKU} | {supplier_link}")
  • auto_detect_columns: list of column names in tabular data files that will be automatically detected (defaults to ["Manufacturer Part Number", "MPN", "part_id"])

suppliers.yaml

This file is used to configure supplier specific behavior. The following parameters are always available:

  • currency: overrides the currency for searching this supplier (see config.yaml)
  • language: overrides the language for searching this supplier (see config.yaml)
  • location: overrides the location for searching this supplier (see config.yaml)

Additionally suppliers can have extra parameters for authentifcation to their respective APIs. These can be set via the CLI like so: inventree-part-import --configure <supplier>.

DigiKey

Register a Production App on the Digikey API portal and enable the "ProductInformation V4" API for it.

Using a Sandbox app will not work.

Mouser

Request a Search API key from the Mouser API Hub.

TME

Request an API key at the Developers Page.

categories.yaml

This file should specify all your InvenTree categories, as well as metadata like category aliases, parameters, etc. for them.

It's defined as hierarchical tree structure where every 'node' represents a category. For example:

Electronics:
    Capacitors:
        Ceramic:
        Electrolytic:
Products:

Additionally you can define the following meta attributes (starting with _):

  • _aliases has to be a list of supplier category names which will be mapped to that category
  • _description specifies the categories description (defaults to category name)
  • _ignore makes inventree-part-import ignore that category, as well as any subcategories
  • _parameters has to be a list of parameter names (for parameters defined in parameters.yaml) this category uses
    note: parameters get inherited by sub categories
  • _omit_parameters has to be a list of parameters names defined in parent categories that get omitted from the category note: this is disfunctional in InvenTree >= 1.2.0 as parameter inheritance happens directly in InvenTree
  • _structural can be set to true to make the category structural

Here's an example for a config with special attributes:

Electronics:
    _description: Electronic Components # custom description
    _structural: true # no parts are allowed to be directly in this category
    Capacitors:
        _parameters: # parameters for both the 'Ceramic' and 'Electrolytic' categories
            - Capacitance
            - Tolerance
        Ceramic:
        Electrolytic:
            _aliases: # category names mapped to this category from various suppliers
                - Aluminum Electrolytic Capacitors
                - Aluminum Electrolytic Capacitors - SMD
                - Aluminum Electrolytic Capacitors - Leaded
                - Electrolyte Capacitors
Products:
    _ignore: true # this category contains our own products, so we won't import anything into it

parameters.yaml

This file should specify all your InvenTree parameters, as well as metadata for them.

The following meta attributes are available:

  • _aliases has to be a list of supplier parameter names which will be mapped to that parameter
  • _description specifies the parameters description (defaults to parameter name)
  • _unit specifies the parameters unit (experimental)

Here's an example for a single parameter:

Input Voltage:
    _aliases:
        - Voltage - Input
        - Voltage - Input (Max)
        - Maximum Input Voltage
    _description: Max Input Voltage # optional
    _unit: V # experimental, this can lead to import problems

Pre Creation Hooks (hooks.py)

Pre creation hooks are functions that get run after part information has been parsed from a supplier, but before the InvenTree part gets created. They basically let you modify a part, before it gets imported. This can be very useful in some cases.

For example, here's one that assigns transistors into different categories, based on their type:

def fix_transistor_categories(api_part):
    if "BJT" in api_part.category_path[-1] or "Bipolar (BJT)" in api_part.category_path:
        transistor_type = api_part.parameters.get("Transistor Type", "")
        if "NPN" in transistor_type:
            api_part.category_path.append("NPN")
        elif "PNP" in transistor_type:
            api_part.category_path.append("PNP")

You can define any number of them in a hooks.py file in your configuration directory. They'll get called in the order they're defined in.

For more examples, checkout my config repository.

Goal

The end goal of this project is to not exist anymore in it's current form. Ideally everything the CLI tool does would be directly available from the InvenTree web interface. This will most likely be done by implementing plugins which offer the required functionality for each supplier.

Credits

  • InvenTree (@SchrodingersGat and @matmair) This project wouldn't exist without their brilliant work on creating the awesome open-source inventory management solution.

  • Ki-nTree (@eeintech) This project is inspired by Ki-nTree and aims to fix most of the issues I've had with it. It only provides the part importing functionality, but tries to improve it in every way.

  • Thanks to @atanisoft for extensive beta testing!

License

  • This project is licensed under the MIT license.

Metadata

Release files for inventree-part-import 1.9.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for inventree-part-import 1.9.2
File Size Uploaded Provenance Actions
inventree_part_import-1.9.2.tar.gz 85.2 kB With provenance Details for inventree_part_import-1.9.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for inventree-part-import 1.9.2
File Interpreter ABI Platform Actions
inventree_part_import-1.9.2-py3-none-any.whl Python 3 none any Details for inventree_part_import-1.9.2-py3-none-any.whl

Total release size: 132.1 kB

Release files / inventree_part_import-1.9.2.tar.gz

Download URL inventree_part_import-1.9.2.tar.gz
Size 85.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a48c3c7790aff21a0fe41b78c9d52d4624a69245ede161398460c6cca2e1a23f
BLAKE2b-256 checksum
How to use checksums
fe68bcedfe9431faf09cd98ad3028ed561f74fe4cf704ebebdc507bc6430571f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 17, 2026.

Transparency log

Release files / inventree_part_import-1.9.2-py3-none-any.whl

Download URL inventree_part_import-1.9.2-py3-none-any.whl
Size 46.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d2dafa6746711cdefb2c00b5b4cb8599cc3b51cac1e5fa2e3adb062d859c5a23
BLAKE2b-256 checksum
How to use checksums
60f7b9558c66f2cb0ffd95bf07d96b09b628f0b201d7e2a8a6e99a941b36968c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 17, 2026.

Transparency log

Security for inventree-part-import 1.9.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for inventree_part_import-1.9.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page