websearch.fast
控制台获取密钥

整站抓取

以任务方式读取一个站点的大量网页。

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

Reads the pages of one site as an asynchronous job, starting from a URL and following its sitemaps and links within the limits you set. The host of url is the scope of the crawl. Pages that robots.txt disallows are counted as skipped_robots and not read.

Pages can be listed while the crawl runs. A crawl and its pages are kept for 7 days after the job ends.

What is charged

Each page read with status: ok is charged once. Failed and skipped pages are free. A cancelled crawl is charged for the pages read before the cancel took effect.

Units: crawl_page. usage.items in the response lists them.

Start a crawl of one site

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

Planned. Until it ships, calls return 501 api_not_implemented.

Headers

NameTypeDescription
Idempotency-Keystring1 to 128 bytes; a retry with the same key and body within 24 hours returns the same job. 1 to 128 characters.

Body

NameTypeDescription
urlrequiredstringPublic http(s) URL, at most 2048 bytes. At most 2048 characters.
limitinteger1 to 10,000. Default 100.
max_depthinteger0 to 20. Default 3.
include_pathsarray of stringAt most 50 items.
exclude_pathsarray of stringAt most 50 items.
include_subdomainsboolean Default false.
use_sitemapsboolean Default true.
ignore_queryboolean Default true.
formatstringOne of markdown, text, html. Default markdown.
modestringOne of main, full. Default main.
max_charsinteger1000 to 500,000. Default 20000.
include_metadataboolean Default true.
webhook_urlstringPublic https URL that receives the final job object, signed with webhook_secret. At most 500 characters.
metadataobjectYour own string values, echoed on the job; at most 4 KB.

Example request

curl https://api.websearch.fast/v1/web/crawl \
  -H "Authorization: Bearer $WEBSEARCH_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://docs.example.org/",
    "limit": 200,
    "include_paths": ["/guide/**"],
    "max_depth": 3
  }'
import os
import uuid
import httpx

