Blog / Web data by industry

Grocery Price Data from Five Stores as JSON

A grocery price API returns a store's products with their prices as JSON, so you can compare a basket across stores or track it week by week without scraping five sites. Perceptlayer has search endpoints for Kroger, Whole Foods, Trader Joe's, Sprouts and Costco at 1 credit per successful call, and each returns a page of products for a query. The stores don't return the same fields: some give a regular and a sale price, some a unit price, some stock. This guide shows the requests, compares the recorded fields and prices a weekly basket.

What is grocery price data good for?

Grocery price data answers three kinds of questions: what a fixed basket costs and how that changes (a price index), which store is cheaper for the same items (a basket comparison), and when and how deep discounts run (promotion tracking). Each needs a slightly different set of fields, and the five stores cover them unevenly, so it helps to know which store gives you what before you design the job.

A price index needs the same products every week, a stable product key and, ideally, a unit price so pack-size changes don't distort it. A basket comparison needs unit prices or sizes, because a 64 oz carton and a half-gallon carton only compare per ounce. Promotion tracking needs the regular price next to the current one, plus an end date where a store gives one. Kroger's response carries all three; Trader Joe's carries a unit price but, in the recording, no regular-versus-sale pair.

If your interest is a single retailer's prices over time rather than grocery specifically, Price Monitoring Tool: Build One on Product APIs covers the storage and alerting side.

Which fields does each store return?

The five recorded searches return different shapes, and this table lists what each one carries for price, promotion, unit price, stock and product key. Everything in it comes from the recorded responses below. The Costco recording is a search for laptop, not a grocery item, so check its fields on a grocery query in the playground before you rely on them.

Field Kroger Whole Foods Trader Joe's Sprouts Costco
Product key id, upc id sku id, product_id, upc id, model
Current price price price price price price.delivery_min, price.delivery_max
Regular price regular_price regular_price none recorded regular_price price.original
Sale flag or price sale_price, sale_ends on_sale none recorded sale_price, on_sale promotions[].short_text
Unit price unit_price, unit, unit_price_text none recorded unit_price, unit_price_unit unit_price.amount, unit_price.unit none recorded
Size size in name size, size_value, size_unit size none recorded
Stock stock_level none recorded none recorded availability.in_stock, availability.stock_level availability.delivery
Store context aisle store_id (required) none store_id in response warehouse in response
Other diets, organic, snap_eligible, rating is_local, facets country_of_origin, characteristics, updated_at badges, nutrition_highlights, rating member_only, rating, facets

How do you request each store's prices?

Every request is a GET with your key in the X-API-Key header and a query. The parameters differ by store, and they're the first thing to get right: Whole Foods requires a store_id, Sprouts takes an optional store_id or a zip from a fixed list, and Kroger's search takes only query and page. The table lists the search parameters from the reference.

Endpoint Required Optional
GET /v1/kroger/search query page (only 1 is allowed)
GET /v1/whole-foods/search query, store_id page, per_page, category, diet
GET /v1/trader-joes/search query page, per_page
GET /v1/sprouts/search query store_id, zip (85260, 90210, 77002, 30301 or 80202), page, per_page
GET /v1/costco/search query country (us, ca), locale, page, per_page, sort, brand[], min_price, max_price, category, in_stock, warehouse and more

Kroger: sale price and its end date

curl "https://api.perceptlayer.com/v1/kroger/search?query=milk" \
  -H "X-API-Key: $API_KEY"

The recorded response returned count: 24 and has_next_page: false. Trimmed to the first item:

{
  "data": {
    "query": "milk",
    "count": 24,
    "has_next_page": false,
    "items": [
      {
        "position": 1,
        "upc": "0001111050434",
        "name": "Simple Truth Organic® Lactose Free Vitamin D Whole Milk Half Gallon",
        "size": "1/2 gal",
        …
        "stock_level": "high",
        "price": 3.99,
        "regular_price": 4.99,
        "sale_price": 3.99,
        "sale_ends": "2026-12-02T04:59:59.999Z",
        "unit_price": 0.0623,
        "unit": "fl oz",
        …
      },
      …
    ]
  }
}

Whole Foods: one store at a time

curl "https://api.perceptlayer.com/v1/whole-foods/search?query=milk&store_id=10245" \
  -H "X-API-Key: $API_KEY"

