ihen404-x402-langchain
LangChain integration tool for HTTP 402 Paywalled Web Scraping powered by Base USDC micro-payments.
Designed specifically for Autonomous AI Agents, trading bots, and market research agents that require programmatic, pay-per-request web access without credit cards or monthly API subscriptions.
Features
- Native LangChain Tool Integration: Drop-in
X402WebScraperToolfor LangChain, LangGraph, and CrewAI agents. - Automated HTTP 402 Settlement: Automatically handles $0.005 Base USDC micro-payment challenges via
X-Paymentheaders. - Zero Friction for AI Agents: Autonomous agents sign and settle transactions directly on Base L2 in milliseconds.
Installation
pip install ihen404-x402-langchain
Quickstart
import os
from langchain_x402 import X402WebScraperTool
from langchain.agents import initialize_agent, AgentType
from langchain_openai import ChatOpenAI
# Initialize the 402-capable web scraper tool
scraper_tool = X402WebScraperTool(
wallet_private_key=os.getenv("BASE_WALLET_PRIVATE_KEY"),
rpc_url="[https://mainnet.base.org](https://mainnet.base.org)",
max_price_per_scrape="0.005" # Max USDC spend per request
)
llm = ChatOpenAI(model="gpt-4o", temperature=0)
agent = initialize_agent(
tools=[scraper_tool],
llm=llm,
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
verbose=True
)
# Agent autonomously handles HTTP 402 payment challenge if paywalled
response = agent.run("Fetch data from [https://api.x402service.com/scrape?url=https://example.com](https://api.x402service.com/scrape?url=https://example.com)")
print(response)
Pricing Structure
| Action | Cost | Settlement Network |
|---|---|---|
| Standard Web Scrape | $0.005 USDC | Base (L2) |
| Failed Request | $0.000 USDC | N/A |
License
MIT License. Developed by @ihen404.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ihen404_x402_langchain-1.0.1.tar.gz.
File metadata
- Download URL: ihen404_x402_langchain-1.0.1.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b05a8678b949c678832e971f9cf2614ee772cff3cf472231a65ade1806dfedb0
|
|
| MD5 |
caa4a621ad3b1b6e5b86e9d2aa993b9f
|
|
| BLAKE2b-256 |
f5457ffae1b82687a5017c73b664105604c7466eab45cd49e0bab82ff8dd2d96
|
File details
Details for the file ihen404_x402_langchain-1.0.1-py3-none-any.whl.
File metadata
- Download URL: ihen404_x402_langchain-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
456c3b89a3f671731c151e11163dd3db3fdcf8cd92c1ece7467c81f6423d769a
|
|
| MD5 |
46e21336687924c4883ccb888482512c
|
|
| BLAKE2b-256 |
d7b02a40a80132ce4bc66e820fde7e716a5c54e7476036fbe81b65c0e247fdc3
|