[wp-hackers] Help with the API on WordPress.org?

DD32 wordpress at dd32.id.au
Fri Jan 2 00:18:29 GMT 2009

Happy new year to you too :)

Alright, Lets see now, First things that spring to my mind:
 * I was going to do the *exact* same thing as you are doing now, But i
quickly stoped, for 1 reason, Google doesnt like Screen scrapers, Google
block you off after 2-3 similar repeditive searches, do it enough times
(like the plugin search) and you'll get blocked very quickly, Google's good
at detecting this.

 * So, Lets use one of the available Google API's! ...Then you realise the
only ones available only return the first 10 results with no further
listing.. and that plugins may appear multiple times in that listing..
(Maybe it was 50... but eitherway, it really reduced the number of viable

Also, mdawaffe was looking into fixing up the .org searching using a proper
search engine functionality (Currently bbPress's searching just doesnt cut
it), I'm not sure if its been released yet, But i believe its in the works.

So for the time being, I'd advise you to not waste your time on a Google
search option, Yahoo might be possible, They actually have API's they like
you using.. and since .org will hopefully get a better search functionality
in the near future, It might not be worth your time (& the extra requests
which would need to happen for it)

Ok, Now onto the actual API, Theres no docs available, but there'll be
something within the month hopefully, I've been talking to someone who's
going to document it for himself, and release it, Its not that complex
really at all

However, Since its not that complex, There isnt a function to send a list of
slugs and get a list of details back, Only a function to return those
details for a single plugin -- Mainly because there was no need for that
kind of functionality in the requirements at the time.. :)

Some basic documentation:


Accepts an object with a property of either:
a: *browse* - A bbPress View to "browse", eg, "popular" =
b: *search* - The term to search for
c: *tag* - Browse by a tag
d: *author* - Browse by an author (Note: .org has a few plugins to extend
the author search to include contributors/etc)

Other properties which the object can have:
*page* - the page of the results (duh..)
*per_page* - the number of results per page
*fields* - This is a bit.. odd.. an array of which fields to return, the API
has defaults for requests, but it can be overridden from the client, send an
array with the field as the key, and true|false as the value to return or
not, The fields are: *'description', 'sections', 'tested' ,'requires',
'rating', 'downloaded', 'downloadlink', 'last_updated' , 'homepage', 'tags'*

*return array of objects:*
An array of the same object that *plugin_information* returns

Takes an object with the property:
*slug* - The slug of the plugin to return the info for
*fields* - once again, Optional, Same deal as in the previous action, just
its got different defautls (ie. this one will return all the sections of the
readme, whilst the previous will only return the short description)

*return object:*
*name* - The plugins name*
*slug* - the plugins slug
*version* - The latest version
*author* - The Author of the plugin - If a URL is available for the author,
This will be a link
The following fields are optional, And are returned based on the *fields*param
*requires* - The required WordPress version
*tested* - The highest tested compatible WordPress version
*rating* - returns the % rating (ie, 10%, 100%) as a number.  (This is
displayed on .org as a 1-5 scale)
  *num_ratings* - If *ratings* is requsted, this will be returned as well,
Its the number of people that have rated the plugin
*downloads* - the number of times the plugin has been downloaded
*last_updated* - the date that the plugin was last updated, Excludes the
*homepage* - The URL of the plugin
*description* - The short description of the plugin(s)
*sections* - An array of readme sections, ie. array( 'faq' => 'FAQ... blah
blah my plugin is great.. blah blah', 'installing' => 'fgfg.... If no readme
sections are found, It returns  array('description' => (*description field
here from above)* )
*downloadlink* - The Download Link for the plugin (Theres a bug in this at
present, Any version with a space in the URL returns the wrong URL:
*tags* - an array of array( 'tag_slug' => 'Tag Name, 'slug2' => 'Pretty

Takes an object of:
*number* - The number of tags to return, Defaults to 100

*return array of objects: *(key will be tag slug)
*name* - The tags name
*slug* - The tags slug
*count* - The number of plugins

Final note, The API may also return an error object in the case of an error,
It'll be an object with a single property:
*error* - A Error string, ie. "Slug not provided" or "action not

2009/1/2 Mike Schinkel <mikeschinkel at gmail.com>

> Hi All (especially DD32):
> Happy New Year.
> I need help understanding how to call the API on WordPress.org.
>  What am I trying to do?  I love the new plugin install option found in
> v2.7's admin console but I find the plugin search results are not very good
> so I'm working on a plugin that will use Google Search results to order the
> search results.  I've got it all working except for the fact that the
> search
> results returned by requesting results from the API on WordPress.org doing
> even include some of the top search results from Google using the same
> term.
> I'm using the following Google search for the keyword "Category" (i.e. if
> I'm looking for plugins related to categories.) Note how I'm search
> for "*WordPress
> Category Plug*", limiting to just http://wordpress.org/extend/plugins/,
> omitting http://wordpress.org/extend/plugins/tags/ and requesting 100
> results:
>   -
> http://www.google.com/search?q=wordpress+category+plugins+site:http://wordpress.org/extend/plugins/+-site:http://wordpress.org/extend/plugins/tags/&num=100
> The "equivalent" search on WordPress.org is here:
>   - http://wordpress.org/extend/plugins/search.php?q=category
>  For example, the Top 10 results on Google are:
>   1. Category Page
>   2. Category Cloud Widget
>   3. Category Icons
>   4. Front Page Excluded Categories
>   5. Category Posts Widget
>   6. My Category Order
>   7. Category Order
>   8. Advanced Category Excluder
>   9. Collapsing Categories
>   10. Enhanced Categories
>  And the Top 10 results on WordPress.org (which appear to be the same as
> returned by the API are):
>   1. Simple Tags
>   2. WP-Cumulus
>   3. Search Everything
>   4. Event Calendar 3
>   5. WP Security Scan
>   6. Admin Management Xtended
>   7. Sidebar Widgets
>   8. DMSGuestbook
>   9. Wordpress Download Monitor
>   10. Yet Another Related Posts Plugin
>  Hopefully it is not a stretch for me to assert that the Google search
> results are far more applicable than the WordPress.org search results?
> What my code currently does is grab the Google search results and correlate
> them to the WordPress.org API results which are ultimately returned from
> the
> *plugins_api()* function found in */wp-admin/includes/plugin-install.php*.
> The API call ultimately looks like this:
> $request = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/',
>                          array( 'body' => array('action' => $action,
> 'request' => serialize($args))) );
> I correlate the two result sets because the WordPress.org API results have
> the metadata needed for the 2.7 admin console plugin search results such as
> rating and version and Google search results has the desired order.  But as
> stated I've found that many of the top search results from Google don't
> even
> show up in WordPress.org's search results.  A serious bummer. :-(
> So what I'm hoping is to find an API function that would let me in a single
> POST send a list of plugin slugs and have it return me the same array of
> plugin info and metadata for those identified plugins that is currently
> being returned by the aforementioned line from plugins_api().  I know the
> link to the API Docs at http://api.wordpress.org/plugins/info/1.0/ says
> "*If
> only I had written some...Sorry -DD32*" but I'm hoping we can start
> documenting here on the list? :-)  Minimally if someone could pastebin the
> code for the API then I could figure it out myself.
> Thanks in advance.
>  -Mike Schinkel
> http://mikeschinkel.com
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list