XRToken API Docs

Web Search

Web search API — per-call billing, structured page results

API Configuration
After saving, the Try It panel below sends real requests with this key.
Base: api.xrtoken.ai

Get web results for a query in one request. Typical uses: agent tools, RAG retrieval, research aggregation.

  • Endpoint: POST /v1/search
  • Auth: Authorization: Bearer tr-... (same as other /v1 APIs)
  • Billing: Per successful call; failures are not charged. See Model Marketplace or GET /v1/models for price.

Field details: Web Search API.

Search types (Type)

TypeModel IDNotes
webdoubao-web-searchWeb search; only SearchType=web in this release
globaldoubao-global-searchGlobal search; request fields differ from web

Select the product line with body Type. Models appear in GET /v1/models (model_type: search).

Quick start

export XRT_API_KEY="tr-xxxxxxxx"
export XRT_BASE="https://api.xrtoken.net"   # CN

# Web search
curl -sS "$XRT_BASE/v1/search" \
  -H "Authorization: Bearer $XRT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "Type": "web",
    "Query": "Beijing day trip ideas",
    "Count": 5,
    "SearchType": "web"
  }'

# Global search
curl -sS "$XRT_BASE/v1/search" \
  -H "Authorization: Bearer $XRT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "Type": "global",
    "Query": "openai research",
    "DocCount": 5,
    "MaxSnippetLength": 500
  }'

Python:

import os
import requests

BASE = os.environ.get("XRT_BASE", "https://api.xrtoken.net")
KEY = os.environ["XRT_API_KEY"]

resp = requests.post(
    f"{BASE}/v1/search",
    headers={
        "Authorization": f"Bearer {KEY}",
        "Content-Type": "application/json",
    },
    json={
        "Type": "web",
        "Query": "tech news today",
        "Count": 10,
        "SearchType": "web",
    },
    timeout=60,
)
resp.raise_for_status()
data = resp.json()
for item in (data.get("Result") or {}).get("WebResults") or []:
    print(item.get("Title"), item.get("Url"))

Request fields

Gateway fields

FieldRequiredDescription
TypeYesweb or global
modelNoIf set, must match Type

Type = web

FieldRequiredDescription
QueryYesQuery string, 1–100 characters
SearchTypeNoDefaults to web; image is not supported yet
CountNoResult count, max 50, default 10
FilterNoNeedContent / NeedUrl / Sites / BlockHosts / AuthInfoLevel
TimeRangeNoOneDay / OneWeek / OneMonth / OneYear or date range
QueryControl.QueryRewriteNoQuery rewrite (adds latency)
ContentFormatsNotext / markdown
IndustryNofinance / game / gov

Type = global

FieldRequiredDescription
QueryYesQuery string, 1–100 characters
DocCountNoResult count, max 20, default 10
MaxSnippetLengthNoMax tokens per snippet (recommend ≤1000, max 3000)
MaxImageCountPerDocNoMax images per doc, default 3, max 10

Response

  • HTTP is usually 200; body is JSON with ResponseMetadata and Result.
  • Response header X-Request-Id (tr-req-...) for support.
  • web: Result.WebResults[] (Title / Url / Snippet / Summary / Content).
  • global: Result.Documents[] and TotalDocCount.

For LLM contexts prefer Summary when present; Snippet is for list UI only.

Billing

ItemRule
MethodPer successful call
Result countDoes not change the unit price
FailuresValidation errors, insufficient balance, service errors: no charge
PriceSee Model Marketplace or GET /v1/models

See Billing for freeze/settle details.

Errors

HTTPTypical cause
400Missing Type/Query, SearchType=image, DocCount>20, model/Type mismatch
401Invalid API key
402Insufficient balance
429Rate limited
502 / 503Temporary service issue

Local validation example:

{ "error": "Query is required", "type": "invalid_request_error" }

Limits

  • CN edition in this release (api.xrtoken.net); check GET /v1/models for availability.
  • Image search (SearchType=image) is not enabled.
  • Synchronous API — no async task polling.
  • Control concurrency reasonably.

On this page