The response reports total_results: 514 and a featured facet with an on-sale count, which is a quick read on how much of a query's results are discounted at that store:

{
  "data": {
    "store_id": "10245",
    "per_page": 24,
    "total_results": 514,
    "items": [
      {
        "id": "B082VVT75S",
        "name": "Unsweetened Oat Milk, 32 FZ",
        "brand": "Elmhurst",
        "is_local": true,
        "price": 7.29,
        "regular_price": 7.29,
        "on_sale": false
      },
      …
    ],
    "facets": [
      …
      {
        "key": "featured",
        "options": [
          {
            "slug": "on-sale",
            "label": "Sales & Deals",
            "count": 248
          },
          …
        ]
      }
    ]
  }
}

The /v1/whole-foods/store endpoint takes a store_id and returns that store, which helps when you track several locations.

Trader Joe's: unit price and size, split out

curl "https://api.perceptlayer.com/v1/trader-joes/search?query=hummus" \
  -H "X-API-Key: $API_KEY"
{
  "data": {
    "total_results": 10,
    "items": [
      {
        "sku": "059248",
        "name": "Organic Hummus",
        "price": 2.99,
        "unit_price": 0.3738,
        "unit_price_unit": "oz",
        "size_value": 8,
        "size_unit": "oz",
        …
        "updated_at": "2026-11-07 20:40:09",
        …
      },
      …
    ]
  }
}

Sprouts: sale and stock together

curl "https://api.perceptlayer.com/v1/sprouts/search?query=milk" \
  -H "X-API-Key: $API_KEY"

The recorded call passed no store_id, and the response came back with store_id: 393864, so store that value with each row:

{
  "data": {
    "store_id": "393864",
    "per_page": 20,
    "total_results": 249,
    "items": [
      {
        "product_id": "120137222",
        "name": "Grazeful Dairy Whole Grassfed A2/A2 Milk",
        "size": "64 oz",
        "upc": "00850221001627",
        "price": 3.79,
        "regular_price": 4.99,
        "sale_price": 3.79,
        "on_sale": true,
        "unit_price": {
          "amount": 0.06,
          "unit": "oz",
          …
        },
        "availability": {
          "in_stock": true,
          "stock_level": "inStock"
        },
        …
      },
      …
    ]
  }
}

Costco: price ranges and promotions

curl "https://api.perceptlayer.com/v1/costco/search?query=laptop" \
  -H "X-API-Key: $API_KEY"

The price is an object rather than a number, and promotions come as a list:

{
  "data": {
    "country": "us",
    "total_results": 164,
    "warehouse": "243",
    "items": [
      {
        "id": "4201046364",
        "brand": "Acer",
        …
        "price": {
          "currency": "USD",
          "delivery_min": 599.99,
          "delivery_max": 599.99,
          "original": 899.99
        },
        "member_only": false,
        …
        "promotions": [
          {
            "short_text": "$90 OFF"
          },
          …
        ],
        …
      },
      …
    ]
  }
}

Costco also has a product-price endpoint that takes a required item and an optional warehouses[] list; there's no recorded response for it here, so check its fields in the playground.

How do you build a weekly basket across stores?

Run one search per basket item per store each week, pick the matching product from the results by its key, and store the date, store, key, price, regular price and unit price where the store returns them. The first week, match by name and size and save the key; after that, match on the key. Kroger and Sprouts both return upc, a candidate key for matching products across the two; the recorded values differ in length (13 and 14 digits), so normalise leading zeros first.

This script runs a basket against Kroger, Trader Joe's and Sprouts, reads only recorded fields and writes one CSV row per result it keeps:

import csv
import datetime
import os

import requests

BASE = "https://api.perceptlayer.com/v1"
HEADERS = {"X-API-Key": os.environ["API_KEY"]}
BASKET = ["milk", "hummus"]

def kroger(item):
    return item.get("upc"), item.get("price"), item.get("regular_price"), item.get("unit_price"), item.get("unit")

def trader_joes(item):
    return item.get("sku"), item.get("price"), None, item.get("unit_price"), item.get("unit_price_unit")

def sprouts(item):
    unit = item.get("unit_price") or {}
    return item.get("upc"), item.get("price"), item.get("regular_price"), unit.get("amount"), unit.get("unit")

STORES = {"kroger": kroger, "trader-joes": trader_joes, "sprouts": sprouts}

