@baris can users do this now? it would be great to turn of node bb community into something like sub reddits where people can make their own sub forums for discussiosn
It is not possible for users to make categories now.
I'm trying to write a Python API wrapper over the NodeBB REST API but I'm a little confused by the interface. I understand that you can add
/api to most if not all urls and be able to get json response.
However, I'd prefer to reference a resource by their
id rather than the associated username, topic name, category name etc.
# My username vs my uid. "https://community.nodebb.org/api/user/truetuna" "https://community.nodebb.org/api/user/6166"
I ask because it seems like there's quite a split between the read-api and the write-api provided by the
nodebb-plugin-write-api plugin. For example, if I wanted to
PUT to a user, I have to reference the resource via the
uid, but when I want to
GET a user, I need to use their
It's not too bad when it's the user resource but it gets pretty weird when it comes to say, topics. With topics, I need the
tid AND the topic
title. In addition, the topic title needs to be formatted in a specific way (removing commas, lowercase, replacing spaces with hyphens etc.).
# The original title was "Deleted topics, comments" "https://community.nodebb.org/api/topic/6438/deleted-topics-comments" "https://community.nodebb.org/api/topic/6438/"
It's very confusing and it makes it quite difficult to use the API.
Am I missing something? Is it possible to reference resources just by their id? Is there a switch I need to turn on in the ACP for this to work? Is there a piece of documentation I'm missing?
Because ideally, I'd prefer to only have to use the id as the resource reference, e.g.
PUT, DELETE "https://community.nodebb.org/api/topic/6438/" PUT, DELETE "https://community.nodebb.org/api/user/6438/" PUT, DELETE "https://community.nodebb.org/api/category/6438/" ...
PS. I'm using NodeBB v0.7.3
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?
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.
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:
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 get
401 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?
Yeah make it on our github and link back here.
There is a private user info setting in the ACP, if its on you can't retrieve user data.
Done and thanks!
@truetuna Public routes are always accessible via corresponding
/api route. Protected routes (like /user/julian/settings) you can access if you send in the user/master token like a write-api route.
This is on master now.
The routes are
Thanks @baris. Is it possible for this to also go into the
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.
@truetuna feel free to send a PR, I recently changed it to https://github.com/NodeBB/NodeBB/commit/f3b6a5fbb92db6b1ada3d6ee086473cc11dd1b07#diff-4913b70c5883cd908f702f7e02f1397e so copy that.
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.
Hey @baris, I made a PR yesterday.