Inventory

Inventory API 101: Real-Time Stock Without Overselling

A plain-language guide

"Real-time" gets used loosely enough in inventory software that it's worth being precise about what it should actually guarantee. A stock count that updates within a second of a sale, but can still be read by two systems at once and both told "yes, available", isn't really real-time in the way that matters. It's fast, and still wrong, under the exact conditions where being right matters most.

A genuinely trustworthy inventory API needs two properties together, not one or the other:

1. Every read reflects the current state, not a cached one

If a query can return a cached or slightly-stale count, "real-time" only holds between updates, which is fine until an update happens right before someone reads. A live query against current data, with no regeneration schedule in between, is table stakes for this. See our guide to product feed APIs for why a feed built this way behaves differently from a periodic export in the first place.

2. Every write is atomic

Freshness alone doesn't stop two simultaneous sales from both reading "1 available" a moment before either one commits. That's a race condition, not a staleness problem, and it needs a different fix: an atomic check-and-decrement in one indivisible operation, so two requests for the last unit can't both succeed. Our guide to atomic stock booking covers exactly why this specific guarantee is what actually prevents overselling, where fast-but-non-atomic reads don't.

A quick way to test whether an inventory API actually has both

  1. Set a test product's stock to exactly 1.
  2. Fire two "buy 1" requests against it at the same moment. A small script, or two browser tabs clicking in quick succession, is enough to see the behavior.
  3. Exactly one should succeed. If both can succeed, the "real-time" claim doesn't hold under the one condition it needs to.

Sync latency vs. read correctness: two different things

How often a source system's changes propagate into the product feed (a database sync interval, an import schedule) is a separate question from whether a query against the feed's current data is correct at read time. A feed can sync from its source every 15 minutes and still guarantee that every query and every booking made in between reflects exactly what the feed currently holds. "How fresh is the underlying data" and "is a read/write against it race-free" are different guarantees, and a serious inventory API needs to be honest about both, separately.

How Feedwyre handles this

Every query reads current data with no caching layer in between, and every stock booking goes through one atomic check-and-decrement - the same guarantee whether the request came from your own storefront, a reseller's child feed, or a partner integration. If you're evaluating more than one option, the two-tab test above takes a couple of minutes and tells you more than any spec sheet will.

Run the two-tab test yourself

Free trial, no credit card. Connect a product feed and try to oversell a test product on purpose.

Start free trial