Clothing Product Data API: Size and Color Availability

How size and color availability arrives in a clothing product data API, shown on one real jacket across two storefronts, with the gaps to handle and a script that builds a size picker.

Clothing Product Data API: Size and Color Availability

A clothing product data API has to answer one question well: is this color available in my size right now? Product pages that ignore it send readers to items they cannot buy. This article uses the Affiliate.com product search, run on October 28, 2026, to show how size and color availability arrives for clothing, using one women’s rain jacket as the example.

One record per size and color

Clothing is not stored as one product with a list of sizes. Each size and color is its own record, with its own availability, price and barcode. This jacket comes in 5 colors and 6 sizes, so each storefront has 30 records. The search matched 60, because the jacket is sold in both a US and a Canadian storefront.

{
  "search": [
    { "field": "name", "value": "Women's Trinity Rain Jacket", "operator": "LIKE" }
  ],
  "fields": ["name", "color", "size", "availability", "stock_quantity", "final_price", "currency", "identifiers.barcode"],
  "sort_by": "final_price",
  "per_page": 100
}

This is one record, trimmed to the fields that matter for availability.

{
  "name": "Women's Trinity Rain Jacket - Grey",
  "color": "Grey",
  "size": "Size: XL",
  "availability": "OutOfStock",
  "stock_quantity": null,
  "final_price": 290,
  "currency": "CAD",
  "identifiers": { "barcode": "805080060490" }
}

For a fuller walkthrough of searching clothing by brand, color and size, see the earlier post on searching clothing across retailers.

Size and color availability, side by side

Here is the Canadian storefront as a grid. “Out” means the record is marked OutOfStock.

ColorXSSMLXLXXL
BlackInInInInInIn
GreyInInInOutOutOut
MoonstoneInInInInInIn
Dark TeakInInInInInIn
Dark MossInInInOutOutOut
  • 24 of the 30 records are in stock. All six that are not belong to two colors, Grey and Dark Moss, and are the three largest sizes (L, XL and XXL).
  • The US storefront is nearly complete. 29 of 30 are in stock, and the only gap is Dark Moss in XXL.
  • The same jacket, two different answers. A reader in Canada who wears an XL cannot buy Grey or Dark Moss, while the same sizes are available in the US storefront.

Three things that need handling

  • Size labels differ by storefront. The US records say “L” and the Canadian ones say “Size: L”. Normalize the label before comparing or displaying sizes.
  • The barcodes match across storefronts. Each size and color carries the same barcode in both, so barcode search can line them up.
  • There is no stock count here. The stock_quantity field was empty on all 60 records. Availability is only InStock or OutOfStock, so a page cannot say “only 2 left” from this data.

Turning availability into a size picker

The script below builds the grid from a list of records and returns the sizes a page should offer for one color.

const ORDER = ['XS', 'S', 'M', 'L', 'XL', 'XXL'];

function availabilityGrid(records) {
  const grid = {};
  for (const r of records) {
    const size = r.size.replace(/^Size:\s*/i, '').trim(); // "Size: L" and "L" both become "L"
    grid[r.color] ??= {};
    grid[r.color][size] = r.availability === 'InStock';
  }
  return grid;
}

function sizesToShow(grid, color) {
  return ORDER.filter(size => grid[color]?.[size]);
}

Run on the Canadian records, sizesToShow(grid, 'Grey') returns XS, S and M. For Dark Moss it also returns XS, S and M, and for Black all six sizes. On the US records Dark Moss returns XS through XL. A size picker built this way never offers an item that is marked out of stock.

Things to keep in mind

  • Availability changes. This is a snapshot from one day, so a live page should read the record when it loads. The post on showing only the sizes that are actually in stock covers that in more depth.
  • Prices follow the storefront. This jacket is 240 in USD and 290 in CAD. Use the currency filter so readers see prices in their own currency.
  • Check one product, then scale up. Trying the grid on a single product, as above, is a quick way to test how a retailer labels its sizes before building a page around it.

The short version: clothing availability is a size-by-color grid, and a page that reads it can show readers only the combinations they can actually buy.