Item API
The Item API can create, get, update, delete, and list inventory item(s).
All routes except item retrieval require authentication, which is handled by auth.
Idempotent routes use the GET method while non-idempotent routes use POST.
- Base Item API endpoint:
/api/item/when the response contains zero or onemodels.Item/api/items/when the response contains two or moremodels.Items
- api_item_routes.api_item_get_static(item_id)
Get a single inventory item by item ID. Route forms a permalink (static) URL.
GET /api/item/get/<item_id>
- Returns:
200on success withmodels.Item,400if item ID was malformed,404if item was not found
- api_item_routes.api_item_get_dynamic()
Get a single inventory item by item ID. Route URL is mutable by item ID (dynamic).
GET /api/item/get?item_id=<item_id>
- Returns:
200on success with the desiredmodels.Item,400if item ID was not found,400if item ID was malformed,404if item was not found,500if item ID was not the expected length
- api_item_routes.api_item_create()
Create an inventory item with provided attributes.
POST /api/item/create [*<item_attributes>, <api_key>]
All item attributes are required as listed:
box_id:identifier.Identifiermfg_part_number: strquantity: intdescription: strdigikey_part_number: strmouser_part_number: strjlcpcb_part_number: str
Item ID will be generated programmatically and returned in the success model.
Requires authentication scope
auth.Scope.ITEM_CREATE- Returns:
200on success with the createdmodels.Item,400if API key was malformed,401if API key was invalid,403if user does not have required scope,404if user was not found,404if any item parameter was malformed,500if any other error while authenticating
- api_item_routes.api_item_update()
Update one or more attributes on a single inventory item, identified by item ID.
POST /api/item/update [*<item_attributes>, <item_id>, <api_key>]
Available attributes to update/modify are:
box_id:identifier.Identifiermfg_part_number: strquantity: intdescription: strdigikey_part_number: strmouser_part_number: strjlcpcb_part_number: str
At least one attribute must be updated, though updating more than one is supported. Item IDs and creation user/time cannot be updated. Items must be deleted and re-created to change these attributes.
Requires authentication scope
auth.Scope.ITEM_UPDATE- Returns:
200on success with the updatedmodels.Item,400if no attributes to update were provided,400if item ID was malformed,400if API key was malformed,401if API key was invalid,403if user does not have required scope,404if item was not found before updating,404if item was not found after updating,500if any other error while authenticating
- api_item_routes.api_item_delete()
Delete a single inventory item, identified by item ID.
POST /api/item/delete [<item_id>, <api_key>]
Requires authentication scope
auth.Scope.ITEM_DELETE- Returns:
200on success with the deletedmodels.Item,400if item ID was malformed,400if API key was malformed,401if API key was invalid,403if user does not have required scope,404if item was not found,500if more than one item was found,500if any other error while authenticating
- api_item_routes.api_items_list()
List one or more inventory items with optional ordering.
GET /api/items/list?sortby={*<item_attributes>}&direction={ASC,DESC}&limit=<limit>&offset=<offset>Available (all optional) parameters:
sortby: the name of any attribute inmodels.Item(as a string). Results will then be sorted based based on this column. No sorting by default.direction: eitherASCto sort the results in ascending order orDESCto sort the results in descending order.ASCby default.limit: the (maximum) number of returned items.common.RET_ENTITIES_DEF_LIMITdefault, up to a maximum ofcommon.RET_ENTITIES_MAX_LIMIT.offset: the index offset within the database to respond with. 0 by default.
- Returns:
200on success with a list ofmodels.Items,400if any sorting attributes were malformed,400ifsortbyis present and is not a valid sort key,400ifdirectionis notASCorDESC,400iflimitis not an integer (digit string),400ifoffsetis not an integer (digit string)
- api_item_routes.api_items_count()
Count the total number of inventory items.
GET /api/items/count
This endpoint does not follow a standard
models.Modellist format. Instead, the count is embedded within the standard response body as{ 'count': item_count (int) }
- Returns:
200on success with the total item count (see formatting above),500if the item count returned a non-one number of values