How to fetch details all users (name email username )

The end point is based on artur’s reply over here

i was able to count the number of users by using the following code


 $app = Cockpit::instance();
   try {

       if ($app->dataStorage->getCollection('system/users')->count()) {
            $usercount= $app->dataStorage->getCollection('system/users')->count();
            echo $usercount. "nos of users" ;
            
            if ($usercount>1){
               
                    echo "test";
                     // code for spitting out array of users?
                     
                    
               
                
            }
            exit;
    }

    } catch(Throwable $e) { }

    
    ?>

but i am unable to figure out how should i fetch details of users… kindly guide me

@Cryptospy how are you managing the api keys?

@artur can you guide me a little? been trying something similar :sweat_smile:
I tried the old v1 methods, it didnt work at all.
Thanks In advance :blush:

@Cryptospy did you find any solution?

@artur where should i start looking?

I am not sure what you mean by “manage”, provided you are asking how to fetch api keys over rest api than the answer is same approach as @artur 's original code +

return [
    'status' =>'success',
    'apiKey' => $user['apiKey'],
    'email' =>$user['email']
   

];

edit: i didnt try to fetch all details though, so i am unsure if it works or not

also i didnt find a way to fetch details of all users via curl/rest api as of yet. i would highly appreciate if someone could help me out

1 Like