{"question":"How do I pay for and call a P0 route from JavaScript, Python or LangChain?","url":"https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/integrations","answer":"Install an x402 client, give it your own wallet, and call the paid route: the client receives HTTP 402, signs the payment and retries, and the second answer is the data. The snippets below call https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/vuln/cve?id=CVE-2021-44228 ($0.005 per call, live from the tariff) from JavaScript, Python and a LangChain tool.","target":{"path":"/vuln/cve","url":"https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/vuln/cve?id=CVE-2021-44228","price_usd":0.005},"networks":"USDC on Base, Arbitrum, Polygon, Avalanche, Optimism, Celo, Ethereum; USDT0 on Arbitrum; sBTC on Stacks","snippets":[{"id":"javascript","language":"javascript","title":"JavaScript: @x402/fetch","install":"npm install @x402/fetch @x402/core @x402/evm viem","code":"import { wrapFetchWithPayment } from \"@x402/fetch\";\nimport { x402Client } from \"@x402/core/client\";\nimport { ExactEvmScheme } from \"@x402/evm/exact/client\";\nimport { privateKeyToAccount } from \"viem/accounts\";\n\n// Your own wallet key, from the environment. It stays on your machine.\nconst signer = privateKeyToAccount(process.env.EVM_PRIVATE_KEY);\nconst client = new x402Client();\nclient.register(\"eip155:*\", new ExactEvmScheme(signer));\nconst fetchWithPayment = wrapFetchWithPayment(fetch, client);\n\n// The first request gets HTTP 402; the wrapper signs the payment and retries.\nconst response = await fetchWithPayment(\"https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/vuln/cve?id=CVE-2021-44228\", { method: \"GET\" });\nconsole.log(response.status, await response.json());","notes":"wrapFetchWithPayment wraps fetch; the wallet is a viem account. Replace the URL with any paid route of this site."},{"id":"python","language":"python","title":"Python: official x402 client (requests)","install":"pip install \"x402[requests]\" eth_account","code":"import os\nfrom urllib.parse import urlencode\n\nfrom eth_account import Account\nfrom x402 import x402ClientSync\nfrom x402.http.clients import x402_requests\nfrom x402.mechanisms.evm import EthAccountSigner\nfrom x402.mechanisms.evm.exact.register import register_exact_evm_client\n\nBASE = \"https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev\"\n\nclient = x402ClientSync()\n# Your own wallet key, from the environment. It stays on your machine.\nregister_exact_evm_client(client, EthAccountSigner(Account.from_key(os.getenv(\"EVM_PRIVATE_KEY\"))))\n\n\ndef p0_cve(cve_id: str) -> dict:\n    \"\"\"Pay for and fetch one CVE triage from P0 (path /vuln/cve).\"\"\"\n    with x402_requests(client) as session:\n        response = session.get(BASE + \"/vuln/cve?\" + urlencode({\"id\": cve_id}))\n        response.raise_for_status()\n        return response.json()\n\n\nif __name__ == \"__main__\":\n    print(p0_cve(\"CVE-2021-44228\"))","notes":"x402ClientSync and x402_requests are the synchronous client; the same package has an httpx (async) client, see the quickstart."},{"id":"langchain","language":"python","title":"LangChain: a tool around the Python function","install":"pip install langchain  # plus the Python snippet above","code":"from langchain.tools import tool\n\n# p0_cve is the function from the Python snippet above (save it as p0_client.py).\nfrom p0_client import p0_cve\n\n\n@tool\ndef cve_triage(cve_id: str) -> dict:\n    \"\"\"Triage one CVE: CVSS score, EPSS exploit probability and CISA KEV status. Paid per call over x402.\"\"\"\n    return p0_cve(cve_id)\n\n\n# Give cve_triage to your agent in its list of tools, as described in the LangChain Tools guide.","notes":"A plain @tool function that calls p0_cve; the payment happens inside the call."}],"verified":{"date":"2026-10-25","sources":[{"name":"x402 documentation: Quickstart for Buyers","url":"https://docs.x402.org/getting-started/quickstart-for-buyers"},{"name":"npm: @x402/fetch (Apache-2.0), latest 2.28.0","url":"https://www.npmjs.com/package/@x402/fetch"},{"name":"PyPI: x402 (MIT), latest 2.25.0","url":"https://pypi.org/project/x402/"},{"name":"LangChain documentation: Tools","url":"https://docs.langchain.com/oss/python/langchain/tools"}]},"notes":["The snippets follow the official x402 quickstart for buyers, read on 2026-10-25; P0 does not run them with a live payment on this page, and the page tests check their syntax only.","The wallet must hold USDC on a network P0 accepts over x402 (USDC on Base, Arbitrum, Polygon, Avalanche, Optimism, Celo, Ethereum; USDT0 on Arbitrum; sBTC on Stacks). The snippets register EVM networks (eip155:*); for Solana and other chains add the matching package from the quickstart.","No account, API key or sign-up is needed. Bad input is refused before any charge. No x402 client? Pay by a direct transfer and claim it with the transaction hash: https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/pay.","Swap the path and parameters for any other paid route listed in https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/openapi.json."],"related":["https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/answers/pay-api-with-x402","https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/answers/cve-epss-kev-priority","https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/pay","https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/openapi.json"],"license":"https://x402-bazaar-rank.x402-bazaar-rank-worker.workers.dev/terms","operator":"dev Mike","version":"2026-10-25.1","data_as_of":"2026-10-25"}