A free XenForo add-on that adds endpoints, filters and sorts to the XenForo REST API: list thread prefixes and user groups, find users by group, and sort threads by most replies or most views.
GET thread-prefixes/lists every thread prefix, as{"prefixes": [...]}, with its title, CSS class and label color (such asredforlabel--red)- Prefix colors: every thread prefix in an API result, including the ones in
forums/{id}, gainscolors: thecolor,background_colorandborder_colorthe forum's default style gives it GET user-groups/lists every user group with its title, display style priority, username CSS and banner CSS classGET users/gainsuser_group_idandsecondary_group_ids[]filters. A user must be in every secondary group you list.GET threads/gains two sorts for the forum-wide thread list:most_replies=1: threads active in the last 30 days by reply count, then everything else by latest activitymost_viewed=1: threads by view count
There are no options. Give an API key the scopes it needs in Setup → API keys:
apikit_thread_prefix:readforthread-prefixes/apikit_user_group:readforuser-groups/
The users filters use XenForo's own user:read scope and permissions: the member list must be enabled and visible to the key's user, unless that user can manage users in the admin panel. The thread sorts use thread:read.
API Kit reads each prefix's colors from the default style's compiled core_labels.less and extra.less, so edited label styles, dark styles and custom CSS classes come through as visitors see them. A rule counts when its selector is made only of the prefix's own classes; hover states, @media blocks and nested selectors are left out, and specificity and !important decide between rules as in a browser. Only plain color values are sent. A value such as var(--x) is left out, and a prefix with no plain colors has no colors field.
The colors are built by a background job when API Kit is installed or upgraded, and again when the default style or a prefix's CSS class changes. They're kept in the add-on's simple cache, and API requests only read them. Until the first build finishes, prefixes have no colors field.
- Endpoints:
Kolakube\APIKit\Api\Controller\ThreadPrefixesandUserGroups - Style CSS:
Kolakube\APIKit\Style\Csscompiles a style's LESS templates and reads the values that apply to an element with given classes.Kolakube\APIKit\Style\Datais the base for data built from it by theKolakube\APIKit\Job\StyleDatajob and kept in the simple cache;Kolakube\APIKit\PrefixColorsis the first. - Class extensions:
XF\Api\Controller\Users,XF\Api\ControllerPlugin\Thread,XF\Entity\ThreadPrefixandXF\Entity\UserGroup
- XenForo 2.2 or later
- PHP 7.2 or later
- Download the latest
Kolakube-APIKit-x.y.z.zipfrom the Releases page. - In your XenForo admin, go to Add-ons → Install/upgrade from archive and upload the zip.
- Add the API Kit scopes to the API keys that need them.
To work on the code, clone this repository into src/addons/Kolakube/APIKit in a XenForo development install.
MIT. See LICENSE.txt.