# Price comparison in JavaScript and TypeScript

> The findcheap package for JavaScript and TypeScript: the install line and the key, a search from a product page's address with a page read and a link resolved, a search from a description in words and from a photo, every method with its call and credits, errors, timeouts and cancelling a call, feedback on a search, the markets, benchmark results, plans and common questions. The same page for people: https://findcheap.ai/developers/use-cases/price-comparison-javascript. Index: https://findcheap.ai/llms.txt. The MCP server reference: https://findcheap.ai/developers/mcp.md. The API reference: https://findcheap.ai/developers/docs.md.

The Findcheap API in JavaScript and TypeScript: where the product on a page is sold for less. Node 18+ or a browser with `fetch`; no dependencies.

One client for every call: a search from a product page's address, from a description in words or from a photo, a page read, and feedback. Free to start: 1,000 credits a month, no payment method required.

Install: `npm install findcheap`

## Install it and search

```
npm install findcheap
export FINDCHEAP_API_KEY=fc_live_...   # from https://findcheap.ai/signin?next=/dashboard/keys
```

The key is free: [create one in your dashboard](https://findcheap.ai/signin?next=/dashboard/keys).

TypeScript:

```
import { Findcheap, FindcheapApiError } from "findcheap";

const fc = new Findcheap(); // reads FINDCHEAP_API_KEY; or new Findcheap({ apiKey: "fc_live_..." })

const answer = await fc.search("https://findcheap.ai/sample-product", { max_results: 3 });
console.log(answer.product.title, "read in", answer.search.market);
for (const card of answer.same_product) console.log(card.price, card.currency, card.retailer, card.url ?? card.resolve_id);

const page = await fc.extract("https://findcheap.ai/sample-product");
if (page.is_product_page) console.log(page.title, page.price, page.currency);

const link = await fc.resolve(answer.similar_products[0].resolve_id!); // for a card whose url is null
```

`search` and `extract` take an optional `objective`: what the shopper wants, in one sentence.

Results are sorted into two arrays, each containing up to 10 results:

- `same_product` - listings that match the original product. Sorted by cheapest first.
- `similar_products` - acceptable equivalents of the original product. Sorted by cheapest first.

## Search from a description in words

`searchProducts` finds products from a description in words, for when there is no product page to start from:

TypeScript:

```
const found = await fc.searchProducts("Insignia 32 inch Fire TV", { market: "US", max_price: 200 });
console.log(found.about_listings);
for (const card of found.listings) console.log(card.price, card.currency, card.retailer, card.url ?? card.resolve_id);
```

It answers up to 10 listings that match the words, cheapest first, and costs 10 credits, with or without listings. `market` is required: there is no address to infer it from. `objective` (what the shopper wants, in one sentence), `min_price`, `max_price` and `max_results` are optional.

## Search from a photo

`searchProducts` also takes a photo in place of the words: `image_url`, a link to the photo, or `image_base64`, the photo's file itself. Pass `null` as the query and send only one of the three. Use it when the shopper has a photo of the product and no words for it:

TypeScript:

```
import { readFile } from "node:fs/promises";

const byLink = await fc.searchProducts(null, { market: "US", image_url: "https://example.com/photos/headphones.jpg" });

const image_base64 = (await readFile("photo.jpg")).toString("base64");
const byFile = await fc.searchProducts(null, { market: "US", image_base64 });
```

It answers up to 10 listings, cheapest first: listings that match the product in the photo and acceptable equivalent products. It usually answers in about 15 seconds and costs 10 credits, with or without listings. A file is a JPEG, PNG or WebP of 10 MB at most.

A photo you send is shared with the stores and search services Findcheap uses to run the search. A photo sent as `image_base64` is redrawn before it is searched or kept: the data a camera stores in the file beside the picture (where and when it was taken, the device) is removed.

## The methods

| Call | Method | Credits | What it does |
| --- | --- | --- | --- |
| Search by URL | `fc.search()` | 10 | Takes a product page URL as input and searches the internet to find where the product is available for a lower price. |
| Search by text | `fc.searchProducts()` | 10 | Takes a description of a product in words as input and returns the listings that match it, cheapest first. |
| Search by image | `fc.searchProducts()` | 10 | Takes a photo of a product as input and returns listings that match the product in the photo and acceptable equivalent products, cheapest first. |
| Extract | `fc.extract()` | 1 | Takes a product page URL as input and returns structured product data from the page. |
| Resolve | `fc.resolve()` | 1 | Calling the Resolve endpoint with a `resolve_id` returns a direct link to the corresponding product on the merchant's website and the merchant's name. |
| Feedback | `fc.feedback()` | 0 | Sending feedback costs nothing, and the first report on a search gives 1 credit back. |

The client returns the answer exactly as the API sends it, and ships its own type declarations. Every field of every answer is in the [API reference](https://findcheap.ai/developers/docs.md).

## Errors, timeouts and cancelling

Every answer opens with `request_id` and closes with `credits_used`. A failed call throws `FindcheapApiError` with `status`, `type`, `message`, `credits_used`, `request_id` and `retry_after` (seconds, on a 429); a call that never reached the API throws `FindcheapConnectionError`. Both extend `FindcheapError`.

Timeouts sit above the API's own ceilings (a search answers within 60 seconds, a read within 30): 100, 40 and 20 seconds for search, extract and resolve, 20 for feedback, or one `timeoutMs` for every call. Pass your own `signal` to cancel a call.

## Feedback on a search

`feedback` reports how a search went, by the `request_id` of its answer:

TypeScript:

```
const report = await fc.feedback(answer.request_id, "partial", {
  useful_cards: [{ list: "same_product", position: 1 }],
  wrong_cards: [{ list: "similar_products", position: 2, reason: "not_equivalent" }],
  note: "The second similar listing is a smaller size.",
});
console.log(report.credits_refunded, "credit back,", report.refunded_today, "of", report.daily_refund_cap, "today");
```

The limits: one report per search, within 20 minutes of the search. The first report on a search gives 1 credit back, up to 100 credits a day per account. Sending feedback costs nothing.

## In other stacks

- Python: [the same client, from PyPI](https://findcheap.ai/developers/use-cases/price-comparison-python.md).
- A LangChain agent: [the same calls as tools](https://findcheap.ai/developers/use-cases/langchain-price-comparison.md).
- An assistant such as ChatGPT, Claude or Cursor: [the Findcheap MCP server](https://findcheap.ai/developers/use-cases/price-comparison-mcp-server.md).
- Any other language: [every call, with its endpoint and its credits](https://findcheap.ai/developers/use-cases/price-comparison-api.md).

The code and the issue tracker: [https://github.com/llmbender/findcheap-sdks](https://github.com/llmbender/findcheap-sdks).

## Countries and stores

Every call runs in a **market**, the country where the shopper is located.

| Market | Currency | Marketplaces Search by URL compares against |
| --- | --- | --- |
| US | USD | Amazon, Walmart, eBay, AliExpress, Shein, and other sites |
| CA | CAD | Amazon, AliExpress, other sites |
| AU | AUD | Amazon, eBay, AliExpress, other sites |
| IN | INR | Amazon, Flipkart, other sites |
| GLOBAL | USD | Amazon, eBay, AliExpress, other sites; the page is fetched from the store's own country when its address names one |

## Benchmark results

PriceBench N=100 human-verified results: savings capture on the equivalent-product track, median search latency, and cost per search.

| Agent | Savings capture | Median search latency | Cost per search |
| --- | --- | --- | --- |
| Findcheap | 92.8% | 15.6s | $0.03 |
| GPT-6 Astra | 43.9% | 87.5s | $1.32 |
| Perplexity | 34.1% | 74.7s | $0.38 |
| Claude Opus 5 | 20.2% | 232s | $1.41 |
| Gemini 3.1 Pro | 10.7% | 80s | $0.08 |

PriceBench is an open source benchmark developed by Findcheap, to help fill the need for multimodal product search evals: [github.com/llmbender/pricebench](https://github.com/llmbender/pricebench)

## What it costs

Free: 1,000 credits a month, no payment method. A search costs 10 credits. No overage charges.

| Plan | Price | Credits a month |
| --- | --- | --- |
| Free | $0 | 1,000 (100 searches) |
| Developer | $19/month | 5,000 (500 searches) |
| Startup | $99/month | 40,000 (4,000 searches) |
| Growth | $499/month | 250,000 (25,000 searches) |

Start for free: https://findcheap.ai/signin. Plans and pricing: https://findcheap.ai/developers/pricing.

## FAQ

**Is there a JavaScript or Node.js library that compares product prices across stores?** Yes: npm install findcheap. It is the Findcheap API in JavaScript and TypeScript: where the product on a page is sold for less. Findcheap takes a product page's address and answers where the product is sold for less: the same product elsewhere, and acceptable equivalents, cheapest first.

**Does it work with TypeScript?** Yes. It is the Findcheap API in JavaScript and TypeScript, and the package ships its own type declarations.

**Which Node version does it need, and what does it depend on?** Node 18+ or a browser with fetch; no dependencies.

**Can I call it from code that runs in a browser?** The client runs on Node 18+ or a browser with fetch. Every request carries an API key in the Authorization header, so code that runs in a visitor's browser would hand that visitor your key: call the API from your server.

**Where does the API key go?** new Findcheap() reads FINDCHEAP_API_KEY; or new Findcheap({ apiKey: "fc_live_..." }). A key is free: create one in your dashboard.

**What happens when a call fails or is rate limited?** A failed call throws FindcheapApiError with status, type, message, credits_used, request_id and retry_after (seconds, on a 429); a call that never reached the API throws FindcheapConnectionError.

**How long can a call take, and can I cancel one?** Timeouts sit above the API's own ceilings (a search answers within 60 seconds, a read within 30): 100, 40 and 20 seconds for search, extract and resolve, 20 for feedback, or one timeoutMs for every call. Pass your own signal to cancel a call.

**Is there a client for Python too?** Yes. Official clients for Python and JavaScript wrap the five calls: pip install findcheap and npm install findcheap.

**What does a search cost?** A search costs 10 credits, with or without listings. Reading a product page without a search costs 1 credit.

**Which countries and stores does it cover?** Five markets: the US, Canada, Australia, India and Global. The table above shows the marketplaces a search compares against in each.

**Are the links affiliate links?** Paid plans carry no affiliate links: every link is the listing's own address. On the Free plan, links to some retailers may be affiliate links.
