import requests


def api_request(url, api_key=None):
    """
        This function takes a url and returns the parsed json object. If necessary, it submits the auth header
    """
    if api_key:
        return requests.get(url, headers={'Authorization': 'Token ' + api_key}).json()
    else:
        return requests.get(url).json()