# API Endpoints

AnySearch provides three APIs for search, capability discovery and public URL content extraction. Use /v1/search for general or vertical queries, and /v1/sub-domains to discover vertical capabilities and parameters when needed. With a public webpage URL, optionally call /v1/extract directly to retrieve its content.

## Create an account and API Key

No API Key? Use a registration endpoint to create an account and a default key. Registration does not require Authorization.

### Email registration

`POST /v1/auth/email/register`

Create an account and receive a default API Key in one request.

### Minimal request · cURL

```bash
curl -X POST https://api.cn.anysearch.com/v1/auth/email/register \
  -H "Content-Type: application/json" \
  -d '{
  "email": "dev@example.com"
}'
```

**Read after success** `data.api_key.key` The plaintext key is returned once. Save it securely immediately.

View success response

### Success response · excerpt

```json
{
  "code": 0,
  "message": "success",
  "data": {
    "username": "dev@example.com",
    "email": "dev@example.com",
    "api_key": {
      "key": "as_sk_5d1f0c9a7b3e4d2f8a6c1b0e9d7f3a52",
      "name": "default"
    }
  }
}
```

### Agent registration

`POST /v1/api/bot/challenge`
`POST /v1/api/bot/register`

Get a challenge, solve it, then submit the answer. Suitable for autonomous agents.

challenge → solve → register

### Step 1 · Get a challenge

```bash
curl -X POST https://api.cn.anysearch.com/v1/api/bot/challenge \
  -H "Content-Type: application/json" \
  -d '{}'
```

### Step 2 · Submit your answer

```bash
curl -X POST https://api.cn.anysearch.com/v1/api/bot/register \
  -H "Content-Type: application/json" \
  -d '{
  "challenge_id": "ch_9c1f4b2a7d0e4f6b8a3c5d9e1f2a4b6c",
  "answer": "89.05"
}'
```

**Read after success** `data.api_key` The plaintext key is returned once. Save it securely immediately.

View success response

### Success response (example)

```json
{
  "code": 0,
  "message": "success",
  "data": {
    "username": "as_auto_q3Jk9xLm2Ab",
    "password": "K7mQ2xRtbV9d",
    "api_key": "as_sk_5d1f0c9a7b3e4d2f8a6c1b0e9d7f3a52",
    "expires_at": null
  }
}
```

**Three reminders for registration:** Check the response body field `code`; some email registration failures still return HTTP 200. Do not log the full response. The key and password are returned once. For registration, `request_id` is mainly returned in the `X-Request-ID` response header.

## How the APIs work together

WHEN NEEDED · DISCOVER

### Discover capabilities

For vertical search, read available tags and parameters first. General search can start with a query.

[GET /v1/sub-domains](/docs/api-endpoints/v1-sub-domains)

SEARCH

### Run a search

Submit query, with a tag and capability parameters when needed.

[POST /v1/search](/docs/api-endpoints/v1-search)

RESULTS

### Use the results

Read returned titles, URLs, snippets and available content.