today = datetime.date.today().isoformat()
with open("basket.csv", "a", newline="") as f:
    writer = csv.writer(f)
    for store, read in STORES.items():
        for query in BASKET:
            r = requests.get(f"{BASE}/{store}/search", headers=HEADERS, params={"query": query}, timeout=60)
            if r.status_code != 200:
                print(store, query, r.status_code)
                continue
            items = r.json()["data"].get("items", [])
            if items:
                writer.writerow([today, store, query, items[0].get("name"), *read(items[0])])

It keeps the first result per query to stay short; a real index should match the saved key instead. Failed calls cost 0 credits and the script skips them. The errors docs list the codes, and the rate limits docs explain the per-account rate: a free account runs 1 request a second.

What does a weekly grocery basket cost?

Cost is one credit per search call, and a basket check is one call per item per store, so the weekly cost is items × stores × 1 credit. Each search returns a page of products, so one call per item is enough when the item you want is on the first page. Whole Foods needs a call per store_id, so tracking several locations multiplies its share.

Job Arithmetic Credits
Try every store once 5 calls × 1 credit 5, out of the 100 free signup credits
20-item basket, 5 stores, weekly 20 × 5 × 1 100 a week, 5,200 a year
50-item index, 5 stores, weekly 50 × 5 × 1 250 a week, 13,000 a year
50-item index, 5 stores, daily 50 × 5 × 30 7,500 a month

The 20-item basket for a year is 5,200 credits, inside the Starter pack's 10,000, and purchased credits last 12 months. The 50-item weekly index is 13,000 a year, inside the Build pack's 50,000. Adding a product-detail call for items whose search result changed costs 1 credit each. See pricing for what credits cost and the credits docs for how they're debited.

To start, run a milk search on the Kroger API page playground and the same query on the Sprouts API page, compare the fields side by side, then get a free API key for the weekly job. The Whole Foods, Trader Joe's and Costco pages have the other stores' endpoints.

APIs in this post

Frequently asked questions

How much does a grocery price API call cost?

Each search endpoint for Kroger, Whole Foods, Trader Joe's, Sprouts and Costco costs 1 credit per successful call, and one call returns a page of products. Failed calls cost nothing. The 100 free credits you get once on signup cover 100 searches, enough to run a 20-item basket across all five stores once.

Can I get prices for a specific store location?

It depends on the store. Whole Foods search requires a store_id. Sprouts search takes an optional store_id or a zip from five allowed values. Costco search takes an optional warehouse, and its product-price endpoint takes a warehouses[] list. Kroger search takes only query and page, and Trader Joe's only query, page and per_page.

Which stores show sale prices?

Kroger returns regular_price, sale_price and sale_ends. Sprouts returns regular_price, sale_price and on_sale. Whole Foods returns regular_price and on_sale, plus an on-sale facet count. Costco returns price.original and a promotions list. The recorded Trader Joe's search returned only price, so detect its changes by comparing week to week.

How do I compare prices across different pack sizes?

Use the unit price where the store returns one: Kroger's unit_price with unit, Trader Joe's unit_price with unit_price_unit, and Sprouts' unit_price.amount with unit_price.unit. Convert to one unit before comparing, since Kroger reports milk per fl oz and Sprouts per oz. For stores without a unit price, store the size and compute it yourself.

Is the data live?

Each call returns the data as found at the time of the call, collected from publicly available sources. Store the date with every row so your index reflects when each price was seen. Trader Joe's items also carry an updated_at timestamp, which is worth keeping alongside your own check date.

  1. LinkedIn Jobs API: Job Listings as JSON

    Search public LinkedIn job listings with jobs-search and fetch one posting with job, at 1 credit a call: parameters, cURL and a weekly hiring-signal job.

  2. Price Monitoring Tool: Build One on Product APIs

    Build a price monitoring tool in Python: daily Google Shopping, Walmart and idealo searches, price and seller per day in SQLite, 1 credit per check.

  3. Jobs API: Indeed, Glassdoor and Google Jobs Compared

    Indeed returns postings with apply_url and coordinates, Glassdoor returns ratings, reviews and pay percentiles, Google Jobs adds date filters. 1 credit a call.

Start with 100 free credits

No password to set. We email you a sign-in link, and your key works on every API.

No credit card. 100 free credits on signup.