Skip to main content

LangChain Thordata for Python

Connect Thordata SERP to Python applications and LangChain agents for real-time search.

This package exposes Thordata search capabilities through a Python client and a LangChain search tool. Version 1 targets Thordata's synchronous SERP endpoint, exposes search-result APIs only, and does not expose Web Scraper APIs or the google_webpage engine.

Installation

pip install langchain-thordata

For local development:

python -m pip install -e ".[test]"

Configuration

Set a ThorData SERP API key:

export THORDATA_API_KEY="your-api-key"

THORDATA_API_TOKEN is accepted as a compatibility alias. The default API URL is https://scraperapi.thordata.com/request; override it for development with THORDATA_SERP_API_URL.

Python client

from langchain_thordata import ThorDataClient

with ThorDataClient() as client:
    results = client.search(
        q="latest AI agent research",
        engine="google_search",
        gl="us",
        hl="en",
        num=10,
    )
    print(results)

The client reuses its HTTP connection pool until close() or aclose() is called. Prefer a synchronous or asynchronous context manager. It also provides await client.asearch(...) for asynchronous callers. The current /request endpoint does not guarantee HTML, so the client intentionally exposes JSON search methods only.

The client accepts every form parameter supported by /request. Pass API-native parameters either as keyword arguments or in the first mapping argument:

flights = client.search(
    {
        "departure_id": "SFO",
        "arrival_id": "JFK",
        "outbound_date": "2026-10-01",
        "return_date": "2026-10-08",
    },
    engine="google_flights",
)

In either form, the convenience names query, country, and language map to q, gl, and hl. Explicit API-native names such as q, gl, hl, and text are preserved. For Yandex, query or q is sent as text.

LangChain tool

from langchain_thordata import ThorDataSearchTool

tool = ThorDataSearchTool()
result = tool.invoke(
    {
        "query": "latest AI agent research",
        "engine": "google_news",
        "country": "us",
        "language": "en",
        "num": 5,
    }
)
print(result)

Specialized parameters are available to the tool through params:

result = tool.invoke(
    {
        "engine": "google_scholar_author",
        "params": {"author_id": "EicYvbwAAAAJ", "sort": "pubdate"},
    }
)

The tool can be passed directly to a LangChain agent:

from langchain.agents import create_agent
from langchain_thordata import ThorDataSearchTool

agent = create_agent(model, tools=[ThorDataSearchTool()])

The agent example requires the separate langchain package; the integration's runtime dependency stays limited to langchain-core.

Supported engines

  • Google search: google, google_light, google_web, google_images, google_videos, google_news, google_shopping, google_local, google_product, google_lens, google_trends, google_maps, google_hotels, google_jobs, and google_ai_mode.
  • Google verticals: google_scholar, google_scholar_cite, google_scholar_author, google_play, google_play_product, google_play_games, google_play_movies, google_play_books, google_finance, google_finance_markets, google_flights, google_patents, and google_patents_details.
  • Bing: bing, bing_images, bing_videos, bing_news, bing_shopping, and bing_maps.
  • Other providers: yandex and duckduckgo. For Yandex, the LangChain query field is sent as the API's required text parameter.

For compatibility, google_search maps to google, and google_places maps to google_local before the request is sent.

Unsupported parameters are omitted from the request. Unsupported engines are rejected because silently switching a search source would change user intent.

Every request sends fixed integration metadata:

  • Platform: langchain
  • Source: python-sdk

These values are sent as both request headers and form metadata. The current ThorData service records the form metadata without forwarding it to the search provider.

The API key is never included in tool output or exception messages. Business code 300 raises ThorDataNotCollectedError; all API exceptions retain their numeric code for programmatic handling.

JSON-string response envelopes are normalized by the client before the LangChain tool serializes its result, so callers parse the tool output once.

Development

ruff check .
pytest
python -m build

Live integration tests should use a dedicated test account and API key. Unit tests use an in-memory HTTP transport and do not call Thordata services.

Learn more

Metadata

Release files for langchain-thordata 0.2.1

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

Source distribution (sdist)

Source distribution for langchain-thordata 0.2.1
File Size Uploaded Provenance Actions
langchain_thordata-0.2.1.tar.gz 13.4 kB With provenance Details for langchain_thordata-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-thordata 0.2.1
File Interpreter ABI Platform Actions
langchain_thordata-0.2.1-py3-none-any.whl Python 3 none any Details for langchain_thordata-0.2.1-py3-none-any.whl

Total release size: 25.3 kB

Release files / langchain_thordata-0.2.1.tar.gz

Download URL langchain_thordata-0.2.1.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
04772d791c0b30a2163dfa24c4ccb72f737807894836ca30d2f27ae632e17a25
BLAKE2b-256 checksum
How to use checksums
4545421dded49dae5f47f90587db9501b707af1c6e79462cd7feebc935eb2bf6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 16, 2026.

Transparency log

Release files / langchain_thordata-0.2.1-py3-none-any.whl

Download URL langchain_thordata-0.2.1-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1f7c5c4dd41ef77a0cb07ba30cd3021e5606c25e9906bbd785c6b39e1f1133c5
BLAKE2b-256 checksum
How to use checksums
027575a9bf3ca4d0beb9972c26044030a78bc53adb6afaf927b981fd994f5206
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 16, 2026.

Transparency log

Security for langchain-thordata 0.2.1

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 langchain_thordata-0.2.1.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 16, 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