[Response fields](/docs/api-endpoints/v1-search#response)

WHEN NEEDED · EXTRACT

### Extract content

Call directly with a public webpage URL, or optionally extract content from a search result URL for summarization or analysis.

[POST /v1/extract](/docs/api-endpoints/v1-extract)

## Choose an API

| Task | API | Quota and next step |
| --- | --- | --- |
| General or vertical search | POST [/v1/search](/docs/api-endpoints/v1-search) | Uses search quota; extract content afterward if needed. |
| Discover tags and parameters | GET [/v1/sub-domains](/docs/api-endpoints/v1-sub-domains) | Does not consume free or paid search quota; use the definitions in Search. |
| Read public webpage content | POST [/v1/extract](/docs/api-endpoints/v1-extract) | Subject to quota; consult the applicable billing rules. |

## Complete call example

QUERY: 全球AI芯片产业研究

### 01 Discover capabilities

### Request · GET /v1/sub-domains

```bash
curl "https://api.cn.anysearch.com/v1/sub-domains?domain=academic"
```

### Response · application/json

```json
{
  "code": 0,
  "message": "success",
  "request_id": "<DISCOVERY_REQUEST_ID>",
  "data": {
    "domains": [
      {
        "domain": "academic",
        "description": "Scholarly paper search, biomedical literature, preprints, citations, datasets",
        "sub_domains": [
          {
            "sub_domain": "academic.paper",
            "description": "Cross-discipline paper search by keyword, title, author, institution with metadata and open access links"
          },
          {
            "sub_domain": "academic.citation",
            "description": "Citation relationships, citation counts, reference lists by DOI or title"
          }
        ]
      }
    ]
  }
}
```

Take `data.domains[0].sub_domains[0].sub_domain` → **`academic.paper`** as the tag for the next step

### 02 Vertical search

### Request · POST /v1/search

```bash
curl -X POST https://api.cn.anysearch.com/v1/search \
  -H "Authorization: Bearer YOUR_ANYSEARCH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "query": "全球AI芯片产业研究",
  "tag": "academic.paper",
  "max_results": 5
}'
```

### Response · application/json

```json
{
  "code": 0,
  "message": "success",
  "request_id": "<VERTICAL_SEARCH_REQUEST_ID>",
  "data": {
    "results": [
      {
        "title": "Artificial Intelligence (AI) Chip Market Size, Share, Trends, and Forecast (2024–2030)…",
        "url": "https://doi.org/10.5281/zenodo.17599539",
        "snippet": "The global Artificial Intelligence (AI) Chip Market, valued at USD 52.92 billion in 2024, is projected to reach USD 295.56 billion by 2030, growing at a CAGR of 33.2% from 2025 to 2030."
      }
    ],
    "metadata": {
      "total_results": 5,
      "search_time_ms": 827
    }
  }
}
```

Take `data.results[0].url` → Pass it unchanged to Extract as `url`

### 03 Extract text

### Request · POST /v1/extract

```bash
curl -X POST https://api.cn.anysearch.com/v1/extract \
  -H "Authorization: Bearer YOUR_ANYSEARCH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "url": "https://doi.org/10.5281/zenodo.17599539"
}'
```

### Response · application/json

```json
{
  "code": 0,
  "message": "success",
  "request_id": "<EXTRACT_REQUEST_ID>",
  "data": {
    "url": "https://doi.org/10.5281/zenodo.17599539",
    "title": "Artificial Intelligence (AI) Chip Market Size, Share, Trends, and Forecast (2024–2030)…",
    "content": "Published November 13, 2025 | Version v1 … The global Artificial Intelligence (AI) Chip Market, valued at USD 52.92 billion in 2024, is projected to reach USD 295.56 billion by 2030, growing at a CAGR of 33.2% from 2025 to 2030. Rising adoption of AI-driven technologies …"
  }
}
```

Snippet vs. source text

**SEARCH · data.results\[0\].snippet**

> The global Artificial Intelligence (AI) Chip Market, valued at USD 52.92 billion in 2024, is projected to reach USD 295.56 billion by 2030, growing at a CAGR of 33.2% from 2025 to 2030.

**EXTRACT · data.content (excerpt)**

> Published November 13, 2025 | Version v1 …
>
> The global Artificial Intelligence (AI) Chip Market, valued at USD 52.92 billion in 2024, is projected to reach USD 295.56 billion by 2030, growing at a CAGR of 33.2% from 2025 to 2030.
>
> Rising adoption of AI-driven technologies …

## Request examples

General search only needs query. The examples below show the same request in five languages. See the Search page for vertical search examples.

### cURL · macOS / Linux / Git Bash

```bash
curl -X POST https://api.cn.anysearch.com/v1/search \
  -H "Authorization: Bearer YOUR_ANYSEARCH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "query": "Global AI Semiconductor Industry Analysis",
  "max_results": 5
}'
```

### Python 3 · requests

```python
import os
import requests

response = requests.post(
    "https://api.cn.anysearch.com/v1/search",
    headers={
        "Authorization": f"Bearer {os.environ['ANYSEARCH_API_KEY']}",
    },
    json={
        "query": "Global AI Semiconductor Industry Analysis",
        "max_results": 5,
    },
    timeout=30,
)

if not response.ok:
    request_id = response.headers.get("X-Request-ID", "unknown")
    raise RuntimeError(
        f"Request failed: HTTP {response.status_code}; request_id={request_id}"
    )

result = response.json()
print(result["data"])
```

### JavaScript · Node.js 18+

```javascript
const response = await fetch("https://api.cn.anysearch.com/v1/search", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.ANYSEARCH_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: "Global AI Semiconductor Industry Analysis",
    max_results: 5,
  }),
  signal: AbortSignal.timeout(30_000),
});

if (!response.ok) {
  const requestId = response.headers.get("X-Request-ID") ?? "unknown";
  throw new Error(
    `Request failed: HTTP ${response.status}; request_id=${requestId}`
  );
}

const result = await response.json();
console.log(result.data);
```

### Go · Standard library

```go
package main

import (
	"encoding/json"
	"fmt"
	"net/http"
	"os"
	"strings"
	"time"
)

func main() {
	req, err := http.NewRequest(
		http.MethodPost,
		"https://api.cn.anysearch.com/v1/search",
		strings.NewReader(`{
			"query": "Global AI Semiconductor Industry Analysis",
			"max_results": 5
		}`),
	)
	if err != nil {
		panic(err)
	}

	req.Header.Set("Authorization", "Bearer "+os.Getenv("ANYSEARCH_API_KEY"))
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 30 * time.Second}
	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	if resp.StatusCode != http.StatusOK {
		requestID := resp.Header.Get("X-Request-ID")
		if requestID == "" {
			requestID = "unknown"
		}

		panic(fmt.Sprintf(
			"Request failed: HTTP %d; request_id=%s",
			resp.StatusCode, requestID,
		))
	}

	var result struct {
		Data json.RawMessage `json:"data"`
	}
	if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
		panic(err)
	}

	fmt.Println(string(result.Data))
}
```

### Rust · reqwest + serde_json

```rust
use reqwest::blocking::Client;
use serde_json::{json, Value};
use std::{env, error::Error, time::Duration};

fn main() -> Result<(), Box<dyn Error>> {
    let api_key = env::var("ANYSEARCH_API_KEY")?;

    let client = Client::builder()
        .timeout(Duration::from_secs(30))
        .build()?;

    let response = client
        .post("https://api.cn.anysearch.com/v1/search")
        .bearer_auth(api_key)
        .json(&json!({
            "query": "Global AI Semiconductor Industry Analysis",
            "max_results": 5,
        }))
        .send()?;

    if !response.status().is_success() {
        let request_id = response
            .headers()
            .get("X-Request-ID")
            .and_then(|value| value.to_str().ok())
            .unwrap_or("unknown");

        return Err(format!(
            "Request failed: HTTP {}; request_id={request_id}",
            response.status()
        )
        .into());
    }

    let result: Value = response.json()?;
    println!("{}", result["data"]);

    Ok(())
}
```

Base URL `https://api.cn.anysearch.com`
Content type Use `Content-Type: application/json` for POST requests.

## Browse domains and capabilities

Find the right capability for your task, then read its parameter definitions before running a vertical search.

- General search general
- Media assets resource
- Social media social\_media
- Finance finance
- Academic research academic
- Law legal
- Health health
- Business business
- Cybersecurity security
- Intellectual property ip
- Code code
- Energy energy
- Environment environment
- Agriculture agriculture
- Travel travel
- Film film
- Gaming gaming

Browse the complete capability directory

## Common response envelope

The server generates a UUID v4 `request_id` for each response and returns the same value in the `X-Request-ID` response header. A caller-supplied request ID is ignored.

| Field | Success | Error |
| --- | --- | --- |
| `code` | `0` | `-1` |
| `message` | `"success"` | Error description; HTTP 402 may include credentials. |
| `request_id` | Server-generated UUID v4 | Use for diagnostics. |
| `data` | Endpoint-specific data | Inspect the actual response. |
| `error_code` | Usually omitted | Optional stable error identifier. |

### Success envelope · data depends on the endpoint

```json
{
  "code": 0,
  "message": "success",
  "request_id": "7d6f4e91-2a83-4c5b-9f10-6e8a3d27b541",
  "data": {}
}
```

Error codes: [Search](/docs/api-endpoints/v1-search#errors), [Sub-domains](/docs/api-endpoints/v1-sub-domains#errors), [Extract](/docs/api-endpoints/v1-extract#errors).

## FAQ

### Must I discover capabilities before a general search?

No. A general search only needs query. Discover definitions when you need a specific vertical capability.

### Does format=markdown return a plain Markdown response?

No. The outer Search response remains JSON. The content field uses Markdown.

### Does capability discovery consume search quota?

No. It does not consume free or paid search quota or count as search usage. Requests may still be rate limited.

### What content can Extract read?

Public HTTP(S) pages containing HTML/XHTML, plain text, JSON or Markdown. PDF, images, audio and video are unsupported.

<!-- docs-navigation -->

## Documentation navigation

- [Source](https://www.cn.anysearch.com/docs/api-endpoints)
- Index: [Docs index](https://www.cn.anysearch.com/docs.md)
- Child / Next: [/v1/search](https://www.cn.anysearch.com/docs/api-endpoints/v1-search.md)
- Child: [/v1/sub-domains](https://www.cn.anysearch.com/docs/api-endpoints/v1-sub-domains.md)
- Child: [/v1/extract](https://www.cn.anysearch.com/docs/api-endpoints/v1-extract.md)
- Previous: [Quick Start](https://www.cn.anysearch.com/docs/quick-start.md)
