websearch.fast
控制台获取密钥

搜索

网页搜索结果,可附带排名靠前网页的正文。

本参考页为英文。字段名、示例和错误码在所有语言版本中都一样。

Searches the web, or one vertical chosen with type. Every url is the address of the destination page itself. With content, the same response carries the cleaned text of the top pages, so a model does not need a second call to read them.

Page 1 of a type: web search that has results may carry knowledge_panel: the encyclopedia card of the person, place, organization or thing the query names, the same object as panel of knowledge. It is included in the search price and adds no unit. A search without a panel costs the same.

type: web and content are available. The other types (news, images, videos, places, shopping, scholar, patents) and answer are planned; until each ships, a call that asks for it gets 501 api_not_implemented.

Operators inside q (site:, -site:, "exact phrase", -term, OR, before:YYYY-MM-DD, after:YYYY-MM-DD) are parsed into the fields below and echoed in input.operators. An operator that conflicts with an explicit field returns 400 invalid_request.

What is charged

Charged when at least one result comes back. An empty result set returns results: [] with the warning no_results and is free, as is every error. Pages that could not be read for content are free; when fewer pages than asked were read, the warning content_partial says how many.

Units: search_web, content_page. usage.items in the response lists them.

Request

POST https://api.websearch.fast/v1/web/search

type: web and content are available; other types and answer are planned.

Body

NameTypeDescription
qrequiredstringThe query. Operators: site:, -site:, quotes, -term, OR, before:, after:; filetype:, intitle:, inurl: (planned). 1 to 2048 characters.
typestringThe vertical. Types not shipped yet return 501 api_not_implemented. One of web, news, images, videos, places, shopping, scholar, patents. Default web.
countrystringISO 3166-1 alpha-2 country code, case-insensitive.
languagestringBCP 47 language tag. At most 12 characters.
locationstringPlace to rank for, as text. 2 to 256 characters.
nearobjectplaces only; exclusive with location.
Show fields
NameTypeDescription
latrequirednumber-90 to 90.
lonrequirednumber-180 to 180.
radius_minteger100 to 50,000. Default 5000.
freshnessstringOnly results published within this period. Until the hourly filter ships, hour returns 501 api_not_implemented. One of hour, day, week, month, year.
date_fromstringDate YYYY-MM-DD (UTC).
date_tostringDate YYYY-MM-DD (UTC).
pageintegerResults are read in blocks of 10 to 100 that start on a multiple of the block size; a page and num pair that does not fit in one block returns 400 with param num. 1 to 10. Default 1.
numintegerDefault 10 (images and shopping 20). page * num at most 200. 1 to 100.
safestringOne of off, moderate, strict. Default moderate.
include_domainsarray of stringHost names; subdomains included. At most 20 items.
exclude_domainsarray of stringAt most 50 items.
contentobjectCleaned text of the top pages.
Show fields
NameTypeDescription
pagesintegerAt most num. On a page above 1, content needs a num that is a multiple of 10, otherwise 400 with param content. 1 to 10. Default 3.
formatstringOne of markdown, text. Default markdown.
max_chars_per_pageinteger500 to 50,000. Default 8000.
modestringOne of full, relevant. Default full.
answerboolean or objectPlanned. True is the same as {}.
max_ageintegerAccept a stored copy up to this age in seconds. 0 to 2,592,000.
no_cachebooleanNever answer from a stored copy. Default false.
timeout_msintegerOur deadline for this call; default and maximum 20000, or 25000 with content. A value outside 1000 to that maximum is refused with 400. 1000 to 25,000.

Example request

curl https://api.websearch.fast/v1/web/search \
  -H "Authorization: Bearer $WEBSEARCH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "q": "rust async runtime comparison",
    "num": 3,
    "content": {"pages": 1, "max_chars_per_page": 3000}
  }'
import os
import httpx

response = httpx.post(
    "https://api.websearch.fast/v1/web/search",
    headers={"Authorization": f"Bearer {os.environ['WEBSEARCH_API_KEY']}"},
    json={
        "q": "rust async runtime comparison",
        "num": 3,
        "content": {"pages": 1, "max_chars_per_page": 3000},
    },
    timeout=60,
)
response.raise_for_status()
print(response.json())
const response = await fetch("https://api.websearch.fast/v1/web/search", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WEBSEARCH_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    q: "rust async runtime comparison",
    num: 3,
    content: { pages: 1, max_chars_per_page: 3000 },
  }),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());

Example response

{
  "object": "web.search",
  "request_id": "20261128120000123456789a1b2c3d4Kx7Qm2Pz",
  "created": 1795867200,
  "input": {
    "q": "rust async runtime comparison",
    "type": "web",
    "page": 1,
    "num": 3,
    "safe": "moderate",
    "operators": {},
    "content": {
      "pages": 1,
      "format": "markdown",
      "max_chars_per_page": 3000,
      "mode": "full"
    },
    "timeout_ms": 25000
  },
  "results": [
    {
      "position": 1,
      "title": "Choosing an async runtime in 2026",
      "url": "https://blog.example.com/posts/async-runtimes-2026",
      "domain": "blog.example.com",
      "snippet": "We benchmarked four runtimes on the same HTTP workload and compared scheduling, I/O and memory use.",
      "published_at": "2026-09-14T00:00:00Z",
      "origin": "index",
      "content": {
        "status": "ok",
        "format": "markdown",
        "chars": 3000,
        "truncated": true,
        "text": "# Choosing an async runtime in 2026\n\n...",
        "fetched_at": 1795860000
      }
    },
    {
      "position": 2,
      "title": "Async runtimes: a comparison of schedulers",
      "url": "https://docs.example.org/rust/async/runtimes",
      "domain": "docs.example.org",
      "snippet": "How work-stealing and thread-per-core runtimes differ, with notes on when each fits.",
      "published_at": "2026-06-02T00:00:00Z",
      "origin": "live"
    },
    {
      "position": 3,
      "title": "Moving a service between async runtimes",
      "url": "https://www.example.net/notes/runtime-migration",
      "domain": "www.example.net",
      "snippet": "What changed in our code when we moved a Rust service from one async runtime to another.",
      "published_at": "2026-03-21T00:00:00Z",
      "origin": "live"
    }
  ],
  "has_more": true,
  "usage": {
    "charged": true,
    "items": [
      {"unit": "search_web", "count": 1},
      {"unit": "content_page", "count": 1}
    ]
  },
  "cache": {"hit": false, "data_age_seconds": 0, "fetched_at": 1795867200}
}