response = httpx.post(
    "https://api.websearch.fast/v1/web/crawl",
    headers={"Authorization": f"Bearer {os.environ['WEBSEARCH_API_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
    json={
        "url": "https://docs.example.org/",
        "limit": 200,
        "include_paths": ["/guide/**"],
        "max_depth": 3,
    },
    timeout=60,
)
response.raise_for_status()
print(response.json())
const response = await fetch("https://api.websearch.fast/v1/web/crawl", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WEBSEARCH_API_KEY}`,
    "Idempotency-Key": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: "https://docs.example.org/",
    limit: 200,
    include_paths: ["/guide/**"],
    max_depth: 3,
  }),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());

Response fields

Job created.

NameTypeDescription
objectrequiredstringAlways web.crawl.
idrequiredstringAt most 64 characters. Starts with wc_.
statusrequiredstringOne of queued, running, succeeded, failed, cancelled.
stop_reasonstringOne of completed, budget, limit, cancelled, deadline, error.
created_atrequiredinteger
started_atinteger
completed_atinteger
inputrequiredobject
usagerequiredobject
Show fields
NameTypeDescription
itemsrequiredarray of object
Show fields
NameTypeDescription
unitrequiredstringBillable unit, for example search_web, content_page, fetch_page, geocode, autocomplete, knowledge.
countrequiredinteger
errorobject
Show fields
NameTypeDescription
coderequiredstring
messagestring
poll_after_msinteger
webhook_secretstringOnly in the create response, when webhook_url was set.
metadataobject
expires_atinteger
progressobject
Show fields
NameTypeDescription
discoveredinteger
queuedinteger
readinteger
failedinteger
skipped_robotsinteger
skipped_scopeinteger

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.
409idempotency_conflict or request_in_progress. Not charged.
413read_request_body_failed: the request body is over the limit. Not charged.
422fetch_failed, site_refused, page_too_large or extraction_failed. 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.

Get a crawl job

GET https://api.websearch.fast/v1/web/crawl/{id}

Planned. Until it ships, calls return 501 api_not_implemented.

Path parameters

NameTypeDescription
idrequiredstringStarts with wc_.

Example request

curl https://api.websearch.fast/v1/web/crawl/wc_01JD7R4K8P \
  -H "Authorization: Bearer $WEBSEARCH_API_KEY"
import os
import httpx

response = httpx.get(
    "https://api.websearch.fast/v1/web/crawl/wc_01JD7R4K8P",
    headers={"Authorization": f"Bearer {os.environ['WEBSEARCH_API_KEY']}"},
    timeout=60,
)
response.raise_for_status()
print(response.json())
const response = await fetch("https://api.websearch.fast/v1/web/crawl/wc_01JD7R4K8P", {
  method: "GET",
  headers: {
    Authorization: `Bearer ${process.env.WEBSEARCH_API_KEY}`,
  },
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());

Response fields

The job.

NameTypeDescription
objectrequiredstringAlways web.crawl.
idrequiredstringAt most 64 characters. Starts with wc_.
statusrequiredstringOne of queued, running, succeeded, failed, cancelled.
stop_reasonstringOne of completed, budget, limit, cancelled, deadline, error.
created_atrequiredinteger
started_atinteger
completed_atinteger
inputrequiredobject
usagerequiredobject
Show fields
NameTypeDescription
itemsrequiredarray of object
Show fields
NameTypeDescription
unitrequiredstringBillable unit, for example search_web, content_page, fetch_page, geocode, autocomplete, knowledge.
countrequiredinteger
errorobject
Show fields
NameTypeDescription
coderequiredstring
messagestring
poll_after_msinteger
webhook_secretstringOnly in the create response, when webhook_url was set.
metadataobject
expires_atinteger
progressobject
Show fields
NameTypeDescription
discoveredinteger
queuedinteger
readinteger
failedinteger
skipped_robotsinteger
skipped_scopeinteger

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.

Pages of a crawl

GET https://api.websearch.fast/v1/web/crawl/{id}/pages

Planned. Until it ships, calls return 501 api_not_implemented.

Path parameters

NameTypeDescription
idrequiredstringStarts with wc_.

Query parameters

NameTypeDescription
starting_afterstringnext_cursor of the previous page.
limitinteger1 to 100. Default 20.
statusstringOne of ok, failed, all. Default ok.

Example request

curl "https://api.websearch.fast/v1/web/crawl/wc_01JD7R4K8P/pages?limit=20" \
  -H "Authorization: Bearer $WEBSEARCH_API_KEY"
import os
import httpx

response = httpx.get(
    "https://api.websearch.fast/v1/web/crawl/wc_01JD7R4K8P/pages",
    headers={"Authorization": f"Bearer {os.environ['WEBSEARCH_API_KEY']}"},
    params={
        "limit": 20,
    },
    timeout=60,
)
response.raise_for_status()
print(response.json())
const response = await fetch("https://api.websearch.fast/v1/web/crawl/wc_01JD7R4K8P/pages?limit=20", {
  method: "GET",
  headers: {
    Authorization: `Bearer ${process.env.WEBSEARCH_API_KEY}`,
  },
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());

Response fields

A page of results, oldest first.

NameTypeDescription
objectrequiredstringAlways list.
datarequiredarray of object
Show fields
NameTypeDescription
requested_urlrequiredstring
urlstringFinal URL after redirects. For now the requested URL, because the reader does not report the final one yet.
statusrequiredstringOne of ok, failed.
errorobject
Show fields
NameTypeDescription
coderequiredstring
messagerequiredstring
http_statusinteger
content_typestring
titlestring
contentstring
formatstringOne of markdown, text, html.
charsinteger
truncatedboolean
extractionstringNeutral label of how the text was taken. New values can appear. One of article, full_page, document, feed, plain, structured.
languagestring
published_atstring
metadataobject
Show fields
NameTypeDescription
descriptionstring
authorstring
site_namestring
canonical_urlstring
image_urlstring
keywordsarray of string
metaobjectMeta name and property tags, at most 100.
json_ldarray of objectAt most 20 items.
imagesarray of objectAt most 200 items.
Show fields
NameTypeDescription
urlrequiredstring
altstring
widthinteger
heightinteger
pdf_pagesinteger
relevant_passagesarray of string
fetched_atinteger
depthinteger
has_morerequiredboolean
next_cursorstring

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.

Cancel a crawl

POST https://api.websearch.fast/v1/web/crawl/{id}/cancel

Planned. Until it ships, calls return 501 api_not_implemented.

Path parameters

NameTypeDescription
idrequiredstringStarts with wc_.

Example request

curl -X POST https://api.websearch.fast/v1/web/crawl/wc_01JD7R4K8P/cancel \
  -H "Authorization: Bearer $WEBSEARCH_API_KEY"
import os
import httpx

response = httpx.post(
    "https://api.websearch.fast/v1/web/crawl/wc_01JD7R4K8P/cancel",
    headers={"Authorization": f"Bearer {os.environ['WEBSEARCH_API_KEY']}"},
    timeout=60,
)
response.raise_for_status()
print(response.json())
const response = await fetch("https://api.websearch.fast/v1/web/crawl/wc_01JD7R4K8P/cancel", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WEBSEARCH_API_KEY}`,
  },
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());

Response fields

The job.

NameTypeDescription
objectrequiredstringAlways web.crawl.
idrequiredstringAt most 64 characters. Starts with wc_.
statusrequiredstringOne of queued, running, succeeded, failed, cancelled.
stop_reasonstringOne of completed, budget, limit, cancelled, deadline, error.
created_atrequiredinteger
started_atinteger
completed_atinteger
inputrequiredobject
usagerequiredobject
Show fields
NameTypeDescription
itemsrequiredarray of object
Show fields
NameTypeDescription
unitrequiredstringBillable unit, for example search_web, content_page, fetch_page, geocode, autocomplete, knowledge.
countrequiredinteger
errorobject
Show fields
NameTypeDescription
coderequiredstring
messagestring
poll_after_msinteger
webhook_secretstringOnly in the create response, when webhook_url was set.
metadataobject
expires_atinteger
progressobject
Show fields
NameTypeDescription
discoveredinteger
queuedinteger
readinteger
failedinteger
skipped_robotsinteger
skipped_scopeinteger

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.