跳转到内容
EN

站内爬取

POST/tavily/crawl● 支持

Tavily 官方文档 ↗

请求体

  • urlstring必填

    The root URL to begin the crawl.

  • limitinteger可选
    默认 50

    Total number of links the crawler will process before stopping.

  • instructionsstring可选

    Natural language instructions for the crawler. When specified, the mapping cost increases to 2 API credits per 10 successful pages instead of 1 API credit per 10 pages.

  • chunks_per_sourceinteger可选
    默认 3

    Chunks are short content snippets (maximum 500 characters each) pulled directly from the source. Use chunks_per_source to define the maximum number of relevant chunks returned per source and to control the raw_content length. Chunks will appear in the raw_content field as: <chunk 1> [...] <chunk 2> [...] <chunk 3>. Available only when instructions are provided. Must be between 1 and 5.

  • max_depthinteger可选
    默认 1

    Max depth of the crawl. Defines how far from the base URL the crawler can explore.

  • max_breadthinteger可选
    默认 20

    Max number of links to follow per level of the tree (i.e., per page).

  • select_pathsarray可选
    默认 null

    Regex patterns to select only URLs with specific path patterns (e.g., /docs/.*, /api/v1.*).

  • select_domainsarray可选
    默认 null

    Regex patterns to select crawling to specific domains or subdomains (e.g., ^docs\.example\.com$).

  • exclude_pathsarray可选
    默认 null

    Regex patterns to exclude URLs with specific path patterns (e.g., /private/.*, /admin/.*).

  • exclude_domainsarray可选
    默认 null

    Regex patterns to exclude specific domains or subdomains from crawling (e.g., ^private\.example\.com$).

  • 更多参数 (7)
    • allow_externalboolean可选
      默认 true

      Whether to include external domain links in the final results list.

    • include_imagesboolean可选
      默认 false

      Whether to include images in the crawl results.

    • extract_depthstring可选
      默认 "basic"

      Advanced extraction retrieves more data, including tables and embedded content, with higher success but may increase latency. basic extraction costs 1 credit per 5 successful extractions, while advanced extraction costs 2 credits per 5 successful extractions.

      取值 basicadvanced
    • formatstring可选
      默认 "markdown"

      The format of the extracted web page content. markdown returns content in markdown format. text returns plain text and may increase latency.

      取值 markdowntext
    • include_faviconboolean可选
      默认 false

      Whether to include the favicon URL for each result.

    • timeoutnumber可选
      默认 150

      Maximum time in seconds to wait for the crawl operation before timing out. Must be between 10 and 150 seconds.

    • include_usageboolean可选
      默认 false

      Whether to include credit usage information in the response. NOTE:The value may be 0 if the total use of /extract and /map have not yet reached minimum requirements. See our Credits & Pricing documentation for details.

返回

200

调用前要求账户余额大于 0;按 Tavily 返回的 usage.credits 计费,每 credit $0.01;Tavily 未返回用量时,按本次请求可能消耗的上限计费。

错误按 Tavily 格式返回,参见 错误码

请求示例

curl
curl https://api.deepraxis.com/tavily/crawl \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://docs.tavily.com","instructions":"Find all pages on the Python SDK","limit":5}'
Python
from tavily import TavilyClient

tavily_client = TavilyClient(
    api_key="$PRAXIS_API_KEY",
    api_base_url="https://api.deepraxis.com/tavily",
)

response = tavily_client.crawl(
    "https://docs.tavily.com",
    instructions="Find all pages on the Python SDK",
    limit=5,
)
print(response)
TypeScript
import { tavily } from "@tavily/core";

const tvly = tavily({
  apiKey: "$PRAXIS_API_KEY",
  apiBaseURL: "https://api.deepraxis.com/tavily",
});

const response = await tvly.crawl("https://docs.tavily.com", {
  instructions: "Find all pages on the Python SDK",
  limit: 5,
});
console.log(response);

响应示例 200

