jupiter-python-sdk
jupiter-python-sdk copied to clipboard
`get_token_price` Fails with DNS Error Due to Hardcoded Unresolvable Host (`price.jup.ag`)
Bug Report: get_token_price Fails with DNS Error Due to Hardcoded Unresolvable Host (price.jup.ag)
SDK Version: [Please specify your jupiter-python-sdk version here]
Problem Description:
When calling the await Jupiter.get_token_price(token_address) function, it consistently fails with a network error like [Errno 8] nodename nor servname provided, or not known.
Inspection of the SDK source code (jupiter.py, around line 1126) reveals that get_token_price hardcodes the API endpoint URL as https://price.jup.ag/v4/price?...:
# From jupiter.py
token_prices_url = "https://price.jup.ag/v4/price?ids=" + input_mint
# ...
token_prices = httpx.get(token_prices_url, timeout=Timeout(timeout=30.0)).json()['data']
This occurs even though:
- Other SDK functions requiring network access (
.quote(),.swap()) which use the configurablequote_api_url(defaulting tohttps://quote-api.jup.ag/v6/...) work correctly, indicating thatquote-api.jup.agis resolvable. - Direct
curlrequests from the same machine toprice.jup.agfail withcurl: (6) Could not resolve host: price.jup.ag, confirming that this specific hardcoded hostname is unresolvable from the user's environment. - Other potential Jupiter price endpoints like
https://lite-api.jup.ag/price/v2are resolvable viacurlfrom the same machine.
Evidence (curl tests):
# Failing curl command for the hardcoded host used by get_token_price
$ curl "https://price.jup.ag/v4/price?ids=So11111111111111111111111111111111111111112"
curl: (6) Could not resolve host: price.jup.ag
# Successful curl command for an alternative, working Jupiter Price API host
$ curl "https://lite-api.jup.ag/price/v2?ids=So11111111111111111111111111111111111111112"
{"data":{"So11111111111111111111111111111111111111112":{"id":"So11...112", "type":"derivedPrice","price":"136.588014000"}},"timeTaken":0.006}
Suggestion:
Consider updating the get_token_price function to use a known working and potentially more reliable endpoint like lite-api.jup.ag, or ideally, make the Price API endpoint configurable during Jupiter client initialization (similar to quote_api_url and swap_api_url) to allow users to adapt if the default endpoint has resolution issues.
Thank you for looking into this!