Metadata-Version: 2.4
Name: langchain-haunt
Version: 0.1.1
Summary: LangChain integration for Haunt, the web extraction API that returns honest errors instead of invented content
Project-URL: Homepage, https://hauntapi.com?utm_source=langchain&utm_medium=integration&utm_campaign=sweep-2026-07
Project-URL: Documentation, https://hauntapi.com/docs?utm_source=langchain&utm_medium=integration&utm_campaign=sweep-2026-07
Project-URL: Repository, https://github.com/Darko893/langchain-haunt
Author-email: Haunt API <support@hauntapi.com>
License: MIT
License-File: LICENSE
Keywords: agents,haunt,langchain,scraping,tools,web extraction
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Requires-Dist: hauntapi>=1.1.0
Requires-Dist: langchain-core>=0.3.0
Requires-Dist: pydantic>=2.0.0
Provides-Extra: test
Requires-Dist: langchain-tests>=0.3.0; extra == 'test'
Requires-Dist: pytest>=7.0; extra == 'test'
Description-Content-Type: text/markdown

# langchain-haunt

LangChain integration for [Haunt](https://hauntapi.com?utm_source=langchain&utm_medium=integration&utm_campaign=sweep-2026-07), the web extraction API built for AI agents.

Haunt reads public web pages and returns structured JSON or clean markdown. The difference from other extraction tools: when a page cannot be read, Haunt tells your agent so, with a plain error code, instead of returning invented content. Failed reads are not charged.

## Install

```bash
pip install langchain-haunt
export HAUNT_API_KEY="your-key"
```

Get a free key (1,000 credits, no card) at [hauntapi.com](https://hauntapi.com/#signup?utm_source=langchain&utm_medium=integration&utm_campaign=sweep-2026-07).

Want to try the engine before creating a key? Prepend `https://hauntapi.com/r/` to any URL for the free no-signup reader:

```bash
curl https://hauntapi.com/r/example.com
```

## Extract structured data with an agent tool

```python
from langchain_haunt import HauntExtract

tool = HauntExtract()

tool.invoke({
    "url": "https://news.ycombinator.com",
    "prompt": "the top 5 story titles and their points",
})
# '{"stories": [{"title": "...", "points": 572}, ...]}'
```

Bind it to any tool-calling model:

```python
from langchain.agents import create_agent

agent = create_agent("claude-sonnet-5", tools=[HauntExtract()])
agent.invoke({"messages": [("user", "What is the current top Hacker News story?")]})
```

## Honest failure, the part your agent will thank you for

A blocked, missing, or login-walled page returns a structured error instead of hallucinated content:

```python
tool.invoke({"url": "https://example.com/admin", "prompt": "the dashboard numbers"})
# '{"error_code": "login_required", "message": "This page needs a login. ..."}'
```

Your agent can branch on `error_code` (`access_denied`, `login_required`, `not_found`, `blocked`) rather than acting on made-up data.

## Load pages as Documents

```python
from langchain_haunt import HauntLoader

loader = HauntLoader([
    "https://example.com/docs/page-one",
    "https://example.com/docs/page-two",
])
docs = loader.load()  # clean markdown, ready for splitting and embedding
```

An unreadable page raises with the honest reason. Pass `on_failure="skip"` to omit unreadable pages instead.

## Links

- [API docs](https://hauntapi.com/docs?utm_source=langchain&utm_medium=integration&utm_campaign=sweep-2026-07)
- [Pricing](https://hauntapi.com/pricing?utm_source=langchain&utm_medium=integration&utm_campaign=sweep-2026-07): you only pay for calls that return working data
- [Hosted MCP server](https://hauntapi.com/mcp/server) for MCP-native stacks
