import requests


def relationships(name): 
    """
    Provides info from relationships get request to LittleSis API, by name input rather
    than id input as is required in original get request format, in JSON format. 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 1 individual or organization for which information is desired.
    
    Example
    -------
    >>> relationships('Steve Jobs')
    {'meta': {'currentPage': 1,
      'pageCount': 1,
      'copyright': 'LittleSis CC BY-SA 4.0',
      'license': 'https://creativecommons.org/licenses/by-sa/4.0/',
      'apiVersion': '2.0'},
     'data': [{'type': 'relationships',
       'id': 1643319,
       'attributes': {'id': 1643319,...}}}
    """
    
    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/{}/relationships'.format(ID)
    response2 = requests.get(path2)
    response2 = response2.json()
    return response2