From 09c1e9b8acb31df1df3721a1869ab222ee2ddbbc Mon Sep 17 00:00:00 2001 From: Auston Bunsen Date: Tue, 30 Jan 2024 13:09:08 -0500 Subject: [PATCH 1/3] Add ability to change SWAP and QUOTE endpoints via env vars --- README.md | 10 ++++++++++ src/jupiter_python_sdk/jupiter.py | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 713c0e8..e408ff4 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,16 @@ If you encounter ```ImportError: cannot import name 'sync_native' from 'spl.toke 1. Go to https://github.com/michaelhly/solana-py/tree/master/src/spl/token and download ```instructions.py``` 2. In your packages folder, replace ```spl/token/instructions.py``` with the one you just downloaded. +### Using custom URLs + +You can set custom URLs via environment variables for any self-hosted Jupiter APIs. Like the [V6 Swap API](https://station.jup.ag/docs/apis/self-hosted) or [QuickNode's Metis API](https://marketplace.quicknode.com/add-on/metis-jupiter-v6-swap-api. Here are the ENV vars: + +``` +QUOTE_API_URL=https://jupiter-swaps.quiknode.pro/D3ADB33F/quote? +SWAP_API_URL=https://jupiter-swaps.quiknode.pro/D3ADB33F/swap +``` + + ### Here is a code snippet on how to use the SDK ```py import base58 diff --git a/src/jupiter_python_sdk/jupiter.py b/src/jupiter_python_sdk/jupiter.py index 56e8600..e992acb 100644 --- a/src/jupiter_python_sdk/jupiter.py +++ b/src/jupiter_python_sdk/jupiter.py @@ -528,8 +528,8 @@ async def get_available_dca_tokens( class Jupiter(): ENDPOINT_APIS_URL = { - "QUOTE": "https://quote-api.jup.ag/v6/quote?", - "SWAP": "https://quote-api.jup.ag/v6/swap", + "QUOTE": os.getenv("QUOTE_API_URL") || "https://quote-api.jup.ag/v6/quote?", + "SWAP": os.getenv("SWAP_API_URL") || "https://quote-api.jup.ag/v6/swap", "OPEN_ORDER": "https://jup.ag/api/limit/v1/createOrder", "CANCEL_ORDERS": "https://jup.ag/api/limit/v1/cancelOrders", "QUERY_OPEN_ORDERS": "https://jup.ag/api/limit/v1/openOrders?wallet=", From 498a9c0a6922d6db08546da5a4165e706daef81e Mon Sep 17 00:00:00 2001 From: Auston Bunsen Date: Thu, 1 Feb 2024 07:48:28 -0500 Subject: [PATCH 2/3] Forgot to import os --- src/jupiter_python_sdk/jupiter.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/jupiter_python_sdk/jupiter.py b/src/jupiter_python_sdk/jupiter.py index e992acb..4a78d37 100644 --- a/src/jupiter_python_sdk/jupiter.py +++ b/src/jupiter_python_sdk/jupiter.py @@ -1,3 +1,4 @@ +import os import base64 import json import time From 398121192b3fff7fa8a0cc10750cd8573460209d Mon Sep 17 00:00:00 2001 From: Auston Bunsen Date: Thu, 1 Feb 2024 12:27:09 -0500 Subject: [PATCH 3/3] Update README.md Missing ) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e408ff4..27b9bd7 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ If you encounter ```ImportError: cannot import name 'sync_native' from 'spl.toke ### Using custom URLs -You can set custom URLs via environment variables for any self-hosted Jupiter APIs. Like the [V6 Swap API](https://station.jup.ag/docs/apis/self-hosted) or [QuickNode's Metis API](https://marketplace.quicknode.com/add-on/metis-jupiter-v6-swap-api. Here are the ENV vars: +You can set custom URLs via environment variables for any self-hosted Jupiter APIs. Like the [V6 Swap API](https://station.jup.ag/docs/apis/self-hosted) or [QuickNode's Metis API](https://marketplace.quicknode.com/add-on/metis-jupiter-v6-swap-api). Here are the ENV vars: ``` QUOTE_API_URL=https://jupiter-swaps.quiknode.pro/D3ADB33F/quote?