See our previous post Inventree Python API: Minimal API connect example using YAML config for our method of creating the api
object using a YAML config file!
from inventree.stock import StockLocation all_stock_locations = StockLocation.list(api) # Dict of part categories by name # (e.g. 'OpAmps') stock_locations_by_name = { category["name"]: category for category in all_stock_locations } # Dict of part categories by public key (e.g. 7) part_locations_by_pk = { category.pk: category for category in all_stock_locations } # Dict of part categories by hierarchical path # (e.g. 'Office/Spart parts box') stock_locations_by_pathstring = { category.pathstring: category for category in all_stock_locations }