import requests
import time


def general_data_request(endpoint, **kwargs):
    """
    Send a data request to the given API endpoint.
    :param endpoint: The endpoint for which to send the get request
    :param kwargs: The data to be passed to the requests.get() method.
    :return: the data retrieved from the remote endpoint.
    """
    request = requests.get(endpoint, **kwargs)
    if request.status_code == 200:
        return request.json()
    if request.status_code == 429:
        print("Too many requests. Delaying execution.")
        time.sleep(1)
        return general_data_request(endpoint, **kwargs)
    else:
        print(kwargs)
        print(request.status_code)
        raise ValueError