Skip to main content

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 X402WebScraperTool for LangChain, LangGraph, and CrewAI agents.
  • Automated HTTP 402 Settlement: Automatically handles $0.005 Base USDC micro-payment challenges via X-Payment headers.
  • 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

ihen404_x402_langchain-1.0.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ihen404_x402_langchain-1.0.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

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

Hashes for ihen404_x402_langchain-1.0.1.tar.gz
Algorithm Hash digest
SHA256 b05a8678b949c678832e971f9cf2614ee772cff3cf472231a65ade1806dfedb0
MD5 caa4a621ad3b1b6e5b86e9d2aa993b9f
BLAKE2b-256 f5457ffae1b82687a5017c73b664105604c7466eab45cd49e0bab82ff8dd2d96

See more details on using hashes here.

File details

Details for the file ihen404_x402_langchain-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ihen404_x402_langchain-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 456c3b89a3f671731c151e11163dd3db3fdcf8cd92c1ece7467c81f6423d769a
MD5 46e21336687924c4883ccb888482512c
BLAKE2b-256 d7b02a40a80132ce4bc66e820fde7e716a5c54e7476036fbe81b65c0e247fdc3

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page