gainflow
Official Python SDK (sync & async) for Gainflow - 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
pip install gainflow
# or
uv add gainflow
Quickstart (Sync)
Set GAINFLOW_API_KEY in your environment (or pass api_key=... explicitly):
export GAINFLOW_API_KEY="gf_live_..."
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
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