Skip to main content

anysearch-py

Typed Python clients for AnySearch.

Client and AsyncClient call the REST Web API. MCPClient and AsyncMCPClient call the remote MCP tools/call API. All clients share Pydantic models, validation, and serialization logic.

API Methods
REST search, extract, get_sub_domains
MCP search, batch_search, extract, get_sub_domains, score, call_tool

The API key is optional when the AnySearch endpoint permits anonymous access.

Requires Python 3.14 or newer. Contracts were checked against the official REST documentation, the live domain directory, and MCP tools/list on 2026-10-28.

Install

uv add anysearch-py
from anysearch_py import Client, SearchTag

with Client(api_key="YOUR_ANYSEARCH_API_KEY") as client:
    response = client.search(
        "Python 3.15 new features",
        tag=SearchTag.CODE_DOC,
        params={"library": "python"},
    )

print(response.data.results[0].url)

max_results must be an integer from 1 to 10. Result titles may be empty, and snippet and content may be None when unavailable. output_format="markdown" puts Markdown in result content; the response remains a typed JSON envelope.

REST Domain Discovery

Discover current tags and their parameter definitions before choosing a vertical search.

from anysearch_py import Client, Domain

with Client(api_key="YOUR_ANYSEARCH_API_KEY") as client:
    response = client.get_sub_domains(domains=[Domain.CODE, Domain.FINANCE])

for domain in response.data.domains:
    for capability in domain.sub_domains:
        print(capability.sub_domain, capability.params)

The SDK sends repeated domain query parameters for multiple domains. Unknown REST domains return an empty capability list. REST search accepts discovered domain.sub_domain strings as well as SearchTag values.

REST Extraction

from anysearch_py import Client

with Client(api_key="YOUR_ANYSEARCH_API_KEY") as client:
    response = client.extract("https://example.com")

print(response.data.title)
print(response.data.content)

Extraction supports HTML, plain text, JSON, and Markdown from public HTTP or HTTPS URLs. See the extract endpoint for request limits and errors.

import asyncio

from anysearch_py import AsyncClient


async def main() -> None:
    async with AsyncClient(api_key="YOUR_ANYSEARCH_API_KEY") as client:
        response = await client.search("Python 3.15 new features")

    print(response.data.results[0].url)


asyncio.run(main())

AsyncClient.extract and AsyncClient.get_sub_domains use the same arguments and response models as their synchronous counterparts.

MCP Tools

from anysearch_py import Domain, MCPClient

with MCPClient(api_key="YOUR_ANYSEARCH_API_KEY") as client:
    markdown = client.get_sub_domains(domains=[Domain.FINANCE, Domain.HEALTH])

print(markdown)
from anysearch_py import MCPClient

with MCPClient(api_key="YOUR_ANYSEARCH_API_KEY") as client:
    markdown = client.search("Python 3.15 new features", max_results=5)

print(markdown)

MCP Metadata and Feedback

Use call_tool to retain structured content and metadata alongside text. structured_content exposes structuredContent, and meta exposes _meta. Search metadata contains request_id; batch search metadata contains request_ids, one per query.

from anysearch_py import MCPClient, ScoreFeedback, SearchArguments

with MCPClient(api_key="YOUR_ANYSEARCH_API_KEY") as client:
    result = client.call_tool(SearchArguments(query="Python 3.15 new features"))
    print(result.text)

    request_id = (result.meta or {}).get("request_id")
    if isinstance(request_id, str):
        client.score([ScoreFeedback(request_id=request_id, score=4)])

Choose the score after reviewing the results: 1 means unusable, 5 means fully answered. score accepts 1–10 feedback entries with integer scores from 1 to 5 and request IDs up to 64 characters. Feedback submission acknowledges queuing, not persistence. AsyncMCPClient provides the same methods as awaitable calls.

Errors

Non-success HTTP responses raise HTTPStatusError, exposing status, code, error_code, request_id, data, and headers. REST errors inside an HTTP 200 response raise APIError with the same business error fields. MCP errors raise JSONRPCError; invalid JSON and unexpected response schemas raise ResponseDecodeError and ResponseValidationError.

HTTP 402 messages can contain generated account credentials, so treat their messages as secrets and avoid logging them. The SDK retries connection failures only; it does not automatically replay requests after HTTP errors or read timeouts.

Catalog Changes

The current catalog uses ACADEMIC_PAPER, ACADEMIC_PERSON, LEGAL_ENFORCEMENT, and LEGAL_JUDICIAL. The former ACADEMIC_BIOMEDICAL, ACADEMIC_PREPRINT, ACADEMIC_SEARCH, LEGAL_CASE, and LEGAL_STATUTE enum members were removed. Use get_sub_domains to choose the capability matching your query.

Live Tests

Live tests read ANYSEARCH_API_KEY from the environment first, then .env.

If neither source provides a non-empty value, those tests skip automatically.

Package code never reads .env.

Metadata

Release files for anysearch-py 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anysearch-py 0.3.0
File Size Uploaded Provenance Actions
anysearch_py-0.3.0.tar.gz 13.2 kB With provenance Details for anysearch_py-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for anysearch-py 0.3.0
File Interpreter ABI Platform Actions
anysearch_py-0.3.0-py3-none-any.whl Python 3 none any Details for anysearch_py-0.3.0-py3-none-any.whl

Total release size: 27.5 kB

Release files / anysearch_py-0.3.0.tar.gz

Download URL anysearch_py-0.3.0.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ef96db6efeddbfe8c1e9a44b8eb6704a6833e2b86315afeb0154e0379d736f1b
BLAKE2b-256 checksum
How to use checksums
73589ba1d4d3abd884191671e8951db33fd468f4ff5dd983bdeca7d299dcca82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / anysearch_py-0.3.0-py3-none-any.whl

Download URL anysearch_py-0.3.0-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc764f8c622a558491fbb47eda0688ad32d8b596107692a1f8e9c439b96bba48
BLAKE2b-256 checksum
How to use checksums
a725a92f6e6de49aa47751cd489238dbe275f4f56e6172d553a55f96281838b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Security for anysearch-py 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for anysearch_py-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page