16 Commits

Author SHA1 Message Date
phdargen
9a718b002d
Fix py publishing (#2295)
* fix uv build

* exclude-newer = 3 days
2026-05-13 22:37:58 +02:00
Carson Roscoe
dd49a43618
chore: version typescript/go/python packages (#1163)
* chore: version typescript packages

* chore: version python package

* chore: version go package

* chore: update lock files
2026-02-11 16:30:47 -05:00
Carson Roscoe
ca7f38e5e7
chore: version python package (#1005) 2026-01-21 16:47:16 -08:00
Carson Roscoe
30a847d7d1
feat: New Python SDK with v2 support (#841)
* chore: renamed python/x402 to python/legacy

* feat: initial Python core SDK

* feat: added core HTTP wrappers

* feat: added core types

* feat: added evm mechanism for exact v1/v2

* feat: added httpx client

* feat: added requests client

* feat: added fastapi middleware

* feat: added flask middleware

* feat: added integration tests

* feat: added Python SDK to e2e tests

* python-v2: fix workflow checks (#863)

* fix format

* fix lint

* fix build

* fix pytest

* Fix syntax errors and missing imports in manual integration example (#902)

- Add missing imports (base64, json, Response, JSONResponse, PaymentPayload, FacilitatorClient)
- Fix function signature syntax error
- Fix dict initialization syntax (colon to equals)
- Add missing return statement after successful payment
- Remove trailing whitespace

* feat: add Python SDK v2 server examples (FastAPI, Flask)  (#879)

* feat: add fastapi example project configuration

* feat: add fastapi example with x402 payment middleware

* docs: add comprehensive README for fastapi example

* feat: add flask example project configuration

* feat: add flask example with x402 payment middleware

* docs: add comprehensive README for flask example

* feat: add test clients for fastapi and flask examples

* docs: add test client usage to READMEs

* chore - remove python-version and test-client.py

* docs - remove test client guide from README.md

* chore - remove license and classifier

* feat - add description and mime type

* feat - update .env-local

* feat: add Python v2 client examples (httpx & requests) (#857)

* feat: add Python v2 client examples (httpx & requests)

Add simple client examples demonstrating httpx (async) and requests (sync) usage with the x402 Python v2 SDK.

- examples/python/clients/example.py - Simple example showing both httpx and requests
- Uses EthAccountSigner with register_exact_evm_client helper
- Minimal configuration required

* refactor: split Python client examples into separate directories

Address PR review feedback:
- Separate httpx/ and requests/ directories
- Add pyproject.toml for uv sync support
- Add environment variable validation
- Add payment response header extraction
- Use context manager for requests session cleanup

Tested on Base Sepolia testnet:
- httpx: tx 0xce49f668aba01c4b0b1af2eb0d9a381f4c62295506a91f20af479e0e834ef350
- requests: tx 0xb83b6feefa5a744b7779ba5b37df33f9c7241f58119454d66102acd97a92f024

* Update examples/python/clients/httpx/main.py

Co-authored-by: phdargen <pdargent@icloud.com>

* Update examples/python/clients/requests/main.py

Co-authored-by: phdargen <pdargent@icloud.com>

---------

Co-authored-by: phdargen <pdargent@icloud.com>

* feat(python): Make v2 framework and client dependencies optional extras (#901)

* python-v2: add svm mechanism (#904)

* add svm mechanism

* add unit tests

* add integration tests

* update server examples

* add e2e tests

* update clients

* make EVM/SVM dependencies optional extras

* fix legacy uv paths

* V2 python bazaar (#929)

* add bazaar extension

* strip query params for discovery

* fix 862

* updated e2e tests

* Add advanced Python client examples (#947)

* Add advanced Python client examples

Implements 5 advanced patterns demonstrating x402 SDK v2 features:
- hooks.py: Payment lifecycle hooks (before, after, failure)
- preferred_network.py: Custom network preference selector
- builder_pattern.py: Network-specific registration with wildcards
- error_recovery.py: Error classification and recovery strategies
- custom_transport.py: Custom httpx transport with retry/timing

Includes:
- CLI entry point (index.py) for running examples
- Comprehensive test suite (40 unit tests)
- E2E integration tests
- README documentation

All tests passing.

* Remove tests and examples beyond TypeScript SDK parity

Address PR review feedback:
- Remove tests directory (tests belong in SDK, not examples)
- Remove custom_transport.py (runtime error, beyond TS parity)
- Remove error_recovery.py (duplicate of hooks.py, beyond TS parity)
- Update index.py, README.md, pyproject.toml accordingly

* Address PR feedback: add SVM support and use optional deps

- Update pyproject.toml to use x402[evm,svm,httpx] instead of
  listing dependencies separately
- Add Solana/SVM network examples to preferred_network.py
- Support both EVM and SVM signers for cross-chain flexibility
- Update .env-local with SOLANA_PRIVATE_KEY option

* Python-v2: facilitator example + e2e (#950)

* add facilitator example

* improve svm signer

* add description to DiscoveredResource

* add facilitator e2e

* add paywall builder (#953)

* Add Python custom client example (#954)

Demonstrates manual x402 v2 payment flow without convenience wrappers.

Shows the 6-step process:
1. Initialize client and register payment schemes
2. Make initial request, receive 402
3. Decode PAYMENT-REQUIRED header
4. Create signed payment payload
5. Retry with PAYMENT-SIGNATURE header
6. Handle success/failure response

Useful for integrating with non-standard HTTP libraries or implementing
custom retry logic.

* feat(v2-sdk): support async dynamic hooks for price and metadata (#900)

* feat(http): implement dual class design for sync/async support

- Add x402HTTPResourceServer (async) for FastAPI/Starlette
- Add x402HTTPResourceServerSync (sync) for Flask/Django
- Share common logic via _x402HTTPServerBase
- Remove dynamic description/resource (keep only dynamic price/payTo)
- Update Flask middleware to use sync server directly
- Integrate with enrich_extensions for bazaar support
- Add per-route hook_timeout_seconds configuration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(types): add missing Awaitable import and fix test import sorting

- Add Awaitable import to types.py for DynamicPayTo/DynamicPrice type hints
- Fix import block sorting in test_async_hooks.py and test_core.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: simplify API by removing unused types and making timeout opt-in

Address reviewer feedback from @phdargen:
- Remove SyncDynamicPayTo/SyncDynamicPrice (unused types that would require SyncPaymentOption to be useful)
- Change hook_timeout_seconds default to None (opt-in, matching TS/Go parity)
- Export x402HTTPResourceServerSync from http/__init__.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

* python-v2: make create_facilitator_config work with both V1 and V2 (#968)

* make create_facilitator_config work with both V1 and V2

* fix lint

* feat: add Python SDK v2 server advanced example (FastAPI) (#952)

* feat - add pyproject.toml, uv.lock for advanced example

* feat - add bazaar extension

* feat - add hooks

* feat - add x402 extensions to pyproject.toml

* feat - add dynamic pricing feature

* feat - add dynamic pay-to and custom money parser features

* docs - add README for advanced server example

* style - apply lint

* chore - add comments for bazaar extension code

* fix: python v2 x402HTTPAdapter retry logic (#978)

* fix: fix consecutive payment bug in x402HTTPAdapter

- Replace instance-level _is_retry flag with per-request header
  to prevent state leakage between consecutive 402 requests.

* tests - add test case for consecutive payment with x402HTTPAdapter

* style - apply lint

* Python-v2: async lifecycle hooks (#975)

* add dual sync/async classes for server/client/facilitator

* update integration/e2e tests

* add unit tests for core, http and implement wrapHttpxWithPaymentFromConfig/wrapRequestsWithPayment

* refactor core server/client/facilitator

* refactor x402_http_server/facilitator_client/x402_http_client

* update exmamples

* add utility function that takes care of html-safe escaping

* add sdk readmes

* add retry unit tests to httpx client

* Update Python SDK Docs for v2 (#976)

* Porting docs and updating for v2 changes (#813)

* porting docs and updating for v2 changes

* update quickstart for sellers

* update quickstarts, miniapps, and mcp docs

* update doc links

* update FAQs

* fix getting started docs

* update core concepts

* remove miniapps guide

* update extensions

* fix bazaar code examples

* fix broken links and yaml file

* remove unnecessary protocol layer doc

* add migration guide

* update documentation for python v2 sdk

* testing pr preview

* docs(python): remove unused os imports and align with TS tab patterns

- Remove unused 'import os' from FastAPI and Flask examples in quickstart-for-sellers
- Update bazaar-discovery-layer Python example to use hardcoded '0xYourPrivateKey' to match TypeScript tab consistency

* update migration doc

* cleanup comments

* cleanup readme

* fix: Python facilitator e2e code

* fix: lint

---------

Co-authored-by: phdargen <p.dargent@cern.ch>
Co-authored-by: somesome <57699892+sohw400@users.noreply.github.com>
Co-authored-by: Logan Kang <kcs93023@gmail.com>
Co-authored-by: 1bcMax <viewitter@gmail.com>
Co-authored-by: phdargen <pdargent@icloud.com>
Co-authored-by: Vladimir Sotnikov <bubert9@gmail.com>
Co-authored-by: Shuhei <shuhei0866@gmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Faris Habib <faris.habib@coinbase.com>
2026-01-21 16:32:07 -08:00
Carson Roscoe
1a79feaf94
Development v2 (#705)
* chore: move packages, examples and e2e clients/servers/facilitators to legacy subfolders

* feat: added @x402/core to /typescript/packages

* feat: added @x402/evm to /typescript/packages/mechanism

* feat: added @x402/svm to /typescript/packages/mechanism

* feat: added @x402/extensions to /typescript/packages

* feat: added @x402/fetch to /typescript/packages/http

* feat: added @x402/axios to /typescript/packages/http

* feat: added @x402/paywall to /typescript/packages/http

* feat: added @x402/express to /typescript/packages/http

* feat: added @x402/hono to /typescript/packages/http

* feat: added @x402/next to /typescript/packages/http

* chore: update /typescript pnpm packaging

* feat: added core files to /go

* feat: added evm mechanism to /go

* feat: added svm mechanism to /go

* feat: added extensions to /go

* feat: added gin to /go/http

* feat: added tests to /go

* feat: rewrote e2e test suite system

* feat: added axios client to e2e suite

* feat: added fetch client to e2e suite

* feat: added go http client to e2e suite

* feat: added express server to e2e suite

* feat: added hono server to e2e suite

* feat: added next server to e2e suite

* feat: added gin server to e2e suite

* feat: added typescript facilitator to e2e suite

* feat: added go facilitator to e2e suite

* feat: added fetch example to examples/typescript/clients

* feat: added axios example to examples/typescript/clients

* feat: added advanced example to examples/typescript/clients

* feat: added custom example to examples/typescript/clients

* feat: added express example to examples/typescript/servers

* feat: added hono example to examples/typescript/servers

* feat: added advanced example to examples/typescript/servers

* feat: added custom example to examples/typescript/servers

* feat: added facilitator example to examples/typescript

* chore: update /examples/typescript pnpm packaging

* feat: added http client to examples/go/clients

* feat: added advanced client to examples/go/clients

* feat: added custom client to examples/go/clients

* feat: added gin server to examples/go/servers

* feat: added advanced server to examples/go/servers

* feat: added custom server to examples/go/servers

* feat: added facilitator to examples/go

* chore: updated github workflows

* fix: typescript examples fotmat/lint

* v2: next example (#706)

* fix legacy example builds

* add next example

* fix format

* upgrade to next 16

* fix legacy build

* fix e2e tests

* V2: next api wrapper (#707)

* add next route wrapper

* add protected api to example page

* add unit tests

* fix missing settle failure check

* added e2e tests for withX402

* add SettleResponse to ProcessSettleResultResponse

* add requirements to payment-header

* feat: add v2 support to x402.org facilitator

* feat: dynamically load bazaar extension in Next only when used

* fix: x402Facilitator in typescript calling onAfterVerify instead on onVerifyFailure on failure

* feat: add ERC1271 and ERC6492 support to Typescript facilitator

* feat: update typescript facilitator example & e2e test for ERC1271/ERC6492 support

* feat: add ERC1271 and ERC6492 support to Go facilitators

* feat: update go facilitator example & e2e test for ERC1271/ERC6492 support

* v2: express fixes + unit tests  (#712)

* add express fixes from v1

* add units test for express/hono

* added fetch/axios unit tests

* v2: Clean up paywall (#710)

* Remove cdpClientKey and sessionTokenEndpoint from PaywallConfig

Remove Onramp functionality from EvmPaywall

Remove Coinbase fields from paywall template generation

* Migrate site to @x402/next with v2 protocol support

* Clean up tests

* remove CDP onramp from core paywall

* Update templates and build process

* Format

* Lockfile

* mock templates for CI

* Format

* Generate new templates

* Format

* v2: facilitator sync fix (#716)

* update next/react versions

* update site to next 16, tailwind 4 and fix env vars

* fix initializeOnStart pattern

* security: bump quic-go dependency for security fix GHSA-47m2-4cr7-mhcw

* v2:fix ts advanced/custom examples (#717)

* fix ts examples

* add clients/advanced/preferred-network example

* feat: improved e2e cli for external facilitator testing

* feat: updated evm & svm signer interfaces in go

* feat: updated evm & svm signer interfaces in typescript

* feat: reverted SupportedKind's kinds structure in go

* feat: reverted SupportedKind's kinds structure in typescript

* feat: refactor facilitator SVM signer interface in typescript

* go example fixes (#719)

* feat: cleanup go bazaar extension

* V2: docs update (#729)

* ts example docs

* improve ts package docs

* feat: dynamic bazaar import for all server middleware

* feat: allow dynamic response building for 402 response in typescript

* feat: allow dynamic response building for 402 response in go

* feat: added withBazaar HTTPFacilitatorClient wrapper

* feat: added linting to go

* fix: lint go

* improve go example docs (#733)

* feat: Solana PR review feedback in typescript

* feat: Solana PR review feedback in go

* fix: locks & paywall gen after rebase off main

* fix: format

* docs: improve @x402/extensions README with comprehensive documentation (#731)

* First draft of contributor docs (#738)

Correct ts contributing

Clean up contribution guidelines

* feat: updated specs for v2

* fix: merge with main, fixed lock

* v2: go settlement failure and initOnStart fixes (#720)

* go settlement failure and initOnStart fixes

* update go unit tests

* update readmes

* feat: review & improve examples & READMEs

* v2: add multiple payment options for go (#743)

* add multiple payment options for go

* fix SyncFacilitatorOnStart

* v2: add hooks for advanced go example (#745)

* add hooks for advanced go example

* fix legacy ts deps

* feat: added server initialization validation

* feat: added @x402 package workflows

* v2: add miniapp and mcp examples (#746)

* add miniapp example

* fix format

* add mcp example

* fix format

* v2: add manifest to miniapp example (#751)

* add manifest to miniapp

* fix format

* feat: x402 website redesign (#750)

* port new website to public repo

* chore: update pnpm-lock.yaml with motion dependency

* feat: add x402 V2 launch blog post and update hero code snippet

- Add /writing/x402-v2-launch blog post page
- Add blog images (blog_intro.png, blog_x402_layers.png, homepage_build5.png)
- Enable Writing nav link in NavBar and Footer
- Update hero code snippet to show V2 SDK usage
- Fix CodeSnippet to support multi-line code

* feat: edit nav for mobile

* Revert "feat: edit nav for mobile"

This reverts commit 475999a2a84f1fab875cd0fe2bb74d44dba7e1bd.

* feat: add ecosystem page and minor home page tweaks

* feat: fix typography in ecosystem

* homepage qa fixes

* feat: add ecosystem icons and fix halftone

* cleanup assets

* fix: minor bug on faq

* feat: add hamburger menu to mobile

* Update README (#755)

* Update readme

* Install instructions and typos

* feat: update site sample code & reduce supported networks

* fix: v1 header in README updated to v2

---------

Co-authored-by: phdargen <p.dargent@cern.ch>
Co-authored-by: A. McDermott <amanda.p.mcdermott@gmail.com>
Co-authored-by: Vedant Anand <136731196+VedantAnand17@users.noreply.github.com>
Co-authored-by: Faris Habib <frs@hbb.dev>
Co-authored-by: erikreppel-cb <erik.reppel@coinbase.com>
2025-12-11 07:41:57 -08:00
Carson Roscoe
0dfd3e683f
chore: version python package (#348) 2025-08-19 10:19:21 -07:00
Carson Roscoe
318d174a43
chore: version python package (#329) 2025-08-09 10:10:38 -04:00
Carson Roscoe
9e539014a6
chore: version python package (#312) 2025-07-31 16:12:26 -07:00
Carson Roscoe
69c0401948
chore: bump x402 package version (#290) 2025-07-16 09:06:20 -07:00
Amanda McDermott
679389022a
feat: Paywall support for Python (flask & fastapi) (#279)
* WIP python paywall

* Add paywall config

* Fix type errors, add flask to project deps

* Pydantic v2.10 doesn't support serialize_by_alias as a config option

* clean up middlewares

* That was unnecessarily complicated

* per pydantic: use  instead of  on Python < 3.12

* Update paywall to full html file, update path

* Allow users to pass in custom HTML as a string for their paywall

* Validate supported networks

* Don't use type in middleware, but do verify

* Minify paywall html during build process

* Add example that uses new python paywall

* Update env to be mainnet in mainnet example

* Add flask and fastapi fullstack examples

* Correct types

* Update paywall html

* Hide balance on paywall

* Format

* ADd proper logging to fastapi middleware

* Escape strings and guard against prototype pollution

* Automatically copy the paywall file over to the python directory

* Update example lockfiles

* Update python tests

* Update paywall template build steps so python matches TS

* Format and lint
2025-07-11 14:42:18 -07:00
Carson Roscoe
f87717093b
depps: in python updated x402's pydantic depp to >=2.10.3 (#280)
* depps: in python updated x402's pydantic depp to >=2.10.3

* fix: lockfiles
2025-07-10 15:34:01 -07:00
Carson Roscoe
094dcd2b95
chore: bump python package version (#263) 2025-06-27 14:51:44 -07:00
Carson Roscoe
008c45730c
feat: initial flask middleware implementation (#257) 2025-06-25 15:28:33 -07:00
Carson Roscoe
5693bab6da
feat: expanded support from USDC to any eip-3009 asset (#249)
* feat: expanded support from USDC to any eip-3009 asset

* fix: unit tests
2025-06-19 11:47:28 -07:00
Carson Roscoe
9288c8d3b0
feat: python x402 mainnet (#247)
* feat: added facilitator config

* initial

* working towards downgrading pydantic

* fix: first mainnet call

* feat: updated cdp-sdk version in example to prod
2025-06-18 16:00:49 -07:00
erikreppel-cb
830976be46
[Draft] Add python support (#215)
* Start types

* Increase tests and fix type issues

* feat: completed fastapi draft and added example (#229)

* feat: fixed fastapi and added example

* chore: tweak README

* feat: python clients (#226)

* feat: httpx client and example

* fix: cleanup httpx example

* feat: added requests example

* feat: unit testing clients & helpers

* chore: format/lint

* chore: correct READMEs of examples

* fix: removed debug logs

* fix: removed artifact code from testing

* chore: removed excess comments

* feat: refactored from web3 to eth_account as accounts

* feat: refactored interfaces per pr feedback

* fix: pr feedback

* chore: rebase & merge

* chore: renamed x402 request exports

* fix: pr feedback

* feat: release GHA and improved readme (#232)

* feat: release GHA and improved readme

* chore: bump to v0.1.1

* chore: renamed PyPi token

---------

Co-authored-by: Carson Roscoe <CarsonRoscoe7@gmail.com>
2025-06-13 15:42:26 -07:00