[The Hub] REST API for Hub


Consider a web service API for the Hub to view activity and control sites without going to the WPMU DEV website.

This was prompted by another request by @mohammadqureshi for a mobile app for the Hub.


While I disagree with that dedicated effort, I am making this alternative proposal that I believe might satisfy the same ultimate desire.

If Dev publishes end-points for WP API calls for non-UI functionality, then we in the field can create our own mobile functionality via web services and common consumer tools.

I actually do not feel strongly about this. No new development requested unless it's minimal. I still prefer limited resources to be dedicated to other more important requests here. But this feature could have marketing value. It might also be accomplished with much less coding effort than a dedicated effort for better UX for the Hub 2.x+ browser UI. With a web service interface to the Hub, multiple UI's can be created in the field, so we all get multiple new and creative approaches to UI solutions with a single effort from WPMU DEV. Win-Win.

End-point examples:

– Activate site feature with Put /Automate/On/foo.com

– Deactivate with Put /Reports/Off/bar.com

– Post /Security/RunScan/foo.com/

– Post /Security/Blacklist/Activate/foo.com

– Post /Performance/Email/Off

– Post /Automate/Plugin/Off/foo.com/ultimate_branding

– Get /Uptime/ResponseTime/20180101/20180103 (array of timestamps and responsetime in ms).

– Get /Uptime/Downtime/20180101/20180130 (array of events with FromTime,ToTime,seconds)

– Remove contact from the list of people getting a report:

Put /Reports/foo.com/MyReportName/Recipient/aaa@foo.com

How might reporting be used? Consider a custom app, server-based or mobile, that checks to see if there is a new Uptime event. With that information the client-side code may post a Slack update, send SMS, put the server into maintenance mode via the WP CLI, or even restart the webserver or network. We have no idea what kind of applications someone could create with ready access to information like that.

How might instructions To the Hub be used? Let's say you're reading an article that says PowerPluginX now has a virus. With a single web service call you might be able to de-activate that plugin for all of your sites:

Post /Plugins/powerpluginx/Off/AllSites

Sure, we can do that one function with the WP CLI but we'd need client side code that does this for all of our sites. The Hub already has access to all sites for this kind of operation.

As a final example, what if we're going to do some work on a site when we get home and we want to get a backup while we're on the way? Open a custom app and execute a function that goes to:

Post /Backups/Run/foo.com

When was the last backup?

Get /Backups/Last/foo.com

In summary, the raison d'être of the Hub is to centralize site management. The initial approach to that is facilitate site management via the browser. In that process Dev has created a lot of rules in the server which implement directives from the browser, and rules which return data to be formatted for the browser. This proposal is a continuation of that core purpose, with modularization of those rules over time so that they can be accessed via the WP API, thus allowing for alternative User interfaces and for new system interfaces that rely on the Hub for functionality, not aesthetics.