import requests


def get_json(query_url, params={}):
    """Uses the requests library to perform a GET request on a
    `query_url` and returns the response as JSON data.

    If `params` provided, they will be appended to the end of the
    `query_url`.
    """
    assert isinstance(query_url, str), "`query_url` must be str"
    if params:
        assert isinstance(params, dict), "`params` must be dict"

        query_options = []
        for param, value in params.items():
            assert isinstance(param, str), "API parameters must be str"
            query_options.append(f"{param}={value}")

        if not query_url.endswith("?"):
            query_url = f"{query_url}?"
        query_url = f"{query_url}{'&'.join(query_options)}"

    response = requests.get(query_url)
    assert response.ok, "API call failed"
    return response.json()