Skip to main content

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

pip install 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="https://example.com/article",
    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="https://example.com",
        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", "arxiv.org"],
        blocked_domains=["spam.com"]
    )
    print(result)

Asynchronous Client

import asyncio
from quercle import AsyncQuercleClient

async def main():
    async with AsyncQuercleClient() as client:
        # Fetch
        result = await client.fetch(
            url="https://example.com",
            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)
    base_url: str | None = None,     # Custom API base URL
    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 analyze
  • prompt: 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 query
  • allowed_domains: Only include results from these domains (e.g., ["*.edu", "example.com"])
  • 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}")

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

quercle-0.1.0.tar.gz (43.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quercle-0.1.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file quercle-0.1.0.tar.gz.

File metadata

  • Download URL: quercle-0.1.0.tar.gz
  • Upload date:
  • Size: 43.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for quercle-0.1.0.tar.gz
Algorithm Hash digest
SHA256 356707c68c6ec68ee1ebfe3757ed8a98b83323d9a2864f141c624e89b9c30a99
MD5 10b91171e4cbe5e6039e1187d9662e36
BLAKE2b-256 1f69038d4dc429e75542bf3e07432c7659ac914e014bc6c662a2726334e06966

See more details on using hashes here.

Provenance

The following attestation bundles were made for quercle-0.1.0.tar.gz:

Publisher: publish.yml on quercledev/quercle-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quercle-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: quercle-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for quercle-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b7087e61bc0b6b7234d5e330ebe5886fdb4233776246b77264b0e5a8191809e
MD5 fd75d6f113b4063b1c31583c2a7b1d2f
BLAKE2b-256 39a56fbea490cff82ec5a0622c8f59b204fb476cbe7e15ea91fdadd3d871c611

See more details on using hashes here.

Provenance

The following attestation bundles were made for quercle-0.1.0-py3-none-any.whl:

Publisher: publish.yml on quercledev/quercle-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page