Home / Docs / Search website code

Search website source code by API

Besides your own documents, the API searches the HTML of the public websites we've crawled: find sites by a script URL, a tag ID, a phrase or a pattern.

Search

GET /api/search finds websites whose HTML contains q (plain text, any case) or matches it (regex=1). Results are one page per site, with the line around the match and the day we fetched it. 1 credit.

NameTypeWhat it does
qstringRequired. Text or, with regex=1, an RE2 pattern.
regex1Optional. Read q as a regular expression.
limitintegerOptional. Sites to return: 20 unless you ask, up to your plan's most.
cursorstringOptional. The next value of the last answer, for the sites after it.
orderstringOptional. newest: the pages fetched most recently first.
Shell
curl -G https://stackgrep.com/api/search -H "Authorization: Bearer $STACKGREP_KEY" \
  --data-urlencode 'q=static.klaviyo.com' -d limit=2
Response
{"pattern": "(?i)static\\.klaviyo\\.com", "took_ms": 9.2, "pages": 1204331, "candidates": 412,
 "hits": [
  {"url": "https://example-store.com/", "site": "example-store.com",
   "match": "static.klaviyo.com", "line": "<script src=\"https://static.klaviyo.com/onsite/js/klaviyo.js?company_id=...\"></script>",
   "seen_at": "2026-09-21"},
  ...
 ],
 "next": "i:...", "cached": false}

candidates is how many pages the index said could match and were checked; cached says the answer came from a recent identical search. Long token-like strings in results (keys, ids) are shortened.

Count

GET /api/count takes q and regex and counts every matching page and site, with a sample of sites. 5 credits.

Shell
curl -G https://stackgrep.com/api/count -H "Authorization: Bearer $STACKGREP_KEY" \
  --data-urlencode 'q=G-[A-Z0-9]{10}' -d regex=1
# {"pattern": "G-[A-Z0-9]{10}", "took_ms": 812.5, "pages": 20113, "sites": 19870,
#  "sample": ["...", "..."], "checked": 20544}

Sites by technology

GET /api/facets finds sites by the technologies we detect, and breaks down what else they use. 5 credits.

Shell
curl -G https://stackgrep.com/api/facets -H "Authorization: Bearer $STACKGREP_KEY" \
  --data-urlencode 'filter=shopify AND klaviyo AND NOT attentive AND tld:de'
# {"sites": 312, "breakdown": [{"name": "shopify", "sites": 312}, {"name": "klaviyo", "sites": 312},
#   {"name": "meta-pixel", "sites": 201}, ...], "sample": ["...", "..."]}

The filter combines technology names (shopify, klaviyo, meta-pixel, ...) with AND, OR, NOT and parentheses; -klaviyo means NOT, and terms side by side are ANDed. tld:de picks a country's domains and site:.org a domain ending. Plain English works too: shopify stores using klaviyo but not attentive in germany. The technologies page lists what we detect.

Try it on your own documentsExact and regex search for your agents, from one API. Or see the engine on npm's source first.