# How to fetch details all users (name email username )

**URL:** <https://discourse.getcockpit.com/t/how-to-fetch-details-all-users-name-email-username/2563>\
**Category:** Support\
**Created:** [November 17, 2022, 12:33pm UTC](https://discourse.getcockpit.com/t/how-to-fetch-details-all-users-name-email-username/2563 "2022-11-17T12:33:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cryptospy](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/cryptospy/32/1169_2.png) [@Cryptospy](https://discourse.getcockpit.com/u/Cryptospy)\
**Post date:** [November 17, 2022, 12:33pm UTC](https://discourse.getcockpit.com/t/how-to-fetch-details-all-users-name-email-username/2563/1 "2022-11-17T12:33:45Z")

</div>

The end point is based on artur’s reply [over here](https://discourse.getcockpit.com/t/authenticate-api-with-username-and-password/2472/4)

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

```auto

 $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

---

<div class="post-metadata">

**Author:** ![HelloDolly](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/hellodolly/32/1181_2.png) [@HelloDolly](https://discourse.getcockpit.com/u/HelloDolly)\
**Post date:** [November 19, 2022, 4:44pm UTC](https://discourse.getcockpit.com/t/how-to-fetch-details-all-users-name-email-username/2563/2 "2022-11-19T16:44:47Z")

</div>

@Cryptospy how are you managing the api keys?

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

---

<div class="post-metadata">

**Author:** ![HelloDolly](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/hellodolly/32/1181_2.png) [@HelloDolly](https://discourse.getcockpit.com/u/HelloDolly)\
**Post date:** [November 23, 2022, 3:59pm UTC](https://discourse.getcockpit.com/t/how-to-fetch-details-all-users-name-email-username/2563/3 "2022-11-23T15:59:14Z")

</div>

@Cryptospy did you find any solution?

@artur where should i start looking?

---

<div class="post-metadata">

**Author:** ![Cryptospy](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/cryptospy/32/1169_2.png) [@Cryptospy](https://discourse.getcockpit.com/u/Cryptospy)\
**Post date:** [December 3, 2022, 5:46am UTC](https://discourse.getcockpit.com/t/how-to-fetch-details-all-users-name-email-username/2563/4 "2022-12-03T05:46:16Z")

</div>

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 +

```auto
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
