How do I retrieve a list of popular plugins using the WordPress.org Plugin API?
-
26-04-2021 - |
Question
I'd like to retrieve a list of popular plugins from WordPress.org using their API.
I know I can do something like this to get a specific plugin:
http://api.wordpress.org/plugins/info/1.0/name_of_plugin
And that I can get back a list of plugins using something like this:
http://api.wordpress.org/plugins/info/1.0/?action=query_plugins
But I don't know how to get the popular plugins. I'm guessing it is something like:
http://api.wordpress.org/plugins/info/1.0/?action=query_plugins&browse=popular
I'd like to do this without using WordPress' (the software) Plugin API. This should be something I could type into a browser and get back the results (like one can with the above).
Thanks!
Solution
I was wrong in the earlier version of the answer and 1.1 version of the API does support this via GET request.
The basic request would be: https://api.wordpress.org/plugins/info/1.1/?action=query_plugins&request[browse]=popular
And you can add more parameters by sticking with request
passed as "array" (in GET interpretation of).
See the [poor] documentation in Codex and links from there for more detail.
For in–PHP way, independent of WP core I made a WPorg Client library which implements this, among other things.
OTHER TIPS
Just adding in some additional api requests with params, due to the minimal documentation available.
By tag "gdpr", 1 result per page, request page nr 1 and browse by popularity:
https://api.wordpress.org/plugins/info/1.2/?action=query_plugins&request[tag]=gdpr&request[per_page]=1&request[page]=1&request[broswe]=popular
By search phrase, tag and 1 result per page:
https://api.wordpress.org/plugins/info/1.2/?action=query_plugins&request[tag]=gdpr&request[per_page]=1&request[search]=jonk
By tag, 1 result per page and return only the fields that seem to be mandatory since they couldn't be turned off:
https://api.wordpress.org/plugins/info/1.2/?action=query_plugins&request[tag]=gdpr&request[per_page]=1&request[fields][ratings]=0&request[fields][homepage]=0&request[fields][rating]=0&request[fields][tested]=0&request[fields][description]=0&request[fields][tags]=0&request[fields][icons]=0&request[fields][donate_link]=0&request[fields][short_description]=0&request[fields][added]=0&request[fields][active_installs]=0&request[fields][downloaded]=0&request[fields][last_updated]=0&request[fields][requires_php]=0&request[fields][requires]=0&request[fields][author]=0
Hope this helps!