Sometimes I just like to start all over and take what I’ve learned to implement in the totally fresh version of the thing that I’m working on. And that is the case with my upcoming coding project. And it’s quite the project indeed. At this moment I have set up a sandbox to validate the idea and making sure that I have bootstrapped it well enough to go on for the next iteration.
I am talking about an extension for the existing WordPress REST API. The thing is, I’d like to change a WordPress installation in nothing more than a glorified cabinet to fetch and store data from. And even have the option to modify and enrich that data. Yes, the things that API’s do.
Server side API
So the project has two ends. The Server/API side and the plugin-side that makes itself know to the API and then share it’s needed information to make the API happy. For instance you can use that data to send a list of your pages and check for dead links on those pages. Or if you have multiple websites with overlapping information (like lists of addresses or even ads) you can share it.
API calling WordPress plugin
The Server side is quite complex. I have extended the existing wp-json with my own endpoint and made automated registering possible. Kind of a milestone for me. After that I’ve set up a simple managing and logging environment to monitor the process a bit better. That combined with a tasklist which gets ran by a cron and you have a sort-of-working system. Kind of neat.
So the plugin was not that hard to build since the server side takes on most of the load. Just request a token from the server and when that returns store it in the options. Then make a list available and create a custom rest endpoint. This endpoint is only available when the token is the same as the server request. That way the plugin does not have to run crons to keep everything up to date and the server can just check if the site is still available when adding the token to the request.
Perspective on coding
One more thing I’d like to add is the way of thinking that has changed my perspective on software and made me want to redo a lot of what I’ve coded. Software has to be written in a way that it’s hard to break. Good and clear error messages are key in making sure the rest of the process keeps on running while you can sidetrack problems and work on them to figure it out.
The V0.1 of my API does this in a way and I think I can really improve on that with the V0.2 version. So working on this is not just a means to an end but also a really effective learning process. And like that a lot. But I’m still kind of in the dark where I will use it for although there are some vague ideas floating in my mind right now. Until the API Core works like a charm and errors kind of work itself out, I’ll keep working on it.
So my project of 2020 will be this API. I’m not sure if I’m going to make it available trough the WP Plugins Repository because it is more aimed at coding people other then the end user. This is the first blog of my Dev Blog on this plugin. More will follow.