src/unifi_api/api.py
def list_sessions(self, client_mac=None, client_type='all', start=None, end=None, site='default'):
        '''
            Get all login sessions
            -------------------------
            returns an array of login sessions for all clients on a site, or a single client
            params:
                Name        | required  | description
                -----------------------------------------
                client_type |   False   | type of client, can be: ['all', 'guest', 'user']
                client_mac  |   False   | client mac to get sessions, if not provided, all sessions will be returned
                start       |   False   | Unix timestamp in seconds or datetime, defaults to end - 7d
                end         |   False   | Unix timestamp in seconds or datetime, defaults to now
                site        |   False   | site name to get sessions, defaults to `default`
        '''
        end = end*1000 if isinstance(end, int) else int(datetime.now().timestamp()*1000) if end is None else int(end.timestamp()*1000)
        start = start*1000 if isinstance(start, int) else end - 7*24*60*60*1000 if start is None else int(start.timestamp()*1000)
        assert 0 < start < end, 'start must be before end (and both positive)'

        data = {
            'type': client_type,
            'start': start,
            'end': end,
        }
        if client_mac is not None:
            data['mac'] = client_mac

        r = self.get(self.endpoint('/api/s/%s/stat/session' % site), json=data)
        return self.process_response(r)

            Get all login sessions
            -------------------------
            returns an array of login sessions for all clients on a site, or a single client
            params:
                Name        | required  | description
                -----------------------------------------
                client_type |   False   | type of client, can be: ['all', 'guest', 'user']
                client_mac  |   False   | client mac to get sessions, if not provided, all sessions will be returned
                start       |   False   | Unix timestamp in seconds or datetime, defaults to end - 7d
                end         |   False   | Unix timestamp in seconds or datetime, defaults to now
                site        |   False   | site name to get sessions, defaults to `default`
        
Get all login sessions
returns an array of login sessions for all clients on a site, or a single client
params:
Name        | required  | description


Get all login sessions returns an array of login sessions for all clients on a site or a single client params : Name | required | description
def list_sessions(self, client_mac=None, client_type='all', start=None, end=None, site='default'):
        end = end*1000 if isinstance(end, int) else int(datetime.now().timestamp()*1000) if end is None else int(end.timestamp()*1000)
        start = start*1000 if isinstance(start, int) else end - 7*24*60*60*1000 if start is None else int(start.timestamp()*1000)
        assert 0 < start < end, 'start must be before end (and both positive)'
        data = {
            'type': client_type,
            'start': start,
            'end': end,
        }
        if client_mac is not None:
            data['mac'] = client_mac
        r = self.get(self.endpoint('/api/s/%s/stat/session' % site), json=data)
        return self.process_response(r)
def list_sessions ( self , client_mac = None , client_type = 'all' , start = None , end = None , site = 'default' ) : end = end * 1000 if isinstance ( end , int ) else int ( datetime . now ( ) . timestamp ( ) * 1000 ) if end is None else int ( end . timestamp ( ) * 1000 ) start = start * 1000 if isinstance ( start , int ) else end - 7 * 24 * 60 * 60 * 1000 if start is None else int ( start . timestamp ( ) * 1000 ) assert 0 < start < end , 'start must be before end (and both positive)' data = { 'type' : client_type , 'start' : start , 'end' : end , } if client_mac is not None : data [ 'mac' ] = client_mac r = self . get ( self . endpoint ( '/api/s/%s/stat/session' % site ) , json = data ) return self . process_response ( r )
Get all login sessions
returns an array of login sessions for all clients on a site, or a single client
params:
Name        | required  | description
Get all login sessions returns an array of login sessions for all clients on a site or a single client params : Name | required | description
'''
            Get all login sessions
            -------------------------
            returns an array of login sessions for all clients on a site, or a single client
            params:
                Name        | required  | description
                -----------------------------------------
                client_type |   False   | type of client, can be: ['all', 'guest', 'user']
                client_mac  |   False   | client mac to get sessions, if not provided, all sessions will be returned
                start       |   False   | Unix timestamp in seconds or datetime, defaults to end - 7d
                end         |   False   | Unix timestamp in seconds or datetime, defaults to now
                site        |   False   | site name to get sessions, defaults to `default`
        '''
self
client_mac
client_type
start
end
site