Use case · competitive intelligence

Monitor competitor prices with an extraction workflow

Price monitoring has two separate jobs: extracting the current value from a public product page, and comparing that value with a history your application owns. ExtractAPI handles the first job. Your code chooses the schedule, database or file, normalization rules, and notification channel.

Who this is for

This pattern is useful for a small catalog, a merchandising dashboard, or a research job that checks a known set of public product URLs. Start with a few representative targets and confirm that the page exposes a stable, permitted price before expanding.

1. Extract a public product page

Pass a narrow CSS selector when the page has a stable price element. The selected text is returned in data.custom; the API does not infer a currency or guarantee that a selector identifies the current selling price.

curl -X POST https://extractapi.app/v1/extract \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://demo.example/products/widget",
    "javascript": true,
    "waitFor": "[data-ready=\"true\"]",
    "selector": "[data-price]"
  }'

This synthetic response illustrates the relevant fields and contains no real seller data:

{
  "status": "ok",
  "url": "https://demo.example/products/widget",
  "data": {
    "title": "Widget Pro | Demo Store",
    "h1": "Widget Pro",
    "custom": ["$49.00"],
    "structuredData": [{"@type":"Product","name":"Widget Pro","offers":{"price":"49.00","priceCurrency":"USD"}}],
    "mainContent": "Widget Pro In stock $49.00"
  }
}

2. Compare values in your application

Store a normalized value and the source timestamp in storage you control. This small Node.js example uses a local JSON file for demonstration; it is not a built-in ExtractAPI history or alert service.

// compare-price.mjs
import { readFile, writeFile } from 'node:fs/promises';

const current = { id: 'demo-widget', competitor: 'Demo Store', price: 49, currency: 'USD' };
let history = {};
try { history = JSON.parse(await readFile('price-history.json', 'utf8')); } catch (error) {
  if (error.code !== 'ENOENT') throw error;
}

const previous = history[current.id];
const change = previous && previous.price !== current.price
  ? { direction: current.price < previous.price ? 'decrease' : 'increase', from: previous.price, to: current.price }
  : null;

history[current.id] = { ...current, checkedAt: new Date().toISOString() };
await writeFile('price-history.json', JSON.stringify(history, null, 2) + '\n');
console.log(JSON.stringify({ current, change }, null, 2));

In production, call your extraction function before the comparison, validate currency and availability, and make the write idempotent. A scheduler such as your own cron, CI job, or queue can invoke the workflow; ExtractAPI does not schedule jobs.

3. Add an alert only if you need one

After comparison, your application may send a Slack, email, or internal notification according to its own credentials and policy. Keep target URLs, raw page content, and API keys out of public analytics and alert payloads unless your recipients are authorized.

Scope boundary: ExtractAPI returns the page extraction. It does not store price histories, schedule recurring checks, send alerts, solve CAPTCHAs, or guarantee access to protected sites.

Implementation checklist

  1. List only public targets that your organization is allowed to monitor; read each site's terms and robots guidance.
  2. Test a representative target with a fixture or non-sensitive development key. Confirm whether the value is server-rendered, JavaScript-rendered, or present in JSON-LD.
  3. Use javascript:true and an optional waitFor selector for client-rendered pages; keep selectors narrow and version them in your application.
  4. Normalize currency, sale versus list price, stock state, and locale before comparing. Treat a missing value as unknown, not as zero.
  5. Record status, request ID, checked time, and sanitized error categories. Retry carefully and avoid burst traffic to a target.
  6. Define your own retention, alert threshold, and suppression rules before enabling notifications.

Limitations

FAQ

Does ExtractAPI provide a scheduled monitoring product?

No. It provides an extraction API. Schedule your own script or job, and own the price history and alerting logic.

Should I read the price from HTML or JSON-LD?

Use the representation that matches your requirement and validate it. JSON-LD can provide Product and Offer fields; a rendered selector can show what a visitor sees. They may differ, so record which field you selected.

What happens when a price is missing?

Keep the observation as unknown, record a sanitized failure category, and avoid overwriting a known value with zero. Investigate selector drift or page availability before alerting.

Get a free API key