Pull number of users and number of topics in category through API


(Krzysztof Madejski) #1

Hi,

I was browsing routes.rb, but still cannot get my two use cases two work, which is getting two following numbers in one call:

  1. Pull number of users registered
    /admin/users.json has limit=100 which I cannot override in query;
    /users/search/users.json returns just 20
  2. Pull number of topics in category
    /category/<category>.json returns just 30

Hints how to get it will be appreciated! :slight_smile:


(Kane York) #2

For the number of users registered, have you tried Discourse Meta ?


(Mittineague) #3

I am also looking for a way to get JSON results past the query limits.

eg. offset-limit ??

… suspended.json?start=100&limit=100

Is there anything like that in place that I don’t know about?


(etewiah) #4

Yeah, that would be pretty useful. Whats your use case by the way?


(Mittineague) #5

I guess “suspended” doesn’t exactly jump out :wink:

Most outer facing pages have AJAXy scroll-to-see-more magic happening, but I haven’t found a way to get at the Admin pages. Very frustrating to know the information is there but not being able to get it.

Not that I’m proposing any “let’s bring the server to it’s knees” type of thing, but a way to “paginate” JSON results within reason would be great.


Scroll through full user list?
(Kane York) #6

BTW, the best way to do this is &after=sort_key, where sort_key is something that the SQL can include as WHERE .... AND key > :after.


(Mittineague) #7

I just tried

... /admin/users/list/new.json?posts_read_count=10

But the returned JSON included accounts with both lower and higher p_r_c values.

Wrong syntax?


(Krzysztof Madejski) #8

I want to show these metrics on my main website to show how forum is growing. Big numbers: we have that many users! we have that many ideas (posted in “ideas” category)

It’s not overwhelming for server, just SELECT COUNT(*) with simple where. If it does not exist I will add it and pull request it (does anybody have an idea what best endpoint it would be?)

@riking If I would need to parse html I prefer to fork it and add my own endpoints.


(Kane York) #9

No, that parameter isn’t supported yet, I was talking about how to do it if someone was going to add it.