Add resale prices to inventory software by barcode

Inventory software for sneaker stock starts from the barcode on the box. This example shows how one API call turns that barcode into a style code, a size and the resale prices for that size. It is written for developers who build the software.

Last checked:

Why start from the barcode

Each size of a colourway has its own barcode. A style code alone does not tell you which size is in the box. Without the barcode, your software needs a size table, or a person must type the size.

The barcode endpoint does the join. It finds the style code and size of the barcode in the Barcodes.gg catalogue, then returns the prices for that size from each marketplace. The catalogue holds 3.09 million barcodes, each stored with its size.

Scan a barcode, get the size and its prices

This Node.js 18 script takes a barcode as its argument:

// scan-price.mjs: node scan-price.mjs <barcode>
const barcode = process.argv[2];
const res = await fetch(`https://barcodes.gg/api/v2/prices/barcode/${barcode}`, {
  headers: { Authorization: `Bearer ${process.env.BARCODES_TOKEN}` },
});
const body = await res.json();
if (!res.ok || body.error) {
  console.error(body.message ?? `HTTP ${res.status}`);
  process.exit(1);
}

const { style_code, barcode_size, is_stale, sites } = body.results;
console.log(style_code, barcode_size, is_stale ? "(newest price older than 24 h)" : "");
for (const site of sites) {
  for (const size of site.sizes) {
    console.log(`${site.site} ${site.market ?? ""}: ${size.price ?? "no ask"} ${site.currency}, as of ${size.as_of}`);
  }
}

The barcode must have 8 to 14 digits. Check the check digit of scanner input before the request, so a misread code does not use a network round trip. The barcode validation tool shows the method.

What to store

  • Store as_of with each price. Show the age of a price next to it, so a user can judge it.
  • Keep the currency and market. StockX rows carry a market such as EU, and sites answer in different currencies. Do not mix them in one number.
  • Refresh on demand. Request prices when a user opens or lists an item. One answered request uses one call, and a product without cached prices is not charged.
  • Use the style code endpoint for size runs. To price every size of a product, call /api/v2/prices/{style_code} once.

Product data from the same token

The same plan includes the barcode lookup API. It returns the product name, brand, colourway, image and size for a barcode. Inventory software can fill the item record and price it with two calls. The endpoints are on the barcode lookup API page.

If you want a finished reseller app and not an API, restock.gg is a reseller app from the same owner.

Get resale prices by API

Resale prices are on Standard (€49 per month) and higher plans. One answered request uses one call. A product without cached prices is not charged.

Guides

StockX, GOAT and Alias are trademarks of their owners. Barcodes.gg is not affiliated with them.