I want to get details about a plugin hosted on WordPress.org Repository by making a call to API at http://api.wordpress.org/plugins/info/1.0/

I have pasted below the code I used and the output. I am not good with PHP and just wanted to know the way to retrieve and output just one piece of information from the array such as Download count.

$payload = array(
  'action' => 'plugin_information',
  'request' => serialize(
        'slug' => 'i-recommend-this',
        'fields' => array(
            'downloaded' => true,
            'description' => false

$body = wp_remote_post( 'http://api.wordpress.org/plugins/info/1.0/', array( 'body' => $payload) );

var_dump( unserialize($body['body']) );

This outputs data in below way:

  public 'name' => string 'I Recommend This' (length=16)
  public 'slug' => string 'i-recommend-this' (length=16)
  public 'version' => string '2.4.2' (length=5)
  public 'author' => string '<a href="http://www.harishchouhan.com">Harish Chouhan</a>' (length=57)
  public 'author_profile' => string 'http://profiles.wordpress.org/hchouhan' (length=38)
  public 'contributors' => 
      'hchouhan' => string 'http://profiles.wordpress.org/hchouhan' (length=38)
      'dreamsonline' => string 'http://profiles.wordpress.org/dreamsonline' (length=42)
      'dreamsmedia' => string 'http://profiles.wordpress.org/dreamsmedia' (length=41)
      'Benoit "LeBen" Burgener' => string '' (length=0)
  public 'requires' => string '3.3' (length=3)
  public 'tested' => string '3.5.2' (length=5)
  public 'compatibility' => 
      '3.6' => 
          '2.4.0' => 
          '2.4.2' => 
  public 'rating' => float 92.4
  public 'num_ratings' => int 13
  public 'downloaded' => int 7673
  public 'last_updated' => string '2013-08-25' (length=10)
  public 'added' => string '2012-04-25' (length=10)
  public 'homepage' => string 'http://www.harishchouhan.com/personal-projects/i-recommend-this/' (length=64)
  public 'sections' => 
  'description' => string '<p>This plugin allows your visitors to simply like/recommend your posts instead of comment on it.</p>

<h4>This plugin includes</h4>

<li>A counter to display the number of "like" and to vote.</li>
<li>A widget and a function to display the X most liked posts.</li>
<li>A preference pane with some options.</li>
<li>Saves Cookie as well as users IP address to disable voting on the same post again</li>

<h4>Advanced Options</h4>

<li>Hide count if count is zero</li>
<li>Set a default messages w'... (length=1694)
      'installation' => string '<ol>
<li>Upload the directory <code>/i-recommend-this/</code> to the <code>/wp-content/plugins/</code> directory</li>
<li>Activate the plugin through the 'Plugins' menu in WordPress</li>
<li>Click on the Settings link below the plugin name on the plugins page</li>

<p>To display the recomment/like link other than at the bottom of individual post, you would have to add below code in your template</p>

<pre><code>&#60;?php if( function_exists(&#039;dot_irecommendthis&#039;) ) dot_irecommendthis(); ?&#62'... (length=586)
      'changelog' => string '<p>= 2.4.2
* Bug fix. Thanks to @mmaxim</p>

<p>= 2.4.1
* Fixed undefined index error.</p>

<p>= 2.4.0
* Added filter dot_irt_before_count to be able to allow custom content or icons before the count.</p>

<p>= 2.3.0
* Added option to hide count if count is zero
* Added option to disable saving of IP address in the database</p>

<p>= 2.2.0
* Added option to customize the link title. You can now remove the word recomment and add anything you like. Ideas suggested by Krystina Montemurro.</p>

<p>= 2.1.5
* Sup'... (length=2216)
      'faq' => string '<p>Take a look at the <a href="http://www.dreamsonline.net/wordpress-plugins/i-recommend-this/">official "I Recommend This" FAQ</a>.</p>

<p>You can also visit the <a href="http://www.dreamsonline.net/wordpress-plugins/i-recommend-this/">support center</a> and start a discussion if needed.</p>' (length=294)
  public 'download_link' => string 'http://downloads.wordpress.org/plugin/i-recommend-this.2.4.2.zip' (length=64)
  public 'tags' => 
      'dribbble-like' => string 'dribbble like' (length=13)
      'heart' => string 'heart' (length=5)
      'like' => string 'Like' (length=4)
      'love' => string 'love' (length=4)
      'post' => string 'Post' (length=4)
      'rate' => string 'rate' (length=4)
      'rating' => string 'rating' (length=6)
      'recommend' => string 'recommend' (length=9)

2 Answers 2


Just found about plugin_api and using it, the above can be achieved with just below code:

/** If plugins_api isn't available, load the file that holds the function */ if ( ! function_exists( 'plugins_api' ) ) require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );

/** Prepare our query */ $call_api = plugins_api( 'plugin_information', array( 'slug' => 'i-recommend-this' ) );

/** Display the results */ if ( is_wp_error( $call_api ) ) echo '

' . print_r( $call_api->get_error_message(), true ) . '
'; else //echo '
' . print_r( $call_api, true ) . '
'; echo '

' . print_r( $call_api->downloaded, true ) . '



Ok finally found a way:

$payload = array( 'action' => 'plugin_information', 'request' => serialize( (object)array( 'slug' => 'i-recommend-this', 'fields' => array( 'downloaded' => true, 'description' => false ) ) ) );

$body = wp_remote_post( 'http://api.wordpress.org/plugins/info/1.0/', array( 'body' => $payload) );

$body = unserialize($body['body']);

echo '<p>Downloaded: ' . print_r( $body->downloaded, true ) . '</p>';


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.