Skip to main content

Bulkgrid Python SDK

Search trusted sources, manage indexing, and run crawl and extraction workflows from Python 3.10+.

Install

pip install bulkgrid

For development before the first PyPI release, run pip install -e packages/sdk-python from the repository root.

Version 0.4.0 uses client.search() for live web search and client.index.search() for indexed retrieval.

Pass type: "images" to client.search() for image search. Check result["type"] to narrow the response to web, image, or news results. Image results include a source page url, imageUrl, nullable imageWidth, imageHeight, and thumbnailUrl. Every live search creates a Search run in result["run"]. With crawl: True, that same run crawls unique source pages. Use client.runs.get(result["run"]["id"])["search"] to reopen saved results, and client.runs.results(result["run"]["id"]) for page content.

Pass type: "news" for news articles. News results include title, url, snippet, position, and nullable source (publisher), date (publication date text), and imageUrl. Check result["type"] == "news" before accessing news-specific fields. With crawl: True, one run crawls the unique article pages. Source and collection methods live under client.index.sources and client.index.collections. The former methods and API routes have been removed without compatibility aliases.

import os
from bulkgrid import BulkgridClient

with BulkgridClient(api_key=os.environ["BULKGRID_API_KEY"]) as client:
    web = client.search({"query": "open source web crawlers", "crawl": True})
    print(web["results"], web["run"])

To search previously indexed content:

import os
from bulkgrid import BulkgridClient

with BulkgridClient(api_key=os.environ["BULKGRID_API_KEY"]) as client:
    data = client.index.search({"query": "How does authentication work?", "limit": 5})
    for result in data["results"]:
        print(result["title"], result["url"])

Methods use Python snake_case. Request and response dictionary keys retain the API's spelling (for example collectionId, maxPages, and source_id). Types are available from bulkgrid.types; responses are ordinary dictionaries, not model objects. TypedDict annotations provide editor/type-checker support; the server validates request fields and the SDK checks HTTP status and JSON response shape, not every response field.

Async

import asyncio
import os
from bulkgrid import AsyncBulkgridClient


async def main():
    async with AsyncBulkgridClient(api_key=os.environ["BULKGRID_API_KEY"]) as client:
        data = await client.index.search({"query": "release notes", "limit": 3})
        print(data["results"])


asyncio.run(main())

Use a context manager, or call close() / await aclose() to release connections. Async cancellation propagates normally.

Sources and collections

import os
from bulkgrid import BulkgridClient

with BulkgridClient(api_key=os.environ["BULKGRID_API_KEY"]) as client:
    analysis = client.index.sources.analyze({"url": "https://example.com"})
    # Persist this ID. Poll with a bounded wait; do not resubmit after a timeout.
    print(client.index.sources.get_analysis(analysis["id"]))

    created = client.index.sources.create(
        {
            "type": "domain",
            "identifier": "https://example.com",
            "visibility": "private",
            "source_mode": "discover",
            "crawl_config": {"includePaths": ["/docs"]},
        }
    )
    source_id = created["source"]["id"]
    print(client.index.sources.status(source_id))
    client.index.collections.add_source(os.environ["COLLECTION_ID"], source_id)

Analysis and creation may start processing. Use explicitly scoped API keys and review scope before running writes. Source creation requires a paid plan; Free can subscribe to existing public sources. An analysis is not a subscription and a created source is not necessarily indexed yet.

Crawl and results

import os
import time
from bulkgrid import BulkgridClient

with BulkgridClient(api_key=os.environ["BULKGRID_API_KEY"]) as client:
    run = client.crawl({"urls": ["https://example.com"], "options": {"formats": ["markdown"]}})
    deadline = time.monotonic() + 120
    while time.monotonic() < deadline:
        status = client.runs.get(run["id"])
        if status["status"] in {"completed", "failed", "cancelled"}:
            break
        time.sleep(3)
    else:
        raise TimeoutError(f"Keep run ID {run['id']} and check it later")
    if status["status"] != "completed":
        raise RuntimeError(f"Run ended with status {status['status']}")
    page = client.runs.results(run["id"], {"page": 1, "limit": 20})
    for result in page["results"]:
        if not result["error_message"]:
            print(client.runs.get_result_content(run["id"], result["id"], {"type": "markdown"}))

runs.results returns one page. Use page, limit, and total for pagination. Source document and change endpoints use nextOffset. Screenshots have separate methods: get_result_screenshot returns a temporary signed URL; download_result_screenshot returns bytes.

Supported operations

Both clients support the same methods:

  • search, crawl, deep_crawl, extract
  • sources: analyze, get_analysis, list, search, create, create_github, get, update, delete, status, recrawl, documents, changes
  • collections: list, create, get, update, delete, rules, update_rules, add_source, remove_source
  • runs: list, create, get, delete, cancel, retry, results, get_result_content, get_result_screenshot, download_result_screenshot

crawl, deep_crawl, and extract fill in the run type. Generic runs.create requires it. remove_source removes all include/exclude rules for that source, matching the TypeScript helper.

Errors and configuration

import os
from bulkgrid import BulkgridAPIError, BulkgridClient, BulkgridTimeoutError

with BulkgridClient(api_key=os.environ["BULKGRID_API_KEY"], timeout=30.0) as client:
    try:
        client.index.search({"query": "pricing"})
    except BulkgridAPIError as error:
        print(error.status_code, error.request_id, error.retry_after)
        # error.data contains the API's structured error or text response.
    except BulkgridTimeoutError:
        print("Request timed out")

The default network timeout is 60 seconds; it is not a run-completion deadline. BulkgridConnectionError represents other network failures; BulkgridResponseError represents invalid JSON responses. Requests do not retry automatically. A timed-out write may already have started work: preserve known IDs and inspect status before retrying. HTTP redirects are not followed, preventing API-key forwarding to redirected hosts.

base_url defaults to https://bulkgrid.com. HTTPS origins are required, except HTTP loopback origins for local development. A custom httpx.BaseTransport / httpx.AsyncBaseTransport can be supplied with transport for testing. Keep keys in server-side environment variables.

Development and releases

python -m pip install -e 'packages/sdk-python[dev]'
python packages/sdk-python/scripts/generate.py --check
python -m pytest packages/sdk-python/tests
python -m mypy --config-file packages/sdk-python/pyproject.toml packages/sdk-python/src/bulkgrid
python -m ruff check packages/sdk-python
python -m build packages/sdk-python

The generator reads the committed public OpenAPI specification. Regenerate after contract changes; CI rejects stale output. The package contains no private platform dependencies.

Publishing uses .github/workflows/publish-python-sdk.yml and tags python-sdk-vX.Y.Z. Before the first release, configure the PyPI project bulkgrid with a GitHub trusted publisher matching the repository, workflow filename, and pypi environment. Name availability/ownership must be confirmed on PyPI. Update src/bulkgrid/_version.py (the single version source) and add release notes before tagging. Nothing is published by installing or testing locally.

The SDK is currently proprietary, consistent with the repository's UNLICENSED packages.

Website maps

run = client.map({"url": "https://example.com", "config": {"limit": 100}})
status = client.runs.get(run["id"])
# Poll until status is completed, failed, or cancelled.
# Completed maps contain discovered URLs in status["result_data"]["links"].

AsyncBulkgridClient also exposes await client.map(...). Map runs use the same cancellation, retry, and deletion methods as crawl runs. They discover URLs without fetching page content or using cached crawl data.

Change monitors

Version 0.5.0 adds monitor creation, settings, history, event comparison, retries, webhook secret rotation, and Slack channel discovery. Use client.monitors in the SDKs or bulkgrid monitors --help in the CLI. These operations require API keys with monitors:read and/or monitors:write; OAuth remains search-only. See the monitor guide for examples and notification behavior.

Metadata

Release files for bulkgrid 0.5.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 bulkgrid 0.5.0
File Size Uploaded Provenance Actions
bulkgrid-0.5.0.tar.gz 22.7 kB With provenance Details for bulkgrid-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bulkgrid 0.5.0
File Interpreter ABI Platform Actions
bulkgrid-0.5.0-py3-none-any.whl Python 3 none any Details for bulkgrid-0.5.0-py3-none-any.whl

Total release size: 39.2 kB

Release files / bulkgrid-0.5.0.tar.gz

Download URL bulkgrid-0.5.0.tar.gz
Size 22.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7c841fa53b49be3c211373fffc096ff0cd62cb936c4aeecb2ab76d9e7fb33aef
BLAKE2b-256 checksum
How to use checksums
a5b12870c9969f0e16198fe272d61861b2ff8417a6888d9ad2b07e4b4c6e3de6
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 Nov 3, 2026.

Transparency log

Release files / bulkgrid-0.5.0-py3-none-any.whl

Download URL bulkgrid-0.5.0-py3-none-any.whl
Size 16.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
47da2a053a84f0bb55c1e76daf9717537f9e275bb77747440752b3171dcee935
BLAKE2b-256 checksum
How to use checksums
42214d847cd81699233d5cf650ab768fdd086dbd12da99f568b13d496428f89a
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 Nov 3, 2026.

Transparency log

Security for bulkgrid 0.5.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 bulkgrid-0.5.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 Nov 3, 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