Did you know that WordPress.org has a JSON API that you can use to query and get data?
Here's a video explanation
Well, we’re in 21st century (I think) so it’s normal and that's good.
As always, let's start with why.
What do you do with the data though?
In my case I needed it for auto suggest. One of my businesses is qSandbox. It’s a WordPress staging platform which allows people to set up a WordPress site or import (paid plan feature) an existing one in seconds. In one of the screens there’s a section where people can install plugins and themes. The installation can be done either via the plugin (https://wordpress.org/plugins/orbisius-support-tickets) or theme’s link (https://wordpress.org/themes/oceanwp) OR a link to a .zip file.
I wanted to be super easy for my customers. They needed just type and get suggestions to pop up rather than having to find and paste links. Not everybody is that organized. Saving a few seconds here and there can add up and keep you focused.
In the first implementation I did it so inefficiently but was working. Kind of. The search was bad as it only searched by a link (in WP terms slug). To get to the list I had to parse the SVN repository for plugins and themes in order to get to plugin or theme’s links. I've even created a crawler that would fetch all the readme files of each plugin. It's so time consuming and wastes resources both mine and those of WordPress.org.
I am glad WordPress.org has an API and the implementation turned our pretty nice.
Oh, if you’re doing implementation within the WordPress context you can check how WordPress itself uses the its API.
Try searching within WordPress’s code for plugins_api() and themes_api() functions.
In my cases I only needed a small number of fields to be returned by the API. Whoever worked on the WordPress.org API realized something cool and it is not everybody will need all the fields. So they have a fields parameter which you can use to specify which fields you’d like returned by the API. This results in faster queries and the response because less data is going to be returned and transferred across networks. Smart. I am going to use this idea in one of my next REST API services.
You can find the most up-to-date version of the code on this link.
This is what the API would return based on the keyword search output of the API
How do you use WordPress.org API? What would you use for?