@@ -7,19 +7,16 @@ A Python SDK for interacting with Jupiter Exchange APIs.
77To install the SDK in your project, run:
88```
99sh
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```
1616python
1717from dotenv import load_dotenv
18-
1918from 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
2421load_dotenv()
2522client = UltraApiClient()
@@ -34,17 +31,25 @@ order_request = UltraOrderRequest(
3431try:
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
4244except Exception as e:
43- print("Error occurred while processing the order :", str(e))
45+ print("Error occurred while processing the swap :", str(e))
4446finally:
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
5055Before 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
0 commit comments