Depth of knowledge [API docs link]

scenario 1: i gave cursor a link to a simple get request example and it couldn’t even reproduce the code, i presume it hallucinated

scenario 1 code:

import requests

def get_token_data(token_address):
    url = f"https://api.dexscreener.com/latest/dex/tokens/{token_address}"
    response = requests.get(url)
    return response.json()

token_address = input("Enter token address: ")
data = get_token_data(token_address)
print(data)

scenario 2: i screenshotted the example and showed it to gpt4 vision and correctly reproduced it.


scenario 2 code:

import requests

BASE_URL = "https://api.dexscreener.com/latest/dex/tokens"

def get_token_data(addresses):
    # Construct the full URL
    url = f"{BASE_URL}/{addresses}"
    
    # Make the request
    response = requests.get(url)
    
    # Check if the request was successful
    if response.status_code == 200:
        return response.json()
    else:
        return f"Error: {response.status_code}"

if __name__ == "__main__":
    # Example usage
    addresses = input("Enter the token addresses (comma-separated, up to 30): ")
    data = get_token_data(addresses)
    print(data)

what am i missing? thank you

What’s wrong with the Scenario 1 code?

ran the scenario 1 code and it worked now. don’t know exactly what made it function now. maybe because i ran the s2 code. anyway thank you!