Amazon Selling Partner API model

Inventory health

and how much of it is dead.

Grain
seller x marketplace x SKU
Built from
  1. 5
    Raw tables
  2. 6
    Staging
  3. 2
    Core
  4. 1
    Analytics
Reads from Amazon Selling Partner API
fba_inventory_summaryfba_returns_reportmerchant_listings_reportorders_by_last_updated_date_reportreturns_by_return_date_report
Ships as
Weld and dbt SQL, open source on GitHub
core.amazon_seller.inventory_health
1-- amazon_seller_inventory_health - what is in Amazon's warehouses, how long it lasts,
2-- and how much of it is dead.
3--
4-- Grain: seller x marketplace x SKU. Point in time - see the note below.
5-- Depends on: staging.amazon_seller.fba_inventory, .listings,
6--             core.amazon_seller.product_sales_over_time
7--
8-- POINT IN TIME, NOT A TIME SERIES. The FBA inventory report is a snapshot and Amazon
9-- does not retain yesterday's, so this model describes now. It carries no date column
10-- for that reason: a date would imply history that does not exist, and someone would
11-- eventually GROUP BY it. To trend cover or ageing, enable Weld history tables on the
12-- fba_inventory_summary stream and build the equivalent over
13-- `fba_inventory_summary__history` - there is no way to reconstruct it later.
14--
15-- The velocity window is the last 30 days of SALE rows. Short enough to reflect
16-- current demand, long enough to survive a slow week. For seasonal catalogues, 30
17-- days across a seasonal boundary will mislead - widen it or compare against the same
18-- weeks last year.
19
20WITH velocity AS (
21    SELECT
22        amazon_seller,
23        marketplace,
24        sku,
25        SUM(quantity)                              AS units_30d,
26        SAFE_DIVIDE(SUM(quantity), 30.0)           AS units_per_day
27    FROM {{core.amazon_seller.product_sales_over_time}}
28    WHERE report_row_type = 'SALE'
29      AND date >= DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY)
30    GROUP BY 1, 2, 3
31)
32
33SELECT
34    i.amazon_seller,
35    i.marketplace,
36    i.sku,
37    i.asin,
38    i.fnsku,
39    COALESCE(l.product_name, i.product_name) AS product_name,
40    l.listing_status,

This model and the 8 it depends on. Deploy them together; refs like {{staging.…}} resolve to the matching folders in Weld, and the dbt view uses source() and ref().

Notes

How it counts. And where it stops.

POINT IN TIME, NOT A TIME SERIES. The FBA inventory report is a snapshot and Amazon does not retain yesterday's, so this model describes now. It carries no date column for that reason: a date would imply history that does not exist, and someone would eventually GROUP BY it. To trend cover or ageing, enable Weld history tables on the fba_inventory_summary stream and build the equivalent over `fba_inventory_summary__history` - there is no way to reconstruct it later. The velocity window is the last 30 days of SALE rows. Short enough to reflect current demand, long enough to survive a slow week. For seasonal catalogues, 30 days across a seasonal boundary will mislead - widen it or compare against the same weeks last year.

Raw tables it reads

  • raw.amazon_seller_central.fba_inventory_summary
  • raw.amazon_seller_central.fba_returns_report
  • raw.amazon_seller_central.merchant_listings_report
  • raw.amazon_seller_central.orders_by_last_updated_date_report
  • raw.amazon_seller_central.returns_by_return_date_report

Put Amazon Selling Partner API in front
of your agents.

Connect Amazon Selling Partner API, deploy the models, and ask questions in Claude, Cursor or ChatGPT. Free for 14 days, no credit card.