{
  "base_url": "https://docs.tavily.com",
  "results": [
    {
      "url": "https://docs.tavily.com/sdk/python/quick-start",
      "raw_content": "```\nfrom tavily import TavilyClient from  tavily import  TavilyClient tavily_client = TavilyClient(api_key=\"tvly-YOUR_API_KEY\") tavily_client = TavilyClient(api_key =\"tvly-YOUR_API_KEY\")response = tavily_client.crawl(\" instructions=\"Find all pages on the Python SDK\") response = tavily_client.crawl(\" instructions = \"Find all pages on the Python SDK\") print(response) print(response)\n```\n\nThese examples are very simple, and you can do so much more with Tavily!\n\n## ​ Features\n\nOur Python SDK supports the full feature range of our REST API, and more. We offer both a synchronous and an asynchronous client, for increased flexibility. [...] > ## Documentation Index\n>\n> Fetch the complete documentation index at:</llms.txt>\n>\n> Use this file to discover all available pages before exploring further.\n\nTavily Docs home page\n\nHomeAgentsIntroductionAPI & SDKsEcosystemExamplesChangelogHelp\n\nPython SDK\n\n# Quickstart\n\nIntegrate Tavily’s powerful APIs natively in your Python apps.\n\nLooking for the Python SDK Reference? Head to our Python SDK Reference and learn how to use `tavily-python`.\n\n## ​ Introduction\n\nThe Python SDK allows for easy interaction with the Tavily API, offering the full range of our search functionality directly from your Python programs. Easily integrate smart search capabilities into your applications, harnessing Tavily’s powerful search features.\n\n## GitHub\n\n`/tavily-ai/tavily-python`\n\n## PyPI\n\n`tavily-python` [...] The `search` function lets you harness the full power of Tavily Search.\n The `extract` function allows you to easily retrieve web content with Tavily Extract.\n The `crawl` and `map`functions allow you to intelligently traverse websites and extract content.\n\nFor more details, head to the Python SDK Reference.\n\nResponses are generated using AI and may contain mistakes."
    },
    {
      "url": "https://docs.tavily.com/sdk/python/reference",
      "raw_content": "Request\n\n```\nfrom tavily import TavilyClient from  tavily import  TavilyClient # Step 1. Instantiating your TavilyClient# Step 1. Instantiating your TavilyClienttavily_client = TavilyClient(api_key=\"tvly-YOUR_API_KEY\") tavily_client = TavilyClient(api_key =\"tvly-YOUR_API_KEY\") # Step 2. Defining the starting URL of the crawl# Step 2. Defining the starting URL of the crawlurl = \" url = \" # Step 3. Executing the crawl with some guidance parameters# Step 3. Executing the crawl with some guidance parametersresponse = tavily_client.crawl(url, instructions=\"Find information on the Python SDK\") response = tavily_client.crawl(url, instructions = \"Find information on the Python SDK\") # Step 4. Printing the crawled results# Step 4. Printing the crawled resultsprint(response) print(response)\n``` [...] > ## Documentation Index\n>\n> Fetch the complete documentation index at:</llms.txt>\n>\n> Use this file to discover all available pages before exploring further.\n\nTavily Docs home page\n\nHomeAgentsIntroductionAPI & SDKsEcosystemExamplesChangelogHelp\n\nPython SDK\n\n# SDK Reference\n\nIntegrate Tavily’s powerful APIs natively in your Python apps.\n\n## ​ Instantiating a client\n\nTo interact with Tavily in Python, you must instatiate a client with your API key. For greater flexibility, we provide both a synchronous and an asynchronous client class. Once you have instantiated a client, call one of our supported methods (detailed below) to access the API.\n\n### ​ Synchronous Client [...] Messi?\\\")\\n\\nprint(response)\\n\\n```\\n\\nYou can also easily extract content from URLs:\\n\\nCopy\\n\\n```\\nfrom tavily import TavilyClient\\n\\ntavily_client = TavilyClient(api_key=\\\"tvly-YOUR_API_KEY\\\")\\nresponse = tavily_client.extract(\\\" also allows you to perform a smart crawl starting at a given URL.\\n\\nCopy\\n\\n```\\nfrom tavily import TavilyClient\\n\\ntavily_client = TavilyClient(api_key=\\\"tvly-YOUR_API_KEY\\\")\\nresponse = tavily_client.crawl(\\\" query=\\\"Python SDK\\\")\\n\\nprint(response)\\n\\n```\\n\\nThese examples are very simple, and you can do so much more with Tavily!\\n\\n## \\u200b Features\\n\\nOur Python SDK supports the full feature range of our REST API, and more. We offer both a synchronous and an asynchronous client, for increased flexibility.\\n\\n- The `search` function lets you harness the"
    },
    {
      "url": "https://pypi.org/project/tavily-python",
      "raw_content": null
    }
  ],
  "response_time": 4.49,
  "usage": {
    "credits": 1
  },
  "request_id": "58f31cd5-ecb3-430c-924a-7c4105948351"
}

响应

HTTP 200

Crawl results returned successfully

application/json

名称 类型 说明
base_url string The base URL that was crawled.
results array<object> A list of extracted content from the crawled URLs.
results[].url string The URL that was crawled.
results[].raw_content string The full content extracted from the page. When query is provided, contains the top-ranked chunks joined by [...] separator.
results[].favicon string The favicon URL for the result.
response_time number Time in seconds it took to complete the request.
usage object Credit usage details for the request.
request_id string A unique request identifier you can share with customer support to help resolve issues with specific requests.