Metadata-Version: 2.4
Name: buywhere-langchain
Version: 0.1.0
Summary: LangChain integration toolkit for the BuyWhere product catalog API
Author-email: BuyWhere <dev@buywhere.ai>
License: MIT
Project-URL: Homepage, https://github.com/buywhere/buywhere-langchain
Project-URL: Source, https://github.com/buywhere/buywhere-langchain
Keywords: buywhere,catalog,langchain,tools,agent
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: langchain-core>=0.3.0
Requires-Dist: httpx>=0.28

# BuyWhere LangChain Integration

LangChain tools for the BuyWhere product catalog API. Add product search, price comparison, and affiliate links to any LangChain agent.

## Installation

```bash
pip install buywhere-langchain
```

## Quick Start

```python
from langchain.agents import create_react_agent, AgentExecutor
from langchain_openai import ChatOpenAI
from buywhere_langchain import BuyWhereToolkit

toolkit = BuyWhereToolkit(api_key="bw_live_xxx")
tools = toolkit.get_tools()

llm = ChatOpenAI(model="gpt-4o")
agent = create_react_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools)

result = agent_executor.invoke({"input": "find me a laptop under $1000 in Singapore"})
print(result["output"])
```

## Available Tools

| Tool | Description |
|------|-------------|
| `buywhere_search` | Search products by name, brand, category, price range |
| `buywhere_get_product` | Get full details for a specific product |
| `buywhere_get_price` | Get pricing across all merchants |
| `buywhere_compare_prices` | Compare 2-5 products side by side |
| `buywhere_get_affiliate_link` | Get an affiliate-tracking URL for a product |
| `buywhere_get_catalog` | List all product categories |
| `buywhere_find_best_price` | Find the cheapest listing for a product across all platforms |
| `buywhere_get_deals` | Find discounted products sorted by discount depth |

## LangGraph

```python
from langgraph.prebuilt import ToolNode

tool_node = ToolNode(toolkit.get_tools())
```

## Error Handling

Tools return typed errors for auth failures, rate limits, and not-found:

- `BuyWhereError` — base exception
- `RateLimitError` — retry with backoff
- `AuthenticationError` — invalid API key
- `NotFoundError` — product/resource not found

## Get an API Key

Sign up at [buywhere.ai](https://buywhere.ai) to get your API key.
