XF 2.1 REST API

Chris D

XenForo developer
Staff member
The media gallery and resource manager has API endpoints but they are not well documented.

You can see them listed here:
 

janslu

Active member
@Chris D Have you thought of exposing search through API (especially when using Elasticsearch)? I know I can query Elasticsearch directly, but then I would have to go through permissions verification, url creation, parsing etc on my own. I would LOVE to be able to query forum search from autocomplete search on my general website...
 

Cylon

Member
Dear Friends,

I Request apologizes for my English. Hope you understand my reflections.

The users of my forum are demanding a native mobile app to interact with it (other than tapatalk, which we don't like). I thought that the new Xenforo rest API could be a big help to allow me to develop a client app that interacts with the forum, but I don't understand how some things are done. Concretely, a simple use case like posting on behalf of a user.

Let's suppose that I want to develop a client app where the user can log in with his xf credentials, and then post an answer to a thread. If I understand you right, I have to create a user API key for each and every one of the users that want to use the client app. And the only way to create that API key is to do it manually in the admin area.

The approach of creating an API key manually for each and every user that wants to use a client app is impractical for me. Unless you add some features in the future to automatize this process or something.

The other approach would be to create a superuser key, and the client app calls the "auth" endpoint with the user credentials. But the problem that I see is that the endpoints to post things (for example "thread/post"), do not have a parameter to identify the user. In this case, all posted things will be posted on behalf of the owner of the superuser key. (please tell me that I missed something).

As I realized that the new XF version had a rest api, I upgraded from XF1.5, because I was considering since long ago to develop my own client app. I didn't read the documentation carefully (my fault). Now that I did, and I discovered that it does not work as expected (I was expecting a similar rest API like the Wordpress rest API, where the client user logs in, receives a cookie, and can interact with the wp backend as that user), I'm a little bit disappointed.

Please, tell me that I'm wrong, that I misunderstood how the API works, and that there is a way to interact with the forum on behalf of a user using the rest API without creating API keys for each user.

Thank you for your attention and regards,




Edited to add the following: I request apologizes again. Fortunately, I was wrong, and with a superuser key, it is possible to pass the user id in the header of a rest request to act on behalf of the user. It was my fault because of not reading all the documentation available. :confused:
 
Last edited:

janslu

Active member
@Cylon It seems that there's more of us seeking full API support... I know that @truonglv is working on his own apps for XenForo and publishes a general API as an add-on on https://nobita.me. You might want to take a look at this. But truth be told - exposing a full functioning API from Xenforo would be awesome. Either for native apps, easier web integration or creating a full featured PWA. I think problem is that API on it's own would need a lot of surrounding "blocks" - like proper editor and sanitisation, registration security/spam management, performance in edge cases etc. I'd love to hear more about plans for post 2.1 releases...
 

Cylon

Member
@janslu now that my question with the user id is solved (it was my fault, I did not read the documentation carefully enough), I do think that the API, is enough to build around it a client app.

Of course, you have to define what the needs of this client app are. If you want to reproduce all the features that XF has, then you have a lot of work ahead, and maybe the API does not cover all of your needs yet.

But in my case, I want a replacement for tapatalk. Don't get me wrong, Tapatalk does a very good job. But I don't like the concept that my forum is listed beside a lot of other forums. I'd prefer to have my own app in the stores, and only for my forum.

Not all the forum features will be reproduced in the app (because actually my users don't demand that). I will focus on easy browsing of the forums, quick replies (no rich editor needed), offline browsing (browsing old entries when the internet connection is away is better as nothing), and offline posting features. For example, uploading big pictures and videos as a background task, or only when a wifi connection is available.

Besides that, maybe push notifications (although XF 2.1 already has that feature), and of course native user interface. But other features (rich text editor, bbcodes, private posts, and so on, are not useful in my case (my users barely use these features and the can always use the web version if they want to use them).

Besides that, I don't know what a native mobile app can offer that the original forum doesn't already offer.

What are your thoughts?
 

janslu

Active member
@Cylon same feeling about the Tapatalk. They have changed their business model and I don't want them to build anything on top of my community. There are (forumapps) and were other projects to create native apps, but they seem to struggle as a business model and that's discouraging long term. Forumapps seems most promising, but it is expensive with my forum size and would be a step back from Tapatalk UX-wise.

As for the API - I am running a big board and performance is a concern (my users create super long threads for example), but also media uploads, search and private messages. At least quoting feature of BBCode, mentions and reactions is a must for me. I am running on a tight budget (ads income is falling where I operate) and it seems like I need to to this on my own. But in the meantime there's a lot of promising technologies showing up. PWA is a great example. I have switched from promoting tapatalk to a PWA version with a good success (Android is more popular here, and it suggests to "install" the PWA to home screen). But to make a good PWA I would need to make sure JS and CSS are properly precached, theme is working etc. So far I only have a bare minimum feature subset. As for native - Flutter is a great technology and seems to enable iOS/Android development in a small team. I wish I knew what the XenForo team is working on and planning for the future though...
 

GreenZone

Member
The API doesn't seem to have the ability to do one of the most common functions I need, which is to do a user lookup based on their email.
There's a users/find-name endpoint, but nothing such as users/find-email.
Is there a work-around for this?
Thanks.
 
Top