payapi-client 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Chet Parker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,37 @@
1
+ Metadata-Version: 2.4
2
+ Name: payapi-client
3
+ Version: 0.1.0
4
+ Summary: Client for PayAPI Market. It finds a listing and reads the provider's x402 quote. It does not hold funds.
5
+ Author: PayAPI Market
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://payapi.market
8
+ Project-URL: Repository, https://github.com/chetparker/x402-marketplace
9
+ Requires-Python: >=3.9
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Dynamic: license-file
13
+
14
+ # payapi-client
15
+
16
+ A Python client for PayAPI Market.
17
+
18
+ `search` reads the public discovery endpoint. `quote_and_pay` makes one unpaid request to the listing's own route and returns the provider's HTTP 402 unchanged, including payTo, amount and asset. It does not hold funds, sign or settle. The payment goes to the provider's own `payTo`.
19
+
20
+ Free to list, PayAPI takes 0% of each job.
21
+
22
+ ## Install
23
+
24
+ ```
25
+ pip install payapi-client
26
+ ```
27
+
28
+ ## Use
29
+
30
+ ```python
31
+ from payapi_client import PayAPIClient
32
+
33
+ client = PayAPIClient()
34
+ quote = client.quote_and_pay("listing-uuid")
35
+ ```
36
+
37
+ Pass `opener` to point tests at a stand-in.
@@ -0,0 +1,24 @@
1
+ # payapi-client
2
+
3
+ A Python client for PayAPI Market.
4
+
5
+ `search` reads the public discovery endpoint. `quote_and_pay` makes one unpaid request to the listing's own route and returns the provider's HTTP 402 unchanged, including payTo, amount and asset. It does not hold funds, sign or settle. The payment goes to the provider's own `payTo`.
6
+
7
+ Free to list, PayAPI takes 0% of each job.
8
+
9
+ ## Install
10
+
11
+ ```
12
+ pip install payapi-client
13
+ ```
14
+
15
+ ## Use
16
+
17
+ ```python
18
+ from payapi_client import PayAPIClient
19
+
20
+ client = PayAPIClient()
21
+ quote = client.quote_and_pay("listing-uuid")
22
+ ```
23
+
24
+ Pass `opener` to point tests at a stand-in.
@@ -0,0 +1,9 @@
1
+ """Client for https://payapi.market.
2
+
3
+ The quote comes from the provider's own HTTP 402. This package does not sign,
4
+ settle, or hold a wallet.
5
+ """
6
+
7
+ from payapi_client.client import DEFAULT_BASE, PayAPIClient
8
+
9
+ __all__ = ["DEFAULT_BASE", "PayAPIClient"]
@@ -0,0 +1,5 @@
1
+ """`python -m payapi_client` prints the default host. It does not send a request."""
2
+
3
+ from payapi_client.client import DEFAULT_BASE
4
+
5
+ print(DEFAULT_BASE)
@@ -0,0 +1,70 @@
1
+ """HTTP client for the PayAPI Market discovery and MCP endpoints."""
2
+
3
+ import json
4
+ from urllib.request import Request, urlopen
5
+
6
+ DEFAULT_BASE = "https://payapi.market"
7
+
8
+
9
+ class PayAPIClient:
10
+ def __init__(self, base=DEFAULT_BASE, opener=None):
11
+ self.base = base.rstrip("/")
12
+ self._open = opener or urlopen
13
+
14
+ def search(self, query, verified_only=True):
15
+ url = self.base + "/agent/search?q=" + _query(query)
16
+ if verified_only:
17
+ url += "&verified_only=1"
18
+ return self._get(url)
19
+
20
+ def quote_and_pay(self, listing_id):
21
+ if not listing_id or not isinstance(listing_id, str):
22
+ raise ValueError("A listing id is required")
23
+ body = {
24
+ "jsonrpc": "2.0",
25
+ "id": 1,
26
+ "method": "tools/call",
27
+ "params": {"name": "quote_and_pay", "arguments": {"id": listing_id}},
28
+ }
29
+ payload = self._post(self.base + "/mcp", body)
30
+ if payload.get("error"):
31
+ raise RuntimeError(payload["error"].get("message") or "MCP request failed")
32
+ result = payload.get("result") or {}
33
+ text = ""
34
+ for part in result.get("content") or []:
35
+ if part.get("type") == "text":
36
+ text = part.get("text") or ""
37
+ break
38
+ if result.get("isError"):
39
+ raise RuntimeError(text or "The tool returned an error")
40
+ if not text:
41
+ return result
42
+ try:
43
+ return json.loads(text)
44
+ except json.JSONDecodeError:
45
+ return text
46
+
47
+ def _get(self, url):
48
+ request = Request(url, headers={"Accept": "application/json"})
49
+ with self._open(request) as response:
50
+ return json.loads(response.read().decode("utf-8"))
51
+
52
+ def _post(self, url, body):
53
+ data = json.dumps(body).encode("utf-8")
54
+ request = Request(
55
+ url,
56
+ data=data,
57
+ headers={
58
+ "Content-Type": "application/json",
59
+ "Accept": "application/json, text/event-stream",
60
+ },
61
+ method="POST",
62
+ )
63
+ with self._open(request) as response:
64
+ return json.loads(response.read().decode("utf-8"))
65
+
66
+
67
+ def _query(value):
68
+ from urllib.parse import quote
69
+
70
+ return quote(value or "", safe="")
@@ -0,0 +1,37 @@
1
+ Metadata-Version: 2.4
2
+ Name: payapi-client
3
+ Version: 0.1.0
4
+ Summary: Client for PayAPI Market. It finds a listing and reads the provider's x402 quote. It does not hold funds.
5
+ Author: PayAPI Market
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://payapi.market
8
+ Project-URL: Repository, https://github.com/chetparker/x402-marketplace
9
+ Requires-Python: >=3.9
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Dynamic: license-file
13
+
14
+ # payapi-client
15
+
16
+ A Python client for PayAPI Market.
17
+
18
+ `search` reads the public discovery endpoint. `quote_and_pay` makes one unpaid request to the listing's own route and returns the provider's HTTP 402 unchanged, including payTo, amount and asset. It does not hold funds, sign or settle. The payment goes to the provider's own `payTo`.
19
+
20
+ Free to list, PayAPI takes 0% of each job.
21
+
22
+ ## Install
23
+
24
+ ```
25
+ pip install payapi-client
26
+ ```
27
+
28
+ ## Use
29
+
30
+ ```python
31
+ from payapi_client import PayAPIClient
32
+
33
+ client = PayAPIClient()
34
+ quote = client.quote_and_pay("listing-uuid")
35
+ ```
36
+
37
+ Pass `opener` to point tests at a stand-in.
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ payapi_client/__init__.py
5
+ payapi_client/__main__.py
6
+ payapi_client/client.py
7
+ payapi_client.egg-info/PKG-INFO
8
+ payapi_client.egg-info/SOURCES.txt
9
+ payapi_client.egg-info/dependency_links.txt
10
+ payapi_client.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ payapi_client
@@ -0,0 +1,20 @@
1
+ [project]
2
+ name = "payapi-client"
3
+ version = "0.1.0"
4
+ description = "Client for PayAPI Market. It finds a listing and reads the provider's x402 quote. It does not hold funds."
5
+ readme = "README.md"
6
+ requires-python = ">=3.9"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ authors = [{ name = "PayAPI Market" }]
10
+
11
+ [project.urls]
12
+ Homepage = "https://payapi.market"
13
+ Repository = "https://github.com/chetparker/x402-marketplace"
14
+
15
+ [build-system]
16
+ requires = ["setuptools>=77"]
17
+ build-backend = "setuptools.build_meta"
18
+
19
+ [tool.setuptools.packages.find]
20
+ include = ["payapi_client*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+