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 country parameter is specified. If you are querying for a non-US region, always pass the country (and optionally currency) parameter explicitly.

Querying Inventory Data

Inventory information is spread across two levels of the response:

  • SupPart – aggregate fields totalAvail and avgAvail summarize stock across all sellers

  • SupOffer – the inventoryLevel field 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

-1

Non-Stocked – the distributor does not carry this part

-2

Yes – in stock, but no quantity is provided

-3

Unknown – no quantity value was provided, or the value was not a valid integer

-4

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
  }
}

 

如您发现任何问题,请选中相关文本/图片,并按 Ctrl + Enter 键向我们提交反馈。
Content