Search
Web Search
Search the web and get ranked results with titles, URLs, and snippets.
Endpoint#
https://api.searlo.tech/api/v1/search/webCredits: 1 per request. A search that finds nothing, or fails, is not charged.
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
q | string | Yes | Search query (1–500 chars) |
limit | number | No | Results per page (1–10, default: 10) |
page | number | No | Page number (default: 1). Results are served down to about result 101: see Pages below |
safe | string | No | Safe search: active or off |
lr | string | No | Language restriction, max 50 chars (e.g. lang_en) |
gl | string | No | Country code, max 5 chars (e.g. us, gb) |
hl | string | No | Interface language code, max 5 chars (e.g. en) |
dateRestrict | string | No | Only results from the last n days, weeks, months or years: d7, w2, m1, y1. Works with gl and hl. See Date filter below |
cache | boolean | No | false skips the cached copy and searches now. Same credits (default: true) |
Response#
{ "searchParameters": { "q": "machine learning", "type": "search", "gl": "us", "hl": "en", "num": 10, "page": 1 }, "page": 1, "nextPage": 2, "previousPage": null, "totalResults": 1250000, "searchTime": 0.42, "organic": [ { "position": 1, "title": "Introduction to Machine Learning", "link": "https://example.com/ml-intro", "snippet": "Machine learning is a subset of AI...", "description": "An introduction to machine learning concepts and methods.", "displayedLink": "example.com", "domain": "example.com", "favicon": "https://www.google.com/s2/favicons?domain=example.com&sz=32" } ], "credits": 1}Responses also set X-Cache (HIT/MISS) and credit headers (X-Credits-Deducted, X-Credits-Remaining).
Pages#
Web search serves results down to about result 101. A page whose first result would come after that returns 400 PAGE_OUT_OF_RANGE with the last page it can serve, and is not charged. At limit 10 the last page is 11, at limit 5 it is 21.
{ "success": false, "errorCode": "PAGE_OUT_OF_RANGE", "message": "Search pages this query up to page 11 at this limit. Ask for page 11 or earlier.", "retryable": false, "maxPage": 11}Date filter#
dateRestrict keeps the results from a recent window: d7 is the last 7 days, w2 the last 2 weeks, m1 the last month and y1 the last year. It works with gl and hl. News Search takes the same filter, and Advanced Search takes it as dateRestrict or dateRange.
A date filter cannot be combined with search operators in q: site:, inurl:, intitle:, filetype:, before: or after:, e-mail addresses and long OR chains. That request returns 400 DATE_FILTER_UNAVAILABLE with retryable: false, and is not charged: remove the filter or the operators. A value that is not one of d, w, m or y followed by a number returns 400 VALIDATION_ERROR.
{ "success": false, "errorCode": "DATE_FILTER_UNAVAILABLE", "message": "This query cannot take a date filter: the lane that applies dates does not serve operator queries (site:, filetype:, OR chains, e-mail addresses). Remove the date filter or the operators.", "retryable": false}Examples
curl "https://api.searlo.tech/api/v1/search/web?q=machine+learning&limit=10&gl=us" \ -H "x-api-key: sk_your_api_key" # Results from the last two weeks, for Germany, in Germancurl "https://api.searlo.tech/api/v1/search/web?q=kuenstliche+intelligenz&dateRestrict=w2&gl=de&hl=de" \ -H "x-api-key: sk_your_api_key"async function webSearch(query, options = {}) { const params = new URLSearchParams({ q: query, limit: options.limit || 10, ...options }); const res = await fetch( `https://api.searlo.tech/api/v1/search/web?${params}`, { headers: { "x-api-key": process.env.SEARLO_API_KEY } } ); return res.json();} const result = await webSearch("machine learning", { limit: 10, gl: "us" });result.organic.forEach(r => console.log(r.position, r.title, r.link));import osimport requests def web_search(query, limit=10, gl=None): params = {"q": query, "limit": limit} if gl: params["gl"] = gl response = requests.get( "https://api.searlo.tech/api/v1/search/web", params=params, headers={"x-api-key": os.environ["SEARLO_API_KEY"]} ) return response.json() results = web_search("machine learning", limit=10, gl="us")for r in results["organic"]: print(r["position"], r["title"], r["link"])Stuck? Write to [email protected], or check live status.