Inventory
API Inventory vs octopart.com
Inventory data returned by the API may differ from what you see on octopart.com. There are two reasons for this:
-
Data freshness – The API returns inventory from regularly ingested distributor data feeds. octopart.com uses live distributor data for some distributors, which can reflect more recent stock changes.
-
Country defaulting – octopart.com detects the user's country from their IP address and surfaces region-appropriate offers. The API defaults to US if no
countryparameter is specified. If you are querying for a non-US region, always pass thecountry(and optionallycurrency) parameter explicitly.
Querying Inventory Data
Inventory information is spread across two levels of the response:
-
SupPart– aggregate fieldstotalAvailandavgAvailsummarize stock across all sellers -
SupOffer– theinventoryLevelfield gives the stock quantity for a specific offer from a specific seller
query InventoryCheck {
supSearchMpn(q: "LM358DR", limit: 2) {
results {
part {
mpn
totalAvail
avgAvail
sellers(includeBrokers: false) {
company {
name
}
isAuthorized
offers {
inventoryLevel
updated
}
}
}
}
}
}
The updated field on SupOffer shows when inventory data was last received from the distributor's feed, which can help assess data freshness.
inventoryLevel Special Codes
inventoryLevel normally returns a non-negative integer representing units in stock. When a distributor cannot provide an exact quantity, a negative special code is returned instead:
Code |
Meaning |
|
Non-Stocked – the distributor does not carry this part |
|
Yes – in stock, but no quantity is provided |
|
Unknown – no quantity value was provided, or the value was not a valid integer |
|
RFQ – contact the distributor for a quote |
totalAvail and avgAvail
totalAvail is the sum of stock across all distributors; avgAvail is the average per distributor. Both fields are on SupPart.
Broker stock affects these values in a specific way: if no standard distributors have stock but one or more brokers have inventoryLevel > 0 or inventoryLevel == -2, then totalAvail is set to 1. The broker's actual quantity is never added numerically – only the presence of broker stock is signaled.
This means a totalAvail of 1 with no standard distributor stock is a signal to check broker offers rather than a literal unit count.
To distinguish distributors from brokers in your application, use the isBroker field on SupPartSeller:
sellers(includeBrokers: true) {
company { name }
isAuthorized
isBroker
offers {
inventoryLevel
}
}