jupiter-python-sdk icon indicating copy to clipboard operation
jupiter-python-sdk copied to clipboard

`get_token_price` Fails with DNS Error Due to Hardcoded Unresolvable Host (`price.jup.ag`)

Open afurgal opened this issue 7 months ago • 0 comments

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:

  1. Other SDK functions requiring network access (.quote(), .swap()) which use the configurable quote_api_url (defaulting to https://quote-api.jup.ag/v6/...) work correctly, indicating that quote-api.jup.ag is resolvable.
  2. Direct curl requests from the same machine to price.jup.ag fail with curl: (6) Could not resolve host: price.jup.ag, confirming that this specific hardcoded hostname is unresolvable from the user's environment.
  3. Other potential Jupiter price endpoints like https://lite-api.jup.ag/price/v2 are resolvable via curl from 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!

afurgal avatar Apr 20 '25 16:04 afurgal