1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] What mistake do I have in this Python code accessing an API? [closed]

Discussão em 'Python' iniciado por Stack, Outubro 7, 2024 às 04:42.

  1. Stack

    Stack Membro Participativo

    #!/usr/bin/env python3
    import json
    import requests
    from requests import Request


    ticker_List = ['AAPL','F','T']

    my_url = "https://yfapi.net/v6/finance/quote"

    my_headers = {'x-api- key':"sLEW68I38624sh1R......kZXyVJvsZ775NKanjI"}

    my_querystring = {"symbols":ticker}

    for ticker in ticker_List:
    response = requests.Request("GET", url=my_url, headers=my_headers, params=my_querystring)

    # Create the API Data in json format
    API_Data = response.json()

    # Bypass header detail
    results = API_Data['quoteResponse']['result']


    My error message:


    NameError: name 'API_Data' is not defined

    Why is my request not working? I thought definition was API_Data = response.json().

    Continue reading...

Compartilhe esta Página