Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to change SWAP and QUOTE endpoints via env vars #6

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/jupiter_python_sdk/jupiter.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import base64
import json
import time
Expand Down Expand Up @@ -528,8 +529,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=",
Expand Down