Read live stock
const url = 'https://api.ebitex.io/commerce/delivery/v1/stock';const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url https://api.ebitex.io/commerce/delivery/v1/stock \ --header 'Authorization: Bearer <token>'Reads live stock for 1 to 50 SKUs (keys=TR-40,TR-41; a SKU is matched without regard to case and returned in upper case) as { items, missing }. Each item is { sku, status, available }; missing lists the SKUs that are not available to this key.
This route is never cached (Cache-Control: private, no-store, no ETag), so it is the authority to confirm against before you take an order; the product routes’ availability is for display. Because it reads the database on every call it has its own, tighter budget: a tenth of the key’s requests per minute.
available is the units available now (on hand minus those held by checkouts, never below zero). It is present only for a counted variant and only when the key may see counts: a server key always may; a browser-safe key may only if the store’s Show stock quantities setting is on, which it is not by default, because a browser-safe key is embedded in a web page and anyone who loads the page can read what it is told. When it is not allowed, available is absent, not null, in every item.
A key reads one store. It sees only the products that store lists and that are active, and for each product only its active variants. A draft, an archived or an unlisted product answers exactly as a product that does not exist, so a key cannot learn that one is there.
Key: a Commerce delivery key (commerce.delivery.read), minted for one store in Commerce. A key with an origin or IP restriction is browser-safe: it reads the same catalogue, but is told exact stock counts only if the store allows it.
Authorizations
Section titled “Authorizations”Responses
Section titled “ Responses ”OK
invalid_keys: no SKU, more than 50, or an empty one.
missing_api_key or invalid_api_key: no key was sent, or it is unknown, revoked or expired, or its store binding was removed.
payment_required: the organization’s subscription needs attention.
scope_denied: the key lacks commerce.delivery.read. app_not_available: Commerce is not enabled for the organization. origin_denied or ip_denied: the key was used from an origin or address outside its restrictions.
rate_limited: the key spent its stock budget; Retry-After says how long to wait.
rate_limited: the key spent its requests-per-minute budget; Retry-After says how long to wait. too_many_failed_authentications: too many bad keys from this address.