jupiter-swap-python 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
+ ---
2
+ name: Bug report
3
+ about: Report a bug
4
+ labels: bug
5
+ ---
6
+
7
+ **Describe the bug**
8
+ A clear description of the issue.
9
+
10
+ **To reproduce**
11
+ ```python
12
+ # Minimal code to reproduce
13
+ ```
14
+
15
+ **Expected behavior**
16
+ What you expected to happen.
17
+
18
+ **Environment**
19
+ - Python version:
20
+ - jupiter-swap-python version:
21
+ - OS:
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest a feature
4
+ labels: enhancement
5
+ ---
6
+
7
+ **What problem does this solve?**
8
+
9
+ **Proposed solution**
10
+
11
+ **Alternatives considered**
@@ -0,0 +1,7 @@
1
+ ## What does this PR do?
2
+
3
+ ## Checklist
4
+ - [ ] Tests pass (`pytest -v`)
5
+ - [ ] Linting passes (`ruff check`)
6
+ - [ ] Types check (`mypy jupiter_swap/`)
7
+ - [ ] CHANGELOG updated (if user-facing)
@@ -0,0 +1,36 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.11", "3.12", "3.13"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python ${{ matrix.python-version }}
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install dependencies
25
+ run: |
26
+ python -m pip install --upgrade pip
27
+ pip install -e ".[dev]"
28
+
29
+ - name: Lint
30
+ run: ruff check jupiter_swap/ tests/
31
+
32
+ - name: Type check
33
+ run: mypy jupiter_swap/
34
+
35
+ - name: Test
36
+ run: pytest -v --tb=short
@@ -0,0 +1,15 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.pyo
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ .eggs/
8
+ .venv/
9
+ venv/
10
+ .mypy_cache/
11
+ .ruff_cache/
12
+ .pytest_cache/
13
+ *.so
14
+ .env
15
+ .DS_Store
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ - Initial release
6
+ - Jupiter V6 quote and swap API
7
+ - Jupiter Ultra API (combined quote + swap with MEV protection)
8
+ - Jupiter Token API (metadata, verification, banned detection)
9
+ - Async/await with `httpx`
10
+ - Built-in rate limiting and 429 retry
11
+ - Fully typed with `py.typed` marker
@@ -0,0 +1,31 @@
1
+ # Contributing to jupiter-swap-python
2
+
3
+ ## Setup
4
+
5
+ ```bash
6
+ git clone https://github.com/JinUltimate1995/jupiter-swap-python.git
7
+ cd jupiter-swap-python
8
+ python -m venv .venv && source .venv/bin/activate
9
+ pip install -e ".[dev]"
10
+ ```
11
+
12
+ ## Development
13
+
14
+ ```bash
15
+ # Run tests
16
+ pytest -v
17
+
18
+ # Lint
19
+ ruff check jupiter_swap/ tests/
20
+
21
+ # Type check
22
+ mypy jupiter_swap/
23
+ ```
24
+
25
+ ## Pull Requests
26
+
27
+ 1. Fork the repo
28
+ 2. Create a feature branch
29
+ 3. Add tests for new functionality
30
+ 4. Ensure all checks pass
31
+ 5. Submit a PR
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 JinUltimate1995
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,187 @@
1
+ Metadata-Version: 2.4
2
+ Name: jupiter-swap-python
3
+ Version: 0.1.0
4
+ Summary: Async Python client for the Jupiter DEX aggregator on Solana — V6 quote/swap and Ultra API.
5
+ Project-URL: Homepage, https://github.com/JinUltimate1995/jupiter-swap-python
6
+ Project-URL: Repository, https://github.com/JinUltimate1995/jupiter-swap-python
7
+ Project-URL: Issues, https://github.com/JinUltimate1995/jupiter-swap-python/issues
8
+ Project-URL: Changelog, https://github.com/JinUltimate1995/jupiter-swap-python/blob/main/CHANGELOG.md
9
+ Author: JinUltimate1995
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: aggregator,async,crypto,defi,dex,jupiter,python,solana,swap,trading
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Framework :: AsyncIO
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development :: Libraries
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.11
24
+ Requires-Dist: httpx>=0.27
25
+ Provides-Extra: dev
26
+ Requires-Dist: mypy>=1.10; extra == 'dev'
27
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
28
+ Requires-Dist: pytest-httpx>=0.30; extra == 'dev'
29
+ Requires-Dist: pytest>=8.0; extra == 'dev'
30
+ Requires-Dist: ruff>=0.4; extra == 'dev'
31
+ Description-Content-Type: text/markdown
32
+
33
+ # jupiter-swap-python
34
+
35
+ **The missing Jupiter swap client for Python. Async. Typed. Production-tested.**
36
+
37
+ [![PyPI version](https://img.shields.io/pypi/v/jupiter-swap-python?color=blue)](https://pypi.org/project/jupiter-swap-python/)
38
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
39
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
40
+ [![CI](https://github.com/JinUltimate1995/jupiter-swap-python/actions/workflows/ci.yml/badge.svg)](https://github.com/JinUltimate1995/jupiter-swap-python/actions)
41
+
42
+ Jupiter's own Python SDK was abandoned (returns 404). This library fills the gap — a clean, typed, async client for [Jupiter](https://jup.ag), the #1 DEX aggregator on Solana.
43
+
44
+ ---
45
+
46
+ ## ⚡ Quickstart
47
+
48
+ ```bash
49
+ pip install jupiter-swap-python
50
+ ```
51
+
52
+ ### Get a quote
53
+
54
+ ```python
55
+ import asyncio
56
+ from jupiter_swap import JupiterClient
57
+
58
+ SOL = "So11111111111111111111111111111111111111112"
59
+ USDC = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
60
+
61
+ async def main():
62
+ async with JupiterClient() as jup:
63
+ quote = await jup.get_quote(SOL, USDC, 1_000_000_000) # 1 SOL
64
+ print(f"1 SOL = {int(quote.out_amount) / 1e6:.2f} USDC")
65
+ print(f"Price impact: {quote.price_impact_pct}%")
66
+
67
+ asyncio.run(main())
68
+ ```
69
+
70
+ ### Swap tokens
71
+
72
+ ```python
73
+ async with JupiterClient(api_key="your-key") as jup:
74
+ # Step 1: Get quote
75
+ quote = await jup.get_quote(SOL, USDC, 1_000_000_000)
76
+
77
+ # Step 2: Build swap transaction
78
+ swap = await jup.get_swap_transaction(
79
+ quote,
80
+ user_public_key="YourWalletPublicKey...",
81
+ priority_fee_lamports=500_000, # 0.0005 SOL
82
+ )
83
+
84
+ # Step 3: Sign and send swap.swap_transaction with your wallet
85
+ print(f"Transaction ready (block height: {swap.last_valid_block_height})")
86
+ ```
87
+
88
+ ### Ultra API (recommended for production)
89
+
90
+ ```python
91
+ async with JupiterClient(api_key="your-key") as jup:
92
+ # Combined quote + swap in one call
93
+ order = await jup.ultra_order(
94
+ input_mint=SOL,
95
+ output_mint=USDC,
96
+ amount=1_000_000_000,
97
+ taker="YourWalletPublicKey...",
98
+ )
99
+
100
+ print(f"Swap type: {order.swap_type}")
101
+ print(f"Out amount: {order.out_amount}")
102
+
103
+ # Sign order.swap_transaction with your wallet, then:
104
+ tx_sig = await jup.ultra_execute(signed_transaction, order.request_id)
105
+ print(f"Executed: {tx_sig}")
106
+ ```
107
+
108
+ ### Token verification
109
+
110
+ ```python
111
+ from jupiter_swap import TokenClient
112
+
113
+ async with TokenClient() as tokens:
114
+ info = await tokens.get_token_info("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v")
115
+ print(f"{info.symbol} — verified: {info.is_verified}, banned: {info.is_banned}")
116
+
117
+ # Check if a token is a known scam
118
+ if await tokens.is_banned("SomeScamMint..."):
119
+ print("🚫 Token is banned!")
120
+ ```
121
+
122
+ ---
123
+
124
+ ## 🔧 API Reference
125
+
126
+ ### `JupiterClient`
127
+
128
+ | Method | Description |
129
+ |--------|-------------|
130
+ | `get_quote()` | Get the best swap route and price |
131
+ | `get_swap_transaction()` | Build a signable transaction from a quote |
132
+ | `ultra_order()` | Combined quote + swap via Ultra API (MEV protection) |
133
+ | `ultra_execute()` | Execute a signed Ultra swap order |
134
+
135
+ ### `TokenClient`
136
+
137
+ | Method | Description |
138
+ |--------|-------------|
139
+ | `get_token_info()` | Get token metadata and verification status |
140
+ | `is_banned()` | Check if a token is on the banned list |
141
+ | `is_verified()` | Check if a token is verified |
142
+ | `get_strict_list()` | Get all strictly verified tokens |
143
+ | `refresh_banned_list()` | Manually refresh the banned list |
144
+
145
+ ### Models
146
+
147
+ - `QuoteResponse` — Route details, expected output, price impact
148
+ - `SwapResponse` — Base64 transaction ready to sign
149
+ - `UltraOrder` — Combined quote + transaction from Ultra API
150
+ - `TokenInfo` — Name, symbol, decimals, verification flags
151
+
152
+ ---
153
+
154
+ ## 🛡️ Why this library?
155
+
156
+ | Problem | Solution |
157
+ |---------|----------|
158
+ | Jupiter's Python SDK is deleted | This exists |
159
+ | Raw `httpx.post()` calls everywhere | Typed client with proper models |
160
+ | No 429 handling | Built-in retry with exponential backoff |
161
+ | Token safety is an afterthought | `TokenClient` with banned/verified checks |
162
+ | Sync-only clients | Fully async with `httpx` |
163
+
164
+ ---
165
+
166
+ ## 🔑 API Key
167
+
168
+ A Jupiter API key is optional but recommended for production use (higher rate limits).
169
+
170
+ Get one at [station.jup.ag](https://station.jup.ag/).
171
+
172
+ ```python
173
+ client = JupiterClient(api_key="your-api-key")
174
+ ```
175
+
176
+ ---
177
+
178
+ ## 📦 Also by JinUltimate1995
179
+
180
+ - [**solana-rpc-resilient**](https://github.com/JinUltimate1995/solana-rpc-resilient) — Solana RPC client with automatic failover, rate limiting, and circuit breaker
181
+ - [**dexscreener-python**](https://github.com/JinUltimate1995/dexscreener-python) — Async DexScreener API client for token/pair data across 80+ chains
182
+
183
+ ---
184
+
185
+ ## License
186
+
187
+ MIT
@@ -0,0 +1,155 @@
1
+ # jupiter-swap-python
2
+
3
+ **The missing Jupiter swap client for Python. Async. Typed. Production-tested.**
4
+
5
+ [![PyPI version](https://img.shields.io/pypi/v/jupiter-swap-python?color=blue)](https://pypi.org/project/jupiter-swap-python/)
6
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
8
+ [![CI](https://github.com/JinUltimate1995/jupiter-swap-python/actions/workflows/ci.yml/badge.svg)](https://github.com/JinUltimate1995/jupiter-swap-python/actions)
9
+
10
+ Jupiter's own Python SDK was abandoned (returns 404). This library fills the gap — a clean, typed, async client for [Jupiter](https://jup.ag), the #1 DEX aggregator on Solana.
11
+
12
+ ---
13
+
14
+ ## ⚡ Quickstart
15
+
16
+ ```bash
17
+ pip install jupiter-swap-python
18
+ ```
19
+
20
+ ### Get a quote
21
+
22
+ ```python
23
+ import asyncio
24
+ from jupiter_swap import JupiterClient
25
+
26
+ SOL = "So11111111111111111111111111111111111111112"
27
+ USDC = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
28
+
29
+ async def main():
30
+ async with JupiterClient() as jup:
31
+ quote = await jup.get_quote(SOL, USDC, 1_000_000_000) # 1 SOL
32
+ print(f"1 SOL = {int(quote.out_amount) / 1e6:.2f} USDC")
33
+ print(f"Price impact: {quote.price_impact_pct}%")
34
+
35
+ asyncio.run(main())
36
+ ```
37
+
38
+ ### Swap tokens
39
+
40
+ ```python
41
+ async with JupiterClient(api_key="your-key") as jup:
42
+ # Step 1: Get quote
43
+ quote = await jup.get_quote(SOL, USDC, 1_000_000_000)
44
+
45
+ # Step 2: Build swap transaction
46
+ swap = await jup.get_swap_transaction(
47
+ quote,
48
+ user_public_key="YourWalletPublicKey...",
49
+ priority_fee_lamports=500_000, # 0.0005 SOL
50
+ )
51
+
52
+ # Step 3: Sign and send swap.swap_transaction with your wallet
53
+ print(f"Transaction ready (block height: {swap.last_valid_block_height})")
54
+ ```
55
+
56
+ ### Ultra API (recommended for production)
57
+
58
+ ```python
59
+ async with JupiterClient(api_key="your-key") as jup:
60
+ # Combined quote + swap in one call
61
+ order = await jup.ultra_order(
62
+ input_mint=SOL,
63
+ output_mint=USDC,
64
+ amount=1_000_000_000,
65
+ taker="YourWalletPublicKey...",
66
+ )
67
+
68
+ print(f"Swap type: {order.swap_type}")
69
+ print(f"Out amount: {order.out_amount}")
70
+
71
+ # Sign order.swap_transaction with your wallet, then:
72
+ tx_sig = await jup.ultra_execute(signed_transaction, order.request_id)
73
+ print(f"Executed: {tx_sig}")
74
+ ```
75
+
76
+ ### Token verification
77
+
78
+ ```python
79
+ from jupiter_swap import TokenClient
80
+
81
+ async with TokenClient() as tokens:
82
+ info = await tokens.get_token_info("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v")
83
+ print(f"{info.symbol} — verified: {info.is_verified}, banned: {info.is_banned}")
84
+
85
+ # Check if a token is a known scam
86
+ if await tokens.is_banned("SomeScamMint..."):
87
+ print("🚫 Token is banned!")
88
+ ```
89
+
90
+ ---
91
+
92
+ ## 🔧 API Reference
93
+
94
+ ### `JupiterClient`
95
+
96
+ | Method | Description |
97
+ |--------|-------------|
98
+ | `get_quote()` | Get the best swap route and price |
99
+ | `get_swap_transaction()` | Build a signable transaction from a quote |
100
+ | `ultra_order()` | Combined quote + swap via Ultra API (MEV protection) |
101
+ | `ultra_execute()` | Execute a signed Ultra swap order |
102
+
103
+ ### `TokenClient`
104
+
105
+ | Method | Description |
106
+ |--------|-------------|
107
+ | `get_token_info()` | Get token metadata and verification status |
108
+ | `is_banned()` | Check if a token is on the banned list |
109
+ | `is_verified()` | Check if a token is verified |
110
+ | `get_strict_list()` | Get all strictly verified tokens |
111
+ | `refresh_banned_list()` | Manually refresh the banned list |
112
+
113
+ ### Models
114
+
115
+ - `QuoteResponse` — Route details, expected output, price impact
116
+ - `SwapResponse` — Base64 transaction ready to sign
117
+ - `UltraOrder` — Combined quote + transaction from Ultra API
118
+ - `TokenInfo` — Name, symbol, decimals, verification flags
119
+
120
+ ---
121
+
122
+ ## 🛡️ Why this library?
123
+
124
+ | Problem | Solution |
125
+ |---------|----------|
126
+ | Jupiter's Python SDK is deleted | This exists |
127
+ | Raw `httpx.post()` calls everywhere | Typed client with proper models |
128
+ | No 429 handling | Built-in retry with exponential backoff |
129
+ | Token safety is an afterthought | `TokenClient` with banned/verified checks |
130
+ | Sync-only clients | Fully async with `httpx` |
131
+
132
+ ---
133
+
134
+ ## 🔑 API Key
135
+
136
+ A Jupiter API key is optional but recommended for production use (higher rate limits).
137
+
138
+ Get one at [station.jup.ag](https://station.jup.ag/).
139
+
140
+ ```python
141
+ client = JupiterClient(api_key="your-api-key")
142
+ ```
143
+
144
+ ---
145
+
146
+ ## 📦 Also by JinUltimate1995
147
+
148
+ - [**solana-rpc-resilient**](https://github.com/JinUltimate1995/solana-rpc-resilient) — Solana RPC client with automatic failover, rate limiting, and circuit breaker
149
+ - [**dexscreener-python**](https://github.com/JinUltimate1995/dexscreener-python) — Async DexScreener API client for token/pair data across 80+ chains
150
+
151
+ ---
152
+
153
+ ## License
154
+
155
+ MIT
@@ -0,0 +1,19 @@
1
+ """
2
+ jupiter-swap-python — async Jupiter DEX aggregator client for Python.
3
+ """
4
+
5
+ from .client import JupiterClient
6
+ from .models import QuoteResponse, SwapResponse, TokenInfo, UltraOrder
7
+ from .tokens import TokenClient
8
+
9
+ __version__ = "0.1.0"
10
+
11
+ __all__ = [
12
+ "JupiterClient",
13
+ "TokenClient",
14
+ "QuoteResponse",
15
+ "SwapResponse",
16
+ "UltraOrder",
17
+ "TokenInfo",
18
+ "__version__",
19
+ ]