How can I read a resource only by their id (cid, uid, tid etc.) rather than the name or name+id?
-
Yeah, that's a bit strange. Maybe they did it so a username or a topic title could also be just a number?
Nah probably not, there should be someway to do it using the id.
-
Can you make an issue on our tracker about this?
User data is accesible at https://community.nodebb.org/api/user/uid/6166 but there is no way to get others because https://community.nodebb.org/api/topic/6438/ redirects to the topic with the slug.
The reason for that was images in topics causing topics to be loaded, you can probably find the relevant issue on our tracker as well.
-
Awesome the
/uid/:id
works.Yeah I noticed that. For now, I can simply just make a 2nd request for topics, categories etc. after getting the redirect path. It would be good to have a similar url style for topics, categories as well in the future. Perhaps something like:
"https://community.nodebb.org/api/topic/tid/6438/" "https://community.nodebb.org/api/category/cid/6438/"
Anyway, I'll create an issue (on Github?) and reference back to this topic.
On a somewhat similar topic, how does authentication work with
/api
routes that aren't exposed by the write-api? When I try to make a request to say http://localhost:4567/api/user/uid/:id, I get401 not-authorised
but when I do the same thing on https://community.nodebb.org it goes through without raising an authentication error. Is there something I have to enable in my NodeBB instance's ACP? -
Hey @baris, what's the status on this? I don't mind doing it and just making a PR to branch
0.7.x
. It's just going to a carbon copy of the changes in your commit here: https://github.com/NodeBB/NodeBB/commit/c139dfa843b87bdb246a2804946e8e5502a4719e -
@truetuna If you need only users, you could use this plugin: https://github.com/NicolasSiver/nodebb-plugin-ns-api
I have made it to expose users with user id, also I have cleared user object, so it will be more suffice for external API/integrations.
-
Thanks Nicholas, but according to the comments above, there already exists an endpoint to get users
/api/user/uid/:uid
so I don't need to install any additional plugins (phew!). I'm in the process of writing a Python wrapper so although I only need users right now, I'm going to eventually need support for others.@baris, will do! I'll see if I can get it done tomorrow.