Metadata-Version: 2.5
Name: gainflow
Version: 0.1.0
Summary: Official Python SDK (sync & async) for the Gainflow web data API
Project-URL: Homepage, https://gainflow.ai
Project-URL: Documentation, https://docs.gainflow.ai
License: MIT
License-File: LICENSE
Keywords: ai-agents,crawl,gainflow,markdown,mcp,monitoring,web-scraping
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: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: httpx<1.0.0,>=0.27.0
Description-Content-Type: text/markdown

# gainflow

Official Python SDK (sync & async) for [Gainflow](https://gainflow.ai) - hard-to-get web data for builders and AI agents.

- **Docs:** https://docs.gainflow.ai
- **Hosted MCP Server:** `https://mcp.gainflow.ai/mcp`
- **Agent Skill:** `npx skills add https://gainflow.ai`

## Install

```bash
pip install gainflow
# or
uv add gainflow
```

## Quickstart (Sync)

Set `GAINFLOW_API_KEY` in your environment (or pass `api_key=...` explicitly):

```bash
export GAINFLOW_API_KEY="gf_live_..."
```

```python
from gainflow import GainflowClient

with GainflowClient() as gf:
    page = gf.scrape(
        "https://news.ycombinator.com",
        formats=["markdown"],
        parse={"titles": ".titleline > a"},
        extract={
            "prompt": "Extract the top 3 story titles",
            "schema": {
                "type": "object",
                "properties": {"top_stories": {"type": "array", "items": {"type": "string"}}},
                "required": ["top_stories"],
            },
        },
    )
    print(page["data"]["extracted"])
```

## Async Client

```python
import asyncio
from gainflow import AsyncGainflowClient

async def main() -> None:
    async with AsyncGainflowClient() as gf:
        page = await gf.scrape("https://example.com", render_js=True)
        print(page["data"]["markdown"])

asyncio.run(main())
```

## Features

- **Scraping & PDF OCR:** `gf.scrape(url, formats=..., parse=..., extract=..., render_js=..., actions=..., ocr=..., country=..., max_age_sec=..., zdr=...)`
- **Site Mapping & Crawling:** `gf.map(url, search=..., limit=...)`, `gf.crawls.create(url=..., max_pages=..., max_depth=...)`
- **Async Batches:** `gf.batches.create(urls=...)`, `gf.batches.get(batch_id)`, `gf.batches.cancel(batch_id)`
- **Monitors & Webhooks:** `gf.monitors.create(...)`, `gf.webhooks.create(url=..., events=...)`
- **Local Businesses:** `gf.businesses.search(...)`, `gf.businesses.enrich(business_id)`
- **Account & Billing:** `gf.account.balance()`, `gf.account.usage()`, `gf.account.create_api_key(name=...)`, `gf.billing.checkout(...)`
- **Low-level Escape Hatch:** `gf.request("POST", "/v1/...", json=...)` with automatic auth and retries on `408`/`429`/`502`/`503`/`504`.

## License

MIT
