oneshot-python 0.2.0__tar.gz → 0.3.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.
- {oneshot_python-0.2.0 → oneshot_python-0.3.0}/PKG-INFO +1 -1
- oneshot_python-0.3.0/README.md +110 -0
- {oneshot_python-0.2.0 → oneshot_python-0.3.0}/oneshot/client.py +6 -10
- {oneshot_python-0.2.0 → oneshot_python-0.3.0}/pyproject.toml +1 -1
- {oneshot_python-0.2.0 → oneshot_python-0.3.0}/.gitignore +0 -0
- {oneshot_python-0.2.0 → oneshot_python-0.3.0}/oneshot/__init__.py +0 -0
- {oneshot_python-0.2.0 → oneshot_python-0.3.0}/oneshot/_errors.py +0 -0
- {oneshot_python-0.2.0 → oneshot_python-0.3.0}/oneshot/x402.py +0 -0
- {oneshot_python-0.2.0 → oneshot_python-0.3.0}/tests/__init__.py +0 -0
- {oneshot_python-0.2.0 → oneshot_python-0.3.0}/tests/test_x402.py +0 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# oneshot-python
|
|
2
|
+
|
|
3
|
+
Core Python SDK for the [OneShot](https://oneshotagent.com) API. Handles the x402 payment protocol (quote, sign, pay, poll) so your Python code can call any OneShot tool.
|
|
4
|
+
|
|
5
|
+
This is the foundation package. If you're using LangChain, install [`langchain-oneshot`](https://pypi.org/project/langchain-oneshot/) instead (it includes this package).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install oneshot-python
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from oneshot import OneShotClient
|
|
17
|
+
|
|
18
|
+
client = OneShotClient(
|
|
19
|
+
private_key="0x...",
|
|
20
|
+
test_mode=True, # Base Sepolia testnet (default)
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
# Paid tool — handles 402 -> sign -> pay -> poll automatically
|
|
24
|
+
result = client.call_tool("/v1/tools/email/send", {
|
|
25
|
+
"to": "user@example.com",
|
|
26
|
+
"subject": "Hello from Python",
|
|
27
|
+
"body": "Sent via oneshot-python",
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
# Free endpoint
|
|
31
|
+
balance = client.call_free_get("/v1/wallet/balance")
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Async
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import asyncio
|
|
38
|
+
from oneshot import OneShotClient
|
|
39
|
+
|
|
40
|
+
client = OneShotClient(private_key="0x...", test_mode=True)
|
|
41
|
+
|
|
42
|
+
async def main():
|
|
43
|
+
result = await client.acall_tool("/v1/tools/research", {
|
|
44
|
+
"topic": "AI agent frameworks",
|
|
45
|
+
"depth": "quick",
|
|
46
|
+
})
|
|
47
|
+
print(result)
|
|
48
|
+
|
|
49
|
+
asyncio.run(main())
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## How Payments Work
|
|
53
|
+
|
|
54
|
+
Paid endpoints use the [x402 protocol](https://x402.org):
|
|
55
|
+
|
|
56
|
+
1. Client POSTs to a tool endpoint
|
|
57
|
+
2. API returns `402 Payment Required` with a USDC quote
|
|
58
|
+
3. Client signs a `TransferWithAuthorization` (EIP-3009) locally
|
|
59
|
+
4. Client re-POSTs with the signed payment in the `x-payment` header
|
|
60
|
+
5. API processes the request and returns the result
|
|
61
|
+
|
|
62
|
+
Your private key never leaves your machine. All signing happens locally via `eth-account`.
|
|
63
|
+
|
|
64
|
+
## Configuration
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
# Test mode (default) — Base Sepolia, no real money
|
|
68
|
+
client = OneShotClient(private_key="0x...", test_mode=True)
|
|
69
|
+
|
|
70
|
+
# Production — Base Mainnet, real USDC
|
|
71
|
+
client = OneShotClient(private_key="0x...", test_mode=False)
|
|
72
|
+
|
|
73
|
+
# Debug logging
|
|
74
|
+
client = OneShotClient(private_key="0x...", debug=True)
|
|
75
|
+
|
|
76
|
+
# Custom API URL
|
|
77
|
+
client = OneShotClient(private_key="0x...", base_url="https://custom-api.example.com")
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## API
|
|
81
|
+
|
|
82
|
+
### Paid tools
|
|
83
|
+
|
|
84
|
+
- `call_tool(endpoint, payload, *, max_cost=None, timeout_sec=120)` — Blocking
|
|
85
|
+
- `acall_tool(endpoint, payload, *, max_cost=None, timeout_sec=120)` — Async
|
|
86
|
+
|
|
87
|
+
### Free endpoints
|
|
88
|
+
|
|
89
|
+
- `call_free_get(endpoint, params=None)` / `acall_free_get(...)` — GET
|
|
90
|
+
- `call_free_post(endpoint, payload=None)` / `acall_free_post(...)` — POST
|
|
91
|
+
- `call_free_patch(endpoint, payload=None)` / `acall_free_patch(...)` — PATCH
|
|
92
|
+
|
|
93
|
+
## Requirements
|
|
94
|
+
|
|
95
|
+
- Python 3.10+
|
|
96
|
+
- `httpx >= 0.27.0`
|
|
97
|
+
- `eth-account >= 0.13.0`
|
|
98
|
+
|
|
99
|
+
## Links
|
|
100
|
+
|
|
101
|
+
- [Documentation](https://docs.oneshotagent.com/sdk/installation#install-via-pip-python)
|
|
102
|
+
- [LangChain integration](https://pypi.org/project/langchain-oneshot/) — 26 tools as LangChain BaseTool
|
|
103
|
+
- [GAME plugin](https://pypi.org/project/game-plugin-oneshot/) — Virtuals Protocol integration
|
|
104
|
+
- [TypeScript SDK](https://www.npmjs.com/package/@oneshot-agent/sdk)
|
|
105
|
+
- [MCP Server](https://www.npmjs.com/package/@oneshot-agent/mcp-server)
|
|
106
|
+
- [GitHub](https://github.com/oneshot-agent/sdk)
|
|
107
|
+
|
|
108
|
+
## License
|
|
109
|
+
|
|
110
|
+
MIT
|
|
@@ -25,19 +25,12 @@ from oneshot._errors import (
|
|
|
25
25
|
)
|
|
26
26
|
from oneshot.x402 import sign_payment_authorization
|
|
27
27
|
|
|
28
|
-
SDK_VERSION = "0.
|
|
28
|
+
SDK_VERSION = "0.3.0"
|
|
29
29
|
|
|
30
30
|
# ---------------------------------------------------------------------------
|
|
31
|
-
# Environment configuration
|
|
31
|
+
# Environment configuration
|
|
32
32
|
# ---------------------------------------------------------------------------
|
|
33
33
|
|
|
34
|
-
TEST_ENV = {
|
|
35
|
-
"base_url": "https://api-stg.oneshotagent.com",
|
|
36
|
-
"rpc_url": "https://sepolia.base.org",
|
|
37
|
-
"chain_id": 84532,
|
|
38
|
-
"usdc_address": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
39
|
-
}
|
|
40
|
-
|
|
41
34
|
PROD_ENV = {
|
|
42
35
|
"base_url": "https://win.oneshotagent.com",
|
|
43
36
|
"rpc_url": "https://mainnet.base.org",
|
|
@@ -45,6 +38,9 @@ PROD_ENV = {
|
|
|
45
38
|
"usdc_address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
46
39
|
}
|
|
47
40
|
|
|
41
|
+
# Deprecated: staging is internal-only. TEST_ENV now aliases to PROD_ENV.
|
|
42
|
+
TEST_ENV = PROD_ENV
|
|
43
|
+
|
|
48
44
|
_POLL_INTERVAL = 2.0 # seconds
|
|
49
45
|
_MAX_POLL_RETRIES = 3
|
|
50
46
|
|
|
@@ -60,7 +56,7 @@ class OneShotClient:
|
|
|
60
56
|
self,
|
|
61
57
|
private_key: str,
|
|
62
58
|
*,
|
|
63
|
-
test_mode: bool =
|
|
59
|
+
test_mode: bool = False,
|
|
64
60
|
base_url: Optional[str] = None,
|
|
65
61
|
debug: bool = False,
|
|
66
62
|
) -> None:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "oneshot-python"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.3.0"
|
|
4
4
|
description = "Core Python SDK for the OneShot API — HTTP client with x402 payment handling"
|
|
5
5
|
readme = {text = "Core Python SDK for the OneShot API", content-type = "text/plain"}
|
|
6
6
|
license = "MIT"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|