# Search Capabilities API

GET /v1/sub-domains

Discover available capabilities and parameter definitions for one or more known domains. Use the returned sub_domain as the Search tag, fill required parameters, then run a vertical search. Discovery does not consume free or paid search quota.

## Request examples

Repeat the `domain` query parameter. Do not use `domains` or a comma-separated list.

### cURL

### cURL · Discover code and finance

```bash
curl 'https://api.anysearch.com/v1/sub-domains?domain=code&domain=finance' \
  -H "Authorization: Bearer YOUR_ANYSEARCH_API_KEY"
```

### Python

### Python · Discover code and finance

```python
import os
import requests

response = requests.get(
    "https://api.anysearch.com/v1/sub-domains?domain=code&domain=finance",
    headers={
        "Authorization": f"Bearer {os.environ['ANYSEARCH_API_KEY']}",
    },
    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

### JavaScript · Discover code and finance

```javascript
const response = await fetch(
  "https://api.anysearch.com/v1/sub-domains?domain=code&domain=finance",
  {
    method: "GET",
    headers: {
      Authorization: `Bearer ${process.env.ANYSEARCH_API_KEY}`,
    },
    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

### Go · Discover code and finance

```go
package main

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

func main() {
	req, err := http.NewRequest(
		http.MethodGet,
		"https://api.anysearch.com/v1/sub-domains?domain=code&domain=finance",
		nil,
	)
	if err != nil {
		panic(err)
	}

	req.Header.Set("Authorization", "Bearer "+os.Getenv("ANYSEARCH_API_KEY"))

	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

### Rust · Discover code and finance

```rust
use reqwest::blocking::Client;
use serde_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
        .get("https://api.anysearch.com/v1/sub-domains?domain=code&domain=finance")
        .bearer_auth(api_key)
        .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().as_u16()
        )
        .into());
    }

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

    Ok(())
}
```

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

API Key is optional. These examples include a Key.

## Use a discovered capability in Search

1. Select a known domain, such as `domain=finance`.
2. Read `data.domains[].sub_domains[].sub_domain` as the Search `tag`.
3. Fill parameters using `params.required` and conditions in description.
4. Submit query, tag and params to `POST /v1/search`.

### Example: turn a discovered finance capability into a search request

After discovering the finance domain, read the finance.quote definition: type is required. Select type=stock and set symbol=AAPL to construct the corresponding Search request.

### Request example · POST /v1/search

```json
{
  "query": "Apple stock price",
  "tag": "finance.quote",
  "params": {
    "type": "stock",
    "symbol": "AAPL"
  },
  "max_results": 5
}
```

[Read the finance.quote parameter definitions →](/docs/api-endpoints/v1-sub-domains)

## General-search tags

The general domain exposes only `general.general` for general search, with no dedicated params.

A general Search request can omit tag and submit query alone. To specify the general-search tag explicitly, use `general.general`.

## Request parameters

| Parameter | Type | Required | Format and behavior |
| --- | --- | --- | --- |
| [domain](/docs/api-endpoints/v1-sub-domains#param-domain) | `string[]` | Yes | Repeat the query parameter: `?domain=code&domain=finance`. Duplicate values do not create duplicate entries. |
| Unknown domain | — | — | HTTP 200 with an empty `data.domains` array. |

### Valid request path

```
GET /v1/sub-domains?domain=code&domain=finance
```

## Response fields

| Field | Meaning | Use in Search |
| --- | --- | --- |
| `data.domains` | Capabilities grouped by requested domain | Choose a domain. |
| `sub_domains` | Available capability definitions | Choose a capability. |
| `sub_domain` | Complete capability tag | `tag` |
| `params` | Definitions keyed by parameter name; may be omitted if empty | `params` |
| `params.*.description` | Meaning, allowed values and conditions | Provide valid values. |
| `params.*.required` | Required flag | Check for missing values. |
| `params.*.sort_order` | Display order | Sort the fields. |

### REST response shape · Selected capabilities and parameters

```json
{
  "code": 0,
  "message": "success",
  "request_id": "7d6f4e91-2a83-4c5b-9f10-6e8a3d27b541",
  "data": {
    "domains": [
      {
        "domain": "code",
        "description": "Developer documentation and code search",
        "sub_domains": [
          {
            "sub_domain": "code.snippet",
            "description": "Search real code implementations",
            "params": {
              "lang": {
                "description": "Filter by programming language",
                "required": false,
                "sort_order": 0
              }
            }
          }
        ]
      },
      {
        "domain": "finance",
        "description": "Financial data and market information",
        "sub_domains": [
          {
            "sub_domain": "finance.quote",
            "description": "Real-time and historical quotes",
            "params": {
              "type": {
                "description": "Asset type. Values: stock, forex, crypto, commodity, index, etf",
                "required": true,
                "sort_order": 0
              }
            }
          }
        ]
      }
    ]
  }
}
```

## Error codes

HTTP status codes and their meanings. `error_code` is optional; inspect the actual response.

| HTTP status | Meaning |
| --- | --- |
| 400 | Missing domain query parameter. |
| 429 | Request rate limit exceeded. |
| 502 | Unable to load capability definitions. |

### 400 · Missing domain

```json
{
  "code": -1,
  "message": "At least one domain parameter is required.",
  "request_id": "7d6f4e91-2a83-4c5b-9f10-6e8a3d27b541"
}
```

## FAQ

### Can I omit domain to read the entire catalog?

The REST endpoint requires at least one domain and returns 400 if it is missing. Select domains from this directory first.

### What is the paper-search tag?

The capability definitions use academic.paper. Do not use the older publication.paper example as a confirmed tag.

### Does no required flag mean every parameter can always be omitted?

Not necessarily. Read conditions in the description. The flight-status departure field has a required/Optional conflict that is preserved in the definitions.

### Can I send the tool’s domains array directly to REST?

No. REST uses repeated domain query parameters. The tool and REST entry points have different outer arguments.

<!-- docs-navigation -->

## Documentation navigation

- [Source](https://anysearch.com/docs/api-endpoints/v1-sub-domains)
- Index: [Docs index](https://anysearch.com/docs.md)
- Parent: [API Endpoints](https://anysearch.com/docs.md/api-endpoints)
- Previous: [/v1/search](https://anysearch.com/docs.md/api-endpoints/v1-search)
- Next: [/v1/extract](https://anysearch.com/docs.md/api-endpoints/v1-extract)
