Skip to content

Commit 373a33a

Browse files
committed
Project renaming for clarity
1 parent dc55d4d commit 373a33a

File tree

7 files changed

+117
-17
lines changed

7 files changed

+117
-17
lines changed

README-dev.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ If you want to make changes to the SDK and test it locally:
88

99
2. To use this library in another project while making changes to it, install the package from its local path in that project:
1010
```sh
11-
pip install -e /path/to/jup-ag-sdk
11+
pip install -e /path/to/jup-python-sdk
1212
```
1313

14-
Replace `/path/to/jup-ag-sdk` with the absolute or relative path to this project directory.
14+
Replace `/path/to/jup-python-sdk` with the absolute or relative path to this project directory.
1515

1616
By installing in editable mode, any changes you make to the SDK will immediately reflect in your tests without needing to reinstall the package.

README-release.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ To create and publish a new release of the package to PyPI:
2727
- Publish the package to PyPI.
2828

2929
5. **Confirm the Release:**
30-
- Check [PyPI](https://pypi.org/project/jup-ag-sdk/) to ensure the new version has been published successfully.
30+
- Check [PyPI](https://pypi.org/project/jup-python-sdk/) to ensure the new version has been published successfully.

README.md

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,16 @@ A Python SDK for interacting with Jupiter Exchange APIs.
77
To install the SDK in your project, run:
88
```
99
sh
10-
pip install jup-ag-sdk
10+
pip install jup-python-sdk
1111
```
1212
## **Quick Start**
1313

14-
Here's a basic example to help you get started with the Jup Python SDK:
14+
Below is a simple example that shows how to fetch and execute an Ultra order with the Jup Python SDK:
1515
```
1616
python
1717
from dotenv import load_dotenv
18-
1918
from jup_python_sdk.clients.ultra_api_client import UltraApiClient
20-
from jup_python_sdk.models.ultra_api.ultra_order_request_model import (
21-
UltraOrderRequest,
22-
)
19+
from jup_python_sdk.models.ultra_api.ultra_order_request_model import UltraOrderRequest
2320
2421
load_dotenv()
2522
client = UltraApiClient()
@@ -34,17 +31,25 @@ order_request = UltraOrderRequest(
3431
try:
3532
client_response = client.order_and_execute(order_request)
3633
signature = str(client_response["signature"])
37-
34+
3835
print("Order and Execute API Response:")
36+
print(f" - Status: {client_response.get('status')}")
37+
if client_response.get("status") == "Failed":
38+
print(f" - Code: {client_response.get('code')}")
39+
print(f" - Error: {client_response.get('error')}")
40+
3941
print(f" - Transaction Signature: {signature}")
4042
print(f" - View on Solscan: https://solscan.io/tx/{signature}")
4143
4244
except Exception as e:
43-
print("Error occurred while processing the order:", str(e))
45+
print("Error occurred while processing the swap:", str(e))
4446
finally:
4547
client.close()
4648
```
4749

50+
You can find additional code examples and advanced usage scenarios in the [examples](./examples) folder.
51+
These examples cover every Ultra API endpoint and should help you get up and running quickly.
52+
4853
## **Setup Instructions**
4954

5055
Before using the SDK, please ensure you have completed the following steps:
@@ -56,11 +61,27 @@ Before using the SDK, please ensure you have completed the following steps:
5661
export PRIVATE_KEY=your_private_key_here
5762
```
5863

59-
2. **Python Version**:
60-
Make sure you are using Python 3.9 or later.
64+
2. **Configuration**:
65+
Depending on your credentials and setup, you have a couple of options for initializing the `UltraApiClient`:
66+
67+
- **Custom Private Key Environment Variable:**
68+
By default, the SDK looks for your private key in an environment variable named `PRIVATE_KEY`.
69+
If you use a different environment variable name, you can specify it explicitly:
70+
```python
71+
from jup_python_sdk.clients.ultra_api_client import UltraApiClient
72+
73+
client = UltraApiClient(private_key_env_var="YOUR_CUSTOM_ENV_VAR")
74+
```
75+
This tells the SDK to read your private key from the environment variable you want.
76+
77+
- **Using an API Key for Enhanced Access:**
78+
If you have an API key from [the Jupiter Portal](https://portal.jup.ag/onboard), you can pass it directly when creating the client:
79+
```python
80+
from jup_python_sdk.clients.ultra_api_client import UltraApiClient
6181

62-
3**Configuration**:
63-
TBD
82+
client = UltraApiClient(api_key="YOUR_API_KEY")
83+
```
84+
When you supply an API key, the library will call the `https://api.jup.ag/` API rather than the default `https://lite-api.jup.ag/` API.
6485

6586
## **Disclaimer**
6687

examples/balances/main.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from dotenv import load_dotenv
2+
from jup_python_sdk.clients.ultra_api_client import UltraApiClient
3+
4+
load_dotenv()
5+
client = UltraApiClient()
6+
7+
address = client._get_public_key()
8+
9+
try:
10+
balances_response = client.balances(str(address))
11+
12+
print("Balances API Response:")
13+
for token, details in balances_response.items():
14+
print(f"Token: {token}")
15+
print(f" - Amount: {details['amount']}")
16+
print(f" UI Amount: {details['uiAmount']}")
17+
print(f" Slot: {details['slot']}")
18+
print(f" Is Frozen: {details['isFrozen']}")
19+
20+
except Exception as e:
21+
print("Error occurred while fetching balances:", str(e))
22+
finally:
23+
client.close()

examples/order-and-execute/main.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from dotenv import load_dotenv
2+
from jup_python_sdk.clients.ultra_api_client import UltraApiClient
3+
from jup_python_sdk.models.ultra_api.ultra_order_request_model import UltraOrderRequest
4+
5+
load_dotenv()
6+
client = UltraApiClient()
7+
8+
order_request = UltraOrderRequest(
9+
input_mint="So11111111111111111111111111111111111111112", # WSOL
10+
output_mint="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", # USDC
11+
amount=10000000, # 0.01 WSOL
12+
taker=client._get_public_key()
13+
)
14+
15+
try:
16+
client_response = client.order_and_execute(order_request)
17+
signature = str(client_response["signature"])
18+
19+
print("Order and Execute API Response:")
20+
print(f" - Status: {client_response.get('status')}")
21+
if client_response.get("status") == "Failed":
22+
print(f" - Code: {client_response.get('code')}")
23+
print(f" - Error: {client_response.get('error')}")
24+
25+
print(f" - Transaction Signature: {signature}")
26+
print(f" - View on Solscan: https://solscan.io/tx/{signature}")
27+
28+
except Exception as e:
29+
print("Error occurred while processing the swap:", str(e))
30+
finally:
31+
client.close()

examples/shield/main.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from jup_python_sdk.clients.ultra_api_client import UltraApiClient
2+
3+
client = UltraApiClient()
4+
5+
# WSOL and USDC mints
6+
wsol_mint = "So11111111111111111111111111111111111111112"
7+
usdc_mint = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
8+
9+
try:
10+
shield_response = client.shield(mints=[wsol_mint, usdc_mint])
11+
12+
print("Shield API Response:")
13+
if shield_response["warnings"]:
14+
for mint, warnings in shield_response["warnings"].items():
15+
print(f"Mint: {mint}")
16+
for warning in warnings:
17+
print(f" - Type: {warning.get('type')}")
18+
print(f" Message: {warning.get('message')}")
19+
else:
20+
print("No warnings returned for provided mints")
21+
22+
except Exception as e:
23+
print("Error occurred while fetching shield information:", str(e))
24+
finally:
25+
client.close()

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ description = "Python SDK for Jupiter Exchange APIs."
55
authors = ["Fiji <[email protected]>"]
66
license = "MIT"
77
readme = "README.md"
8-
homepage = "https://github.com/cmoutafidis/jup-ag-sdk"
9-
repository = "https://github.com/cmoutafidis/jup-ag-sdk"
8+
homepage = "https://github.com/cmoutafidis/jup-python-sdk"
9+
repository = "https://github.com/cmoutafidis/jup-python-sdk"
1010
keywords = ["solana", "jupiter", "sdk"]
1111
packages = [{include = "jup_python_sdk"}]
1212
classifiers = [

0 commit comments

Comments
 (0)