Metadata-Version: 2.4
Name: langchain-chordian-search-api
Version: 0.1.0
Summary: LangChain tools for Chordian People & Companies Search API
License-Expression: MIT
Project-URL: Repository, https://github.com/SitaChopra/langchain-chordian-search-api
Project-URL: Documentation, https://docs.chordian.ai/search-api
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx<1.0,>=0.27
Requires-Dist: langchain-core<2.0,>=1.0
Requires-Dist: pydantic<3.0,>=2.7
Provides-Extra: test
Requires-Dist: pytest>=8.0; extra == "test"
Requires-Dist: uvicorn>=0.30; extra == "test"
Dynamic: license-file

# Chordian Search API for LangChain

`langchain-chordian-search-api` provides LangChain tools for Chordian's People & Companies Search API. It is separate from Chordian Knowledge Memory, which searches an organization's private knowledge rather than the external web.

## What it provides

- `chordian_search_start` starts a company or people list-building workflow.
- `chordian_search_status` reads workflow status and results by `thread_id`.
- `chordian_search_continue` raises the target for an existing search.
- `chordian_search_stop` cancels an in-flight search.

Start and continue responses are asynchronous; the tools return the API response and do not poll or retry automatically. Search API calls may be metered. The API docs say list building is charged per matched record, but do not state exact prices. Review your account's billing terms before enabling calls.

## Requirements

- Python 3.11 or newer.
- A Chordian platform API key (`ck_live_...`) with Search API access.
- HTTPS for remote API endpoints. Plain HTTP is permitted only for loopback tests.

The key is sent only in the `x-api-key` header. It is not placed in URLs, tool arguments, or return values. Redirects are not followed, which prevents forwarding the key to another host. Network errors are not retried automatically, to avoid duplicate metered POST requests.

## Install and configure

```sh
python -m pip install langchain-chordian-search-api
export CHORDIAN_SEARCH_API_ENDPOINT="https://api.chordian.ai"
read -r -s -p 'Chordian Search API key: ' CHORDIAN_SEARCH_API_KEY
export CHORDIAN_SEARCH_API_KEY
```

PowerShell:

```powershell
$env:CHORDIAN_SEARCH_API_ENDPOINT = "https://api.chordian.ai"
$secret = Read-Host 'Chordian Search API key' -AsSecureString
$env:CHORDIAN_SEARCH_API_KEY = [System.Net.NetworkCredential]::new('', $secret).Password
Remove-Variable secret
```

Do not commit real keys or paste them into prompts. Use a least-privilege key and an approved expiration.

## Use the tools

Creating the tools does not make a network request, but it requires an explicit application-level billing opt-in:

```python
from langchain_chordian_search_api import create_search_tools

tools = create_search_tools(allow_metered_calls=True)
```

Call the start tool only after the user approves the potential charge. `total_target` is required and is capped at 500 by this integration as a guard against unexpectedly large requests:

```python
start = next(tool for tool in tools if tool.name == "chordian_search_start")
response = await start.ainvoke(
    {
        "search_type": "company",
        "prompt": "Find Series B SaaS companies in the US",
        "search_mode": "fast",
        "total_target": 25,
    }
)
```

Pass the returned `thread_id` to `chordian_search_status` when you need progress or results. Call `chordian_search_continue` only after approval for any additional charges. No background polling is started by the package.

## API behavior

The integration follows Chordian's documented Search API routes:

- Company start: `POST /api/v1/search/workflow/start`.
- People start: `POST /api/v1/search/workflow/people/start`.
- Company status: `GET /api/v1/search/workflow/status/{thread_id}`; continue: `POST /api/v1/search/workflow/continue`; stop: `POST /api/v1/search/workflow/stop/{thread_id}`.
- People status: `GET /api/v1/search/workflow/people/status/{thread_id}`; continue: `POST /api/v1/search/workflow/people/continue`; stop: `POST /api/v1/search/workflow/people/stop/{thread_id}`.

See the [Search API overview](https://docs.chordian.ai/search-api), [getting started](https://docs.chordian.ai/search-api/getting-started), and [API reference](https://docs.chordian.ai/search-api/reference/people-and-company-engine-enrichment/startCompanySearch).

## Test and build

```sh
python -m pip install -e ".[test]" build
python -m pytest -q
python -m build
```

Tests use a local fake HTTP server. They do not call Chordian, require a real key, or create billable searches.

## License

MIT. See `LICENSE`.
