Overview
Every ScrapeGraph v2 endpoint is one method on the officialscrapegraph-py SDK. Wrap each one with LangChain’s built-in @tool decorator and you get a fully typed toolkit — no extra dependency, no third-party integration package, full control over arguments and return shapes.
LangChain tool docs
How LangChain’s
@tool decorator worksscrapegraph-py on PyPI
The official Python SDK for ScrapeGraph v2
Installation
Get your ScrapeGraph API key from the dashboard.
Build the toolkit
Save this once assgai_tools.py — every example below imports from it.
sgai_tools.py
Endpoint → tool reference
| ScrapeGraph endpoint | SDK call | LangChain tool |
|---|---|---|
POST /scrape | sgai.scrape(url=...) | scrape |
POST /extract | sgai.extract(prompt=..., url=...) | extract |
POST /search | sgai.search(query=...) | search |
POST /crawl | sgai.crawl.start(url=...) | crawl_start |
GET /crawl/{id} | sgai.crawl.get(id) | crawl_get |
POST /crawl/{id}/stop | sgai.crawl.stop(id) | crawl_stop |
POST /crawl/{id}/resume | sgai.crawl.resume(id) | crawl_resume |
DELETE /crawl/{id} | sgai.crawl.delete(id) | crawl_delete |
POST /monitor | sgai.monitor.create(url=..., interval=...) | monitor_create |
GET /monitor | sgai.monitor.list() | monitor_list |
GET /monitor/{id} | sgai.monitor.get(id) | monitor_get |
POST /monitor/{id}/pause | sgai.monitor.pause(id) | monitor_pause |
POST /monitor/{id}/resume | sgai.monitor.resume(id) | monitor_resume |
DELETE /monitor/{id} | sgai.monitor.delete(id) | monitor_delete |
GET /monitor/{id}/activity | sgai.monitor.activity(id) | monitor_activity |
GET /history | sgai.history.list(...) | history_list |
GET /history/{id} | sgai.history.get(id) | history_get |
GET /credits | sgai.credits() | credits |
Direct invocation
Call any tool by itself without an LLM — useful for scripts, tests, or as a building block inside chains.Tool-calling agent
Give the LLM the whole toolkit and let it pick. LangChain v1’screate_agent works with any chat model that supports tool calling (ChatOpenAI, ChatAnthropic, etc.).
create_agent returns a compiled LangGraph under the hood — see the LangGraph page for advanced patterns (custom StateGraph, ToolNode, checkpointing).Structured output with Pydantic
extract already returns structured JSON under the json_data key. Validate it into a Pydantic model for type safety downstream.
Chain pattern
Compose tools with LCEL when the sequence is fixed.Support
Python SDK
Source and issues for scrapegraph-py
Discord
Get help from our community