def get_user_id(request):
    """
    Returns string representing unique ID for current API session user

    None is returned for anonymous/public API sessions.

    Keyword Parameters:
    request  -- Falcon HTTP request object representing current API call

    >>> from unittest.mock import Mock
    >>> fake_request = Mock()
    >>> fake_request.env = {'beaker.session': {}}
    >>> get_user_id(fake_request) #Check that no session exists
    
    """
    # obtain logged in API user ID (if available)
    try:
        api_session_user = request.env['beaker.session'].get('user_id')
    except KeyError as e:
        api_session_user = None #anonymous user session, no login ID
    # return
    return api_session_user