import requests


def lookup(book_id):
    """Look up books based on id"""

    # Contact API
    try:
        url = f"https://www.googleapis.com/books/v1/volumes/{book_id}"
        response = requests.get(url)
        response.raise_for_status()
    except requests.RequestException:
        return None

    # Parse response
    
    # Ensure title exists
    try:
        title = response.json()["volumeInfo"]["title"]
    except:
        title = ""

    # Ensure author exists
    try:
        authors = response.json()["volumeInfo"]["authors"]
    except:
        authors=""
        
    return {
        "title": title,
        "authors": authors
        }