Official Python SDK for the Quercle API - AI-powered web search and fetching
Project description
Quercle Python SDK
Official Python SDK for the Quercle API - AI-powered web search and fetching.
Installation
uv add quercle
Quick Start
from quercle import QuercleClient
# Initialize with API key (or set QUERCLE_API_KEY env var)
client = QuercleClient(api_key="qk_...")
# Fetch and analyze a URL
result = client.fetch(
url="<any-url>",
prompt="Summarize the main points in bullet points"
)
print(result)
# Search the web
result = client.search("What is TypeScript?")
print(result)
Authentication
Get your API key at quercle.dev.
# Option 1: Pass API key directly
client = QuercleClient(api_key="qk_...")
# Option 2: Set environment variable
# export QUERCLE_API_KEY=qk_...
client = QuercleClient()
Usage
Synchronous Client
from quercle import QuercleClient
# Using context manager (recommended)
with QuercleClient() as client:
# Fetch a URL and analyze content
result = client.fetch(
url="<any-url>",
prompt="Extract the main heading and first paragraph"
)
print(result)
# Search the web
result = client.search("Python best practices 2024")
print(result)
# Search with domain filtering
result = client.search(
"machine learning tutorials",
allowed_domains=["*.edu", "*.org"],
blocked_domains=["*.xyz"]
)
print(result)
Asynchronous Client
import asyncio
from quercle import AsyncQuercleClient
async def main():
async with AsyncQuercleClient() as client:
# Fetch
result = await client.fetch(
url="<any-url>",
prompt="Summarize this page"
)
print(result)
# Search
result = await client.search("Latest AI news")
print(result)
# Parallel requests
results = await asyncio.gather(
client.search("Python tutorials"),
client.search("TypeScript tutorials"),
)
for r in results:
print(r)
asyncio.run(main())
API Reference
QuercleClient / AsyncQuercleClient
Constructor
QuercleClient(
api_key: str | None = None, # API key (or use QUERCLE_API_KEY env var)
timeout: float | None = None, # Request timeout in seconds (default: 120)
)
Methods
fetch(url: str, prompt: str) -> str
Fetch a URL and analyze its content with AI.
url: The URL to fetch and analyzeprompt: Instructions for how to analyze the page content- Returns: AI-processed analysis of the page content
search(query: str, *, allowed_domains: list[str] | None = None, blocked_domains: list[str] | None = None) -> str
Search the web and get AI-synthesized answers with citations.
query: The search queryallowed_domains: Only include results from these domains (e.g.,["*.edu", "*.gov"])blocked_domains: Exclude results from these domains- Returns: AI-synthesized answer with source citations
Error Handling
from quercle import QuercleClient, QuercleError
from quercle.exceptions import (
AuthenticationError,
InsufficientCreditsError,
RateLimitError,
TimeoutError,
)
try:
client = QuercleClient()
result = client.search("test query")
except AuthenticationError:
print("Invalid API key")
except InsufficientCreditsError:
print("Not enough credits")
except RateLimitError:
print("Too many requests")
except TimeoutError:
print("Request timed out")
except QuercleError as e:
print(f"API error: {e.status_code} - {e.detail}")
Tool Descriptions
Pre-defined descriptions for building AI agent tools:
from quercle import (
# Tool descriptions
FETCH_TOOL_DESCRIPTION,
SEARCH_TOOL_DESCRIPTION,
# Fetch field descriptions
FETCH_URL_DESCRIPTION,
FETCH_PROMPT_DESCRIPTION,
# Search field descriptions
SEARCH_QUERY_DESCRIPTION,
SEARCH_ALLOWED_DOMAINS_DESCRIPTION,
SEARCH_BLOCKED_DOMAINS_DESCRIPTION,
)
| Constant | Description |
|---|---|
FETCH_TOOL_DESCRIPTION |
Fetch a web page and analyze its content using AI... |
SEARCH_TOOL_DESCRIPTION |
Search the web and get an AI-synthesized answer with citations... |
FETCH_URL_DESCRIPTION |
The URL to fetch and analyze |
FETCH_PROMPT_DESCRIPTION |
Instructions for how to analyze the page content... |
SEARCH_QUERY_DESCRIPTION |
The search query to find information about. Be specific |
SEARCH_ALLOWED_DOMAINS_DESCRIPTION |
Only include results from these domains... |
SEARCH_BLOCKED_DOMAINS_DESCRIPTION |
Exclude results from these domains... |
Requirements
- Python 3.10+
- httpx
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quercle-0.1.2.tar.gz.
File metadata
- Download URL: quercle-0.1.2.tar.gz
- Upload date:
- Size: 44.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c10c9fa277d71c6f7cd9eee433628d3bbe5fe9f326da0291562a5556da3be952
|
|
| MD5 |
2e7f0d9b4e09c2b66975915b23557025
|
|
| BLAKE2b-256 |
09d3ac4c81697079cccc49ad7a10f6be23209c48b17264e33c5ca80ca6950398
|
Provenance
The following attestation bundles were made for quercle-0.1.2.tar.gz:
Publisher:
publish.yml on quercledev/quercle-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quercle-0.1.2.tar.gz -
Subject digest:
c10c9fa277d71c6f7cd9eee433628d3bbe5fe9f326da0291562a5556da3be952 - Sigstore transparency entry: 757274324
- Sigstore integration time:
-
Permalink:
quercledev/quercle-python@15cd6968d1948103ba7b210c536dc87098d3ffc3 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/quercledev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@15cd6968d1948103ba7b210c536dc87098d3ffc3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file quercle-0.1.2-py3-none-any.whl.
File metadata
- Download URL: quercle-0.1.2-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc555a0c1ea732e037245ae2994b23002b629e7fb719f365c942475ea9758afc
|
|
| MD5 |
643e3179a54a2d94dbc42a27d2e076f7
|
|
| BLAKE2b-256 |
9d597d348028295528b806b00eb0b59dbdea65dff8d29433e2ab94f06f5b7858
|
Provenance
The following attestation bundles were made for quercle-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on quercledev/quercle-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quercle-0.1.2-py3-none-any.whl -
Subject digest:
cc555a0c1ea732e037245ae2994b23002b629e7fb719f365c942475ea9758afc - Sigstore transparency entry: 757274381
- Sigstore integration time:
-
Permalink:
quercledev/quercle-python@15cd6968d1948103ba7b210c536dc87098d3ffc3 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/quercledev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@15cd6968d1948103ba7b210c536dc87098d3ffc3 -
Trigger Event:
push
-
Statement type: