TypeScript
Use the TypeScript SDK from your Node.js application or worker.Install
apiKey.
Search indexed content
Requiressearch:query and accessible indexed content:
Find a source and add it to a collection
Requiressources:read, sources:write, collections:read, collections:write, and search:query. Plan limits and collection restrictions still apply; a 403 is not a reason to retry with broader credentials automatically.
created: false means the source already existed. Adding a subscription does not guarantee indexing is complete. sources.list({ search }) searches your subscribed and owned sources; sources.search(query) searches the public catalog and owned sources, with subscription flags.
Collection creation requires a qualifying plan. To use an existing collection, call collections.list() and select an appropriate accessible collection instead. addSource includes the whole source and keeps existing exclusions. Use updateRules for specific folders or URLs:
removeSource({ collectionId, sourceId }) removes the source’s rules returned by an initial read. It requires both collections:read and collections:write; rules added concurrently after that read are left alone. Removing a source from a collection does not remove its workspace subscription.
GitHub sources and indexing
sources.recrawl(id) requests a refresh and needs sources:write plus runs:write. sources.changes(id, { runId, kind: 'changed' }) lists changes for a specific run; paginate with offset and the returned nextOffset.
Create and monitor a crawl
Requiresruns:write, runs:read, and results:read:
completed, failed, or cancelled, with a maximum wait time. Once complete:
Available methods
crawl, deepCrawl, and extract add the required run type automatically. Raw HTTP calls and runs.create must include it explicitly.
sources.delete removes your subscription to a shared source or deletes an owned source according to server permissions. See Source management.
Handle failures
RequestOptions.signal to cancel requests. The SDK does not automatically retry requests or poll runs. See Retries before retrying a create request that may already have succeeded.
Analyze a source before ingestion
Source analysis is asynchronous and may start a resource-consuming crawl. It requiressources:discover and runs:write; start it only within the approved source scope. These methods are available in the repository build; verify your installed package includes them.
sources:discover. Counts describe estimated coverage, not guaranteed storage or credits. Treat partial results and warnings as incomplete evidence. The SDK does not poll indefinitely or create a source subscription automatically.
After approved creation, use sources.status(sourceId) to distinguish source registration from indexing readiness. Use collections.rules(collectionId) before adding whole-source access with collections.addSource({ sourceId, collectionId }). A failed collection update does not undo source creation; preserve the returned source ID rather than repeating creation.
Python
The Python SDK supports Python 3.10+ and offers the same source, collection, crawl, extraction, search, and run operations as the TypeScript SDK.The Python package is prepared for its first PyPI release. Until it is published, install it from a local repository checkout with
python -m pip install ./packages/sdk-python. After publication, use python -m pip install bulkgrid.Search
base_url is https://bulkgrid.com; you can override it for your deployment. Request and response dictionaries retain the API’s field spelling, such as collectionId and source_id. Method names use Python conventions: deep_crawl, sources.get_analysis, sources.create_github, and runs.get_result_content.
Async applications
close() / await aclose() explicitly.
Types and errors
Request and response types are available frombulkgrid.types. Responses remain regular Python dictionaries; type hints support editor completion and static checking. The server validates requests; the SDK checks HTTP status and JSON object responses.
Catch BulkgridAPIError for non-success HTTP responses. It exposes status_code, data, request_id, and retry_after. BulkgridTimeoutError and BulkgridConnectionError identify network failures; BulkgridResponseError identifies invalid JSON responses.
The default network timeout is 60 seconds; configure it with timeout=30.0, for example. It does not wait for a crawl or extraction run to finish. Requests do not retry automatically: a timed-out write may already have started processing. Persist run and analysis IDs, use bounded polling, and inspect status before retrying.
Sources, collections, and runs
The Sources, Collections, and Runs and results guides include Python tabs. For example, analyze a source withclient.sources.analyze({"url": "https://example.com"}) and check it with client.sources.get_analysis(analysis_id).
Use client.collections.add_source(collection_id, source_id) to include a source in a collection. remove_source(collection_id, source_id) removes all rules for that source, matching the TypeScript helper.
client.runs.results(run_id, {"page": 1, "limit": 20}) returns one page of results. Text content comes from get_result_content; screenshot URLs come from get_result_screenshot, and download_result_screenshot returns image bytes. Check per-result failures and pagination metadata before consuming outputs.