import requests


def post_query(query, page_number):
    """ Posts a query to the xeno-canto API.

    Arguments:
        query (str): Xeno canto search query.
        page_number (int): Which page to download.

    Returns:
        response_json (dict): A dictionary containing all metadata of a recording.
    """
    xeno_query_url = 'http://www.xeno-canto.org/api/2/recordings'
    params_dict = {'query': query, 'page': page_number}

    response = requests.get(url=xeno_query_url,
                            params=params_dict)

    valid_response = response.status_code == 200

    if valid_response:
        response_json = response.json()
        return response_json

    else:
        response.raise_for_status()