How do I get a list of all users from the API?

api

(dirkcuys) #1

I see that I can get a list of users using the API using http://discourse.example.net/admin/users.json, but I get only 100 users and I don’t know how the paging for that works? The interface doesn’t seem to display more than 100 users if you go to the admin part.


(Mittineague) #2

There is no paging.
There is no scrolling.
Currently the only way to get more is to use “Export” :sadpanda:


(dirkcuys) #3

sad panda indeed :frowning: The exported list doesn’t include the same data, and the way it happens makes it hard to grab programatically.

Any idea if paging for users is wanted by anyone else and if it is something that may be implemented at some stage?


(cpradio) #4

Yes :smile:

No idea.


(Michael Downey) #5

Any thought if this will be fixed/expanded? We really need API access to access our user lists. Limiting at 100 just doesn’t make sense.


(David Neuhaus) #6

Has this been addressed? This would be really useful to my user import script


(Felix Freiberger) #7

I’d also love to see this, to use in scripts that process the whole user base in some way, like this:


(Dean Taylor) #8

Whilst not immediately obvious…

It is possible to get a list of all users via the groups API endpoint available to admins.

You’ll have to iterate over the following groups:

  • trust_level_0
  • trust_level_1
  • trust_level_2
  • trust_level_3
  • trust_level_4

But they do support both limit and offset parameters:

/groups/trust_level_0/members.json?limit=50&offset=50

Using the api for user management (the 100 user limit)
Find user through API by user field?
(David Neuhaus) #9

This is a great workaround, but begs the question: Is there a reason these parameters are not supported on /users.json ?


(Dean Taylor) #10

It was recently noted that you only need to iterate trust_level_0:


(Jack Zampolin) #11

So this API doesn’t give emails too. This means that I would have to get the whole list then interate through and pull each user individually to get all the appropriate info (admin, moderator, etc…) Is that correct


(Blake Erickson) #12

Yes I believe that is correct. I don’t think paging has been added yet to /admin/users.json.