DeepSeek Search & Fetch API: cURL and Python quickstart

Find pages with Search, fetch one selected URL as Markdown, then decide how your app uses that evidence. The examples keep provider credentials in a local environment variable.

By ChinaGenAI · Updated

DeepSeek Search and Fetch are standalone JSON endpoints. Search discovers pages; Fetch retrieves one selected page as Markdown. Your application decides which result to fetch and whether to pass its content to a model. These calls do not use the Chat Completions endpoint.

Build a local request

Preview only · no key or API call

Query: 1–128 Unicode characters. Results: 1–50. Count does not change the per-request fee.

Request previewPOST

https://api.deepseek.com/v1/tools/search

JSON body

{
  "query": "DeepSeek Search API site:api-docs.deepseek.com after:2026-10-01",
  "count": 3,
  "need_content": false
}

Bash / zsh command

curl https://api.deepseek.com/v1/tools/search \
  -H "Authorization: Bearer $DEEPSEEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"DeepSeek Search API site:api-docs.deepseek.com after:2026-10-01","count":3,"need_content":false}'

The copied command reads DEEPSEEK_API_KEY from your terminal environment. Search or Fetch fees apply only if you run it and the request returns billable data.

1. Search for pages

Send a query from 1 to 128 Unicode characters. count defaults to 10 and accepts 1–50 results. The example uses site: and after: query operators; you can also use an exact phrase in quotation marks, -site:, before: and lang:.

DeepSeek Search API cURL request
curl https://api.deepseek.com/v1/tools/search \
  -H "Authorization: Bearer $DEEPSEEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"DeepSeek Search API site:api-docs.deepseek.com after:2026-10-01","count":3,"need_content":false}'

A successful response contains a results array. Each result can include a title, URL, snippet, model-oriented summary, optional page content, publication date and authority fields. An empty array is a valid no-match result. The content field is empty when need_content is false, and may also be unavailable for a result.

2. Fetch one result

Choose a result URL, review it, then send that URL to Fetch. The request accepts one HTTP or HTTPS page URL; a successful response contains the page title and Markdown content.

DeepSeek Fetch API cURL request
curl https://api.deepseek.com/v1/tools/fetch \
  -H "Authorization: Bearer $DEEPSEEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/article"}'

Replace the example URL with a URL returned by Search. If you already have a page URL, you can call Fetch directly without a Search request.

Search, then fetch with Python

This standard-library example reads the key from the DEEPSEEK_API_KEY environment variable, prints search results, then fetches the first result if one exists. It makes up to two successful billable requests when both calls return usable data. It does not ask a model to choose or run a tool.

Python Search-to-Fetch flow
import json
import os
from urllib.request import Request, urlopen

BASE_URL = "https://api.deepseek.com"
API_KEY = os.environ["DEEPSEEK_API_KEY"]

def post_json(path, payload):
    request = Request(
        BASE_URL + path,
        data=json.dumps(payload).encode("utf-8"),
        headers={
            "Authorization": f"Bearer {API_KEY}",
            "Content-Type": "application/json",
        },
        method="POST",
    )
    with urlopen(request, timeout=30) as response:
        return json.load(response)

search = post_json(
    "/v1/tools/search",
    {"query": "DeepSeek Search API site:api-docs.deepseek.com", "count": 3},
)
results = search.get("results", [])

for index, result in enumerate(results, start=1):
    print(index, result["title"], result["url"])
    print(result.get("snippet", ""))

if results:
    page = post_json("/v1/tools/fetch", {"url": results[0]["url"]})
    print(page.get("title", ""))
    print(page.get("content", "")[:4000])

Cost and common errors

  • Each endpoint is listed at $0.75 per 1,000 successful requests. A successful Search followed by a successful Fetch is $0.0015 at the published rate. Result count and model-token usage do not set these request fees.
  • A request is billable only when HTTP 200 returns non-empty Search results or Fetch page content. Empty Search results and failed or timed-out requests are not billed.
  • Search has an account-level limit of 100 requests per second. Fetch has 25 per second plus a per-domain limit. These are separate from model concurrency limits.
  • 401: check the DeepSeek key. 402: the account balance is insufficient. 403 or 404 on Fetch: check the target site, access policy, content type and whether Markdown can be extracted. 429, 408 or a 5xx: wait before retrying. For other 4xx responses, correct the request instead of repeating it.

The API reference says server-side Search and Fetch calls made through DeepSeek Harness, Claude Code or Codex are free “currently,” while also listing a 1 November 2026 billing start. That date has passed, and the live pricing and guide pages retain the conflicting wording. See the current documented billing note before relying on a managed-tool free period.

Official references

Search & Fetch API guide · Models and current pricing · 17 October Search & Fetch announcement · Estimate DeepSeek token and request costs

Official API documentation checked 3 November 2026. These are copyable examples; this site did not use a provider key or send Search, Fetch or model requests.