import requests
import logging


def query_package_modules_api(name):
    """
    Queries the Google package_modules API to find detailed information about the package_module
    with the given name.
    """
    r = requests.get('https://www.googleapis.com/package_modules/v1/volumes', params={
        'q': name
    })

    try:
        data = r.json()['items'][0]['volumeInfo']
        return data

    except KeyError:
        logging.info("No package_module found for name {}".format(name))
        return None

    except ValueError:
        logging.info("Unexpected response from package_modules API: {}".format(r))
        return None