import requests


def bio(name): 
    """
    Provides paragraph biography/background description of 1 individual or entity from an entity get request on LittleSis API. Resorts to
    entity with the highest number of relationships listed for entries that point to multiple entites (like last name only entries). 
    
    Parameters
    ----------
    name: Name of one individual or organization for which biographical information is desired. 
    
    Example
    -------
    >>> bio('Barack Obama')
    'The 44th President of the United States, he was sworn into office on January 20,
    2009; born in Honolulu, Hawaii, August 4, 1961; obtained early education in Jakarta,
    Indonesia, and Hawaii; continued education at Occidental College, Los Angeles, Calif.;
    received a B.A. in 1983 from Columbia University, New York City; worked as a community 
    organizer in Chicago, Ill.; studied law at Harvard University, where he became the 
    first African American president of the Harvard Law Review, and received J.D. in 1991;
    lecturer on constitutional law, University of Chicago; member, Illinois State senate
    1997-2004; elected as a Democrat to the U.S. Senate in 2004 for term beginning January
    3, 2005.'
    """
    
    path = 'https://littlesis.org/api/entities/search?q={}'.format(name)
    response = requests.get(path)
    response = response.json()
    ID = response['data'][0]['id']
    path2 = 'https://littlesis.org/api/entities/{}'.format(ID)
    response2 = requests.get(path2)
    response2 = response2.json()
    response2 = response2['data']['attributes']['summary']
    return response2