Response fields

Results. An empty list carries the warning no_results and is not charged.

NameTypeDescription
objectrequiredstringAlways web.search.
request_idrequiredstringSame as the X-Request-Id header.
createdrequiredintegerUnix seconds (UTC).
inputrequiredobjectThe parameters as applied, defaults filled in.
usagerequiredobject
Show fields
NameTypeDescription
chargedrequiredboolean
itemsrequiredarray of object
Show fields
NameTypeDescription
unitrequiredstringBillable unit, for example search_web, content_page, fetch_page, geocode, autocomplete, knowledge.
countrequiredinteger
cacheobject
Show fields
NameTypeDescription
hitrequiredbooleanThe response, or every page in it, came from a stored copy.
data_age_secondsrequiredintegerAge of the oldest part of the response.
fetched_atrequiredintegerUnix seconds when the oldest part was read.
warningsarray of object
Show fields
NameTypeDescription
coderequiredstringFor example no_results, content_partial, answer_unavailable, partial, all_failed, reach_reduced.
messagestring
paramstring
resultsrequiredarray of object
Show fields
NameTypeDescription
positionrequiredinteger1-based rank across pages. At least 1.
titlerequiredstring
urlrequiredstringReal destination URL, never a redirect link.
domainrequiredstringHost of url, lowercase, without www.
snippetstringAt most 400 characters.
published_atstringISO 8601 UTC, when known.
site_namestringThe publisher's own name, when known.
originrequiredstringOur neutral label of how the result reached you. New values can appear. One of index, live, open_data.
attributesobjectFacts shown with the result.
contentobjectCleaned page text added by the content option.
Show fields
NameTypeDescription
statusrequiredstringOne of ok, failed.
error_codestringOne of fetch_failed, site_refused, unsupported_content, page_too_large, timeout.
formatstringOne of markdown, text.
textstring
charsinteger
truncatedboolean
titlestring
fetched_atintegerUnix seconds when the page was read.
has_morerequiredboolean
answer_boxobject
Show fields
NameTypeDescription
titlestring
answerrequiredstring
snippetstring
urlstring
knowledge_panelobjectAn encyclopedia card from open data. In a search it comes only on page 1 of a search with results and is included in the search price.
Show fields
NameTypeDescription
titlerequiredstring
typestringShort label, for example Physicist or City.
descriptionstringA short text from the encyclopedia article.
description_urlstringThe article the description comes from.
description_site_namestringName of the encyclopedia, with description_url.
websitestringOfficial website of the entity.
attributesobjectKey facts as name: value, in a stable order.
attributionrequiredarray of objectThe open data projects the data comes from, with their licences. Show it with the data.
Show fields
NameTypeDescription
sourcerequiredstringName of the open data set the fact comes from.
urlrequiredstring
licenserequiredstringFor example CC BY-SA 4.0 or CC0 1.0.
top_storiesarray of objectAt most 10 items.
Show fields
NameTypeDescription
positionrequiredinteger1-based rank across pages. At least 1.
titlerequiredstring
urlrequiredstringReal destination URL, never a redirect link.
domainrequiredstringHost of url, lowercase, without www.
snippetstringAt most 400 characters.
published_atstringISO 8601 UTC, when known.
site_namestringThe publisher's own name, when known.
originrequiredstringOur neutral label of how the result reached you. New values can appear. One of index, live, open_data.
image_urlstring
authorsarray of string
contentobjectCleaned page text added by the content option.
Show fields
NameTypeDescription
statusrequiredstringOne of ok, failed.
error_codestringOne of fetch_failed, site_refused, unsupported_content, page_too_large, timeout.
formatstringOne of markdown, text.
textstring
charsinteger
truncatedboolean
titlestring
fetched_atintegerUnix seconds when the page was read.
answerobjectPlanned.
Show fields
NameTypeDescription
statusrequiredstringOne of ok, unavailable.
textstringMarkdown with [n] markers that index citations.
dataobjectStructured answer when answer.schema was sent.
citationsarray of object
Show fields
NameTypeDescription
indexrequiredintegerAt least 1.
urlrequiredstring
titlestring
site_namestring
published_atstring
languagestring

Errors

StatusCodes
400invalid_request, invalid_url, invalid_schema or invalid_image. Not charged.
401invalid_token. Not charged.
403pre_consume_token_quota_failed (the key's own spending limit), access_denied, web_not_allowed or model_not_in_plan (customer keys while plans cannot include the web tools). Not charged.
404not_found or invalid_endpoint. Not charged.
413read_request_body_failed: the request body is over the limit. Not charged.
429rate_limited, concurrency_limited, api_key_temporarily_frozen, or the failure guard. Not charged.
500internal_error. Not charged.
501api_not_implemented: the endpoint, type or option has not shipped. Not charged.
503source_unavailable, web_api_disabled, token_cache_busy or billing_busy (the charge could not be prepared in time; retry after Retry-After). Not charged.
504timeout. Not charged.