Metadata-Version: 2.5
Name: pdg-langchain
Version: 0.1.0
Summary: LangChain tools for the Provenance Data Grid API — compliance, entity, financial, and market data for AI agents
Project-URL: Homepage, https://pdg.neprovenance.com
Project-URL: Documentation, https://pdg.neprovenance.com/docs
Author-email: New England Provenance LLC <support@neprovenance.com>
License-Expression: MIT
Keywords: ai-agents,compliance,langchain,nppes,ofac,sec,x402
Requires-Python: >=3.10
Requires-Dist: httpx>=0.25.0
Requires-Dist: langchain-core>=0.2.0
Description-Content-Type: text/markdown

# pdg-langchain

LangChain tools for the [Provenance Data Grid](https://pdg.neprovenance.com) API. Query compliance data, business entities, healthcare providers, SEC financials, crypto prices, weather, and web content from your LangChain agents.

## Install

```bash
pip install pdg-langchain
```

## Authentication

Set your API key as an environment variable:

```bash
export PDG_API_KEY="your-key-here"
```

A free tier of 5 calls/day is available without an API key. Purchase credits at <https://pdg.neprovenance.com/billing/plans>.

## Quick start -- single tool

```python
from pdg_langchain import PDGSanctionsScreen

tool = PDGSanctionsScreen()
result = tool.invoke({"name": "John Smith"})
print(result)
```

## Use all tools with an agent

```python
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent

from pdg_langchain import get_pdg_tools

llm = ChatOpenAI(model="gpt-4o")
tools = get_pdg_tools()

agent = create_react_agent(llm, tools)

response = agent.invoke(
    {"messages": [{"role": "user", "content": "Screen 'Acme Corp' against the OFAC sanctions list"}]}
)
print(response["messages"][-1].content)
```

## Pass API key directly

```python
from pdg_langchain import get_pdg_tools

tools = get_pdg_tools(api_key="your-key-here")
```

## Available tools

| Tool | Endpoint | Description |
|------|----------|-------------|
| `PDGSanctionsScreen` | `/sanctions/screen` | OFAC SDN screening -- fuzzy match against 19,596 sanctioned entities |
| `PDGEntitySearch` | `/entity/search` | Business entity search across SEC, NPPES, and 5 state SOS databases |
| `PDGProviderSearch` | `/provider/search` | Healthcare provider search -- 9.89M US providers by name, NPI, or specialty |
| `PDGCompanyFinancials` | `/company/{cik}/financials` | SEC financial data: revenue, net income, assets, EPS from XBRL filings |
| `PDGCryptoPrice` | `/price/crypto/{symbol}` | Crypto price, 24h change, volume, and market cap (100+ coins) |
| `PDGWebExtract` | `/web/extract` | Extract a web page as clean, LLM-ready markdown |
| `PDGWebSearch` | `/web/search` | Web search via Brave Search with structured results |
| `PDGWeather` | `/weather/{lat},{lon}` | Current conditions and 48-hour forecast for any coordinates |

## Tool parameters

**PDGSanctionsScreen**
- `name` (str, required) -- Name to screen

**PDGEntitySearch**
- `name` (str, required) -- Business name
- `state` (str, optional) -- Two-letter US state code

**PDGProviderSearch**
- `name` (str, optional) -- Provider or organization name
- `npi` (str, optional) -- NPI number for exact lookup
- `state` (str, optional) -- Two-letter US state code
- `city` (str, optional) -- City name
- `taxonomy` (str, optional) -- Taxonomy/specialty code
- `limit` (int, default 10) -- Max results (1-50)

**PDGCompanyFinancials**
- `cik` (str, required) -- SEC CIK number (e.g. "320193" for Apple)

**PDGCryptoPrice**
- `symbol` (str, required) -- Coin symbol (e.g. "btc", "eth")

**PDGWebExtract**
- `url` (str, required) -- URL to extract

**PDGWebSearch**
- `query` (str, required) -- Search query

**PDGWeather**
- `lat` (float, required) -- Latitude
- `lon` (float, required) -- Longitude

## License

MIT
