-1

I'm kind of stuck on how to pass a query string to the function below. I've tried including in payload as a key-value pair and attaching it to the final version of the URL:

def send_public_request(url_path, payload={}):
    query_string = urlencode(payload, True)
    url = BASE_URL + url_path
    if query_string:
        url = url + "?" + query_string
    response = dispatch_request("GET")(url=url)
    return response.json()

1 Answers1

0
response = send_public_request('/fapi/v1/klines' , {"symbol": "BTCUSDT", "interval": "1d"})

To explain:

response = send_public_request(API_ENDPOINT , PARAMS_FOR_ENDPOINT)
Synthase
  • 5,849
  • 2
  • 12
  • 34