Providers
SerpAPI
SerpAPI's Google endpoints for classic SERP results and Google Lens for reverse image search.
- env var
- SERPAPI_API_KEY
- auth
- query parameter
- operations
- search · image
- results
- 10
Address it
import { create, searchByImage } from "@agntn/web";
const serpapi = await create("serpapi"); // SERPAPI_API_KEY
const results = await serpapi.search("query", { maxResults: 10 });
const matches = await searchByImage("https://example.com/image.jpg", { provider: "serpapi" });
The key is a query parameter on serpapi.com.
What it reads
| Call | Endpoint |
|---|---|
search | GET /search?engine=google&q=…&num=…&start=… |
searchByImage | GET /search?engine=google_lens&url=… |
What comes back
Search: publishedDate, image (thumbnail), favicon and metadata.{position, source, displayedLink}. No filters. Paging through start. Image matches carry pageUrl, imageUrl, dimensions, source, position and exactMatch.
Gotchas
- The only built-in reverse image provider. Everything under Reverse image search applies.
- 100 searches a month on the free plan. A burst answers 429 fast.
maxResultsis applied on our side to whatever Google or Lens returns. Google pays little attention tonum(amaxResults: 1call still brought back nine organic results) and hands a different page for astartoff the ten grid, so a smallmaxResultswalks each Google page in slices: the continuation fetches the same page again, which SerpAPI serves from its cache for an hour without charging, andstartmoves only once the page is used up.- No matches is an empty list, not an error. An image Lens cannot fetch looks the same, so
[]may also mean the provider never saw the picture.
Where it lives
src/providers/serpapi.ts.