XF 2.1 REST API

Welcome to another HYS for 2.1 and this one's a biggie. If you haven't seen the previous entries about what's coming in XF 2.1, check them out here.

Although Halloween may be over, why not trick the "Watch forum" link into giving you a treat, by getting it send you an email whenever we post about new things in the pipeline.

As I write this, our most popular suggestion was a REST API and with 2.1, it's here. While this is a fairly developer-focused feature on its own, it opens up many more integration options. This will make it easier to get data into or out of XenForo, without having to understand the underlying PHP framework that XF is built on.

The API breaks down into a few distinct components, so let's look at those in turn.
 

Chris D

XenForo developer
Staff member
Am I to understand that if I wanted to have a button that lets users create an API key for their eCommerce information for use in addons like "Install & Upgrade", I could programmatically create a "user key" with new, custom scope(s) for accessing eCommerce info, and any requests using that API key would automatically be tied to that user's account?
Yep! :)
 

Chris D

XenForo developer
Staff member
Huh, that's odd don't think I've ever run into that. Do you know what configuration causes this?
I believe it's when PHP is running as CGI/FastCGI under Apache. It's the same reason we had to add the following to our default .htaccess:
Code:
#   This line may be needed to workaround HTTP Basic auth issues when using PHP as a CGI.
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
Which mostly related to WebDAV IIRC.

Instead of faffing with that kind of thing, it's just easier to use a custom header. There's no real disadvantage to this. But there are also benefits in that we now have a convention for any API related headers that we support.
 

RobParker

Well-known member
Could someone give some examples of what this would mean for possible addons?

I assume it's mainly for interfacing with other software? So for example, it might make Wordpress integration much simpler? But any native addons would already tie directly into XF and hence not use the API so it doesn't add any functionality to native addons?
 

DragonByte Tech

Well-known member
Great, now release a preview version so we can get to work!



😛


Fillip
 

Mike

XenForo developer
Staff member
Could someone give some examples of what this would mean for possible addons?

I assume it's mainly for interfacing with other software? So for example, it might make Wordpress integration much simpler? But any native addons would already tie directly into XF and hence not use the API so it doesn't add any functionality to native addons?
This really is about external integrations. If you're already writing code within the XF framework (adding pages/routes, changing what's on an existing page, etc), then it doesn't really mean much. But if you're wanting to work with data in XF (or push data to it) from any other system, then it's pretty significant.
 

RobParker

Well-known member
This really is about external integrations. If you're already writing code within the XF framework (adding pages/routes, changing what's on an existing page, etc), then it doesn't really mean much. But if you're wanting to work with data in XF (or push data to it) from any other system, then it's pretty significant.

So... WordPress?
 

Mike

XenForo developer
Staff member
It's a fair bit more generic than that, but yes, it would allow easier integration with WordPress. There were some examples in the original posts, such as creating threads whenever an article/blog entry was created (with a user that varies depending on the article author).
 

Rudy

Well-known member
Much of the technical part of this is over my head these days. ;) But anyway...
For example, you may integrate with a third-party CMS that creates a thread whenever you post a new article.
I think for many people Single Sign On between 2 xenforo installs or XF + another script would be the big one. REST API is really great to see added, but if you see any way to include Single Sign On , then that would be a game changer of the first category.
It's a fair bit more generic than that, but yes, it would allow easier integration with WordPress. There were some examples in the original posts, such as creating threads whenever an article/blog entry was created (with a user that varies depending on the article author).
Great news!! I have been wanting WordPress integration probably since XF was first released, and nobody has successfully done it yet to my satisfaction. (The couple I have tried required that XF and WP use the same domain, which is not possible in the use cases I had.) Whoever develops a good WP/XF integration add-on using the new API with the features many of us want (displaying thread replies as WP comments, posting a comment from WordPress as a thread reply in XF, new WP posts create new XF threads, XF member login on WP for commenting, etc.) is going to see me as one of the first in line to try it out. :) Whether it happens soon or a year or two in the future (when the REST API gets more robust) isn't a big deal, really, as long as it works correctly. Having this groundwork in place is a good start!
 

Kintaro

Well-known member
Hey @Chris D - how about outbound Webhooks? Allow the admin to configure external URLs which will be called as a result of certain actions taking place (eg new user registered, new thread created, etc). It's kind of the reverse of an inbound api as described in this HYS.

I've already started coding an addon to do this - but it would make sense to have it as part of the core.
Open a new suggestion thread about it!
 
Top