WPapi.org

to support hosting

WPapi is a super easy to use API that gives you access to the stats for your WordPress-hosted plugins and themes, which you can use on your own blog or website for graphs, or like whatever.

A quick explanation

I was in the middle of rebuilding parts of my own site and even though I've started moving my plugins and themes across into the official WordPress plugin and theme directories I still want to display up-to-date download stats on my own site.

If you dig around you can find the xml feed that WordPress uses to generate their graphs, however I wanted a JSON feed. To be more specific I wanted JSON because I'm considering adding some sexy graphs, possibly using something like this.

A few hours work and the basics are in place, using the 'hidden' WordPress xml feed as the data source, I'm collecting the stats, caching them, and then serving up either an XML or JSON feed. Check out the examples to see what data is currently returned, I'm looking at possibly adding more in the near future.

Ok, cool, how do I use it?

http://wpapi.org/api/type/slug.format

What's it all mean?

type
too easy, this will be either plugin or theme
slug
if your plugin is http://wordpress.org/extend/plugins/fluency-admin/
then your slug is simply fluency-admin
format
you've got the choice of xml, json, jsonp, php or csv

Got it? Here's a couple of quick examples just in case…

http://wpapi.org/api/plugin/fluency-admin.xml http://wpapi.org/api/plugin/wp-super-cache.json http://wpapi.org/api/theme/carrington-blog.jsonp http://wpapi.org/api/theme/p2.php http://wpapi.org/api/plugin/stats.csv

Check the documentation for more info.

JSON Response

URL http://wpapi.org/api/plugin/slug.json http://wpapi.org/api/theme/slug.json
Parameter count (integer) - specify how many days of stats to return.

Examples

http://wpapi.org/api/plugin/fluency-admin.json

{
  "slug":"fluency-admin",
  "type":"plugin",
  "stats":{
    "2009-09-20":"694",
    "2009-09-21":"619",
    "2009-09-22":"312",
    "2009-09-23":"302",
    "2009-09-24":"228",
    "2009-09-25":"180",
    "2009-09-26":"158",
    "2009-09-27":"145",
    "2009-09-28":"217",
    "2009-09-29":"204",
    "2009-09-30":"181",
    "2009-10-01":"158",
    "2009-10-02":"115",
    "2009-10-03":"115",
    "2009-10-04":"103",
    "2009-10-05":"132",
    "2009-10-06":"134",
    "2009-10-07":"145",
    "2009-10-08":"112",
    "2009-10-09":"107",
    "2009-10-10":"78"
  },
  "total_days":21,
  "total_downloads":4439,
  "average_downlods":211.381,
  "last_update":"2009-10-11 19:49:28",
  "hits":12
}

http://wpapi.org/api/plugin/fluency-admin.json?count=3

{
  "slug":"fluency-admin",
  "type":"plugin",
  "stats":{
    "2009-10-08":"112",
    "2009-10-09":"107",
    "2009-10-10":"78"
  },
  "total_days":21,
  "total_downloads":4439,
  "average_downlods":211.381,
  "last_update":"2009-10-11 19:49:28",
  "hits":12,
  "count":3
}

JSONP Response

URL http://wpapi.org/api/plugin/slug.jsonp http://wpapi.org/api/theme/slug.jsonp
Parameters count (integer) - specify how many days of stats to return.
callback (string) - name of custom javascript callback function
Defaults to "wpapi_callback" if not specified.

Examples

http://wpapi.org/api/plugin/fluency-admin.jsonp

wpapi_callback({
  "slug":"fluency-admin",
  "type":"plugin",
  "stats":{
    "2009-09-20":"694",
    "2009-09-21":"619",
    "2009-09-22":"312",
    "2009-09-23":"302",
    "2009-09-24":"228",
    "2009-09-25":"180",
    "2009-09-26":"158",
    "2009-09-27":"145",
    "2009-09-28":"217",
    "2009-09-29":"204",
    "2009-09-30":"181",
    "2009-10-01":"158",
    "2009-10-02":"115",
    "2009-10-03":"115",
    "2009-10-04":"103",
    "2009-10-05":"132",
    "2009-10-06":"134",
    "2009-10-07":"145",
    "2009-10-08":"112",
    "2009-10-09":"107",
    "2009-10-10":"78"
  },
  "total_days":21,
  "total_downloads":4439,
  "average_downlods":211.381,
  "last_update":"2009-10-11 19:49:28",
  "hits":12
})

http://wpapi.org/api/plugin/fluency-admin.jsonp?count=3

wpapi_callback({
  "slug":"fluency-admin",
  "type":"plugin",
  "stats":{
    "2009-10-08":"112",
    "2009-10-09":"107",
    "2009-10-10":"78"
  },
  "total_days":21,
  "total_downloads":4439,
  "average_downlods":211.381,
  "last_update":"2009-10-11 19:49:28",
  "hits":12,
  "count":3
})

http://wpapi.org/api/plugin/fluency-admin.jsonp?count=5&callback=myFunction

myFunction({
  "slug":"fluency-admin",
  "type":"plugin",
  "stats":{
    "2009-10-06":"134",
    "2009-10-07":"145",
    "2009-10-08":"112",
    "2009-10-09":"107",
    "2009-10-10":"78"
  },
  "total_days":21,
  "total_downloads":4439,
  "average_downlods":211.381,
  "last_update":"2009-10-11 19:49:28",
  "hits":12,
  "count":5
})

PHP Response

URL http://wpapi.org/api/plugin/slug.php http://wpapi.org/api/theme/slug.php
Parameter count (integer) - specify how many days of stats to return.

Response is a serialized string, which can be easily converted back into an array.

Examples

http://wpapi.org/api/plugin/fluency-admin.php

a:8:{
  s:4:"slug";s:13:"fluency-admin";
  s:4:"type";s:6:"plugin";
  s:5:"stats";a:21:{
    s:10:"2009-09-20";s:3:"694";
    s:10:"2009-09-21";s:3:"619";
    s:10:"2009-09-22";s:3:"312";
    s:10:"2009-09-23";s:3:"302";
    s:10:"2009-09-24";s:3:"228";
    s:10:"2009-09-25";s:3:"180";
    s:10:"2009-09-26";s:3:"158";
    s:10:"2009-09-27";s:3:"145";
    s:10:"2009-09-28";s:3:"217";
    s:10:"2009-09-29";s:3:"204";
    s:10:"2009-09-30";s:3:"181";
    s:10:"2009-10-01";s:3:"158";
    s:10:"2009-10-02";s:3:"115";
    s:10:"2009-10-03";s:3:"115";
    s:10:"2009-10-04";s:3:"103";
    s:10:"2009-10-05";s:3:"132";
    s:10:"2009-10-06";s:3:"134";
    s:10:"2009-10-07";s:3:"145";
    s:10:"2009-10-08";s:3:"112";
    s:10:"2009-10-09";s:3:"107";
    s:10:"2009-10-10";s:2:"78";
  }
  s:10:"total_days";s:2:"21";
  s:15:"total_downloads";s:4:"4439";
  s:17:"average_downloads";s:7:"211.381";
  s:11:"last_update";s:19:"2009-10-11 21:11:07";
  s:4:"hits";s:2:"64";
}

http://wpapi.org/api/plugin/fluency-admin.php?count=4

a:8:{
  s:4:"slug";s:13:"fluency-admin";
  s:4:"type";s:6:"plugin";
  s:5:"stats";a:21:{
    s:10:"2009-10-07";s:3:"145";
    s:10:"2009-10-08";s:3:"112";
    s:10:"2009-10-09";s:3:"107";
    s:10:"2009-10-10";s:2:"78";
  }
  s:10:"total_days";s:2:"21";
  s:15:"total_downloads";s:4:"4439";
  s:17:"average_downloads";s:7:"211.381";
  s:11:"last_update";s:19:"2009-10-11 21:11:07";
  s:4:"hits";s:2:"64";
  s:5:"count";s:1:"4";
}

XML Response

URL http://wpapi.org/api/plugin/slug.xml http://wpapi.org/api/theme/slug.xml
Parameter count (integer) - specify how many days of stats to return.

Examples

http://wpapi.org/api/plugin/fluency-admin.xml

<?xml version="1.0" encoding="UTF-8"?>
<data>
  <slug>fluency-admin</slug>
  <type>plugin</type>
  <stats>
    <value date="2009-09-20">694</value>
    <value date="2009-09-21">619</value>
    <value date="2009-09-22">312</value>
    <value date="2009-09-23">302</value>
    <value date="2009-09-24">228</value>
    <value date="2009-09-25">180</value>
    <value date="2009-09-26">158</value>
    <value date="2009-09-27">145</value>
    <value date="2009-09-28">217</value>
    <value date="2009-09-29">204</value>
    <value date="2009-09-30">181</value>
    <value date="2009-10-01">158</value>
    <value date="2009-10-02">115</value>
    <value date="2009-10-03">115</value>
    <value date="2009-10-04">103</value>
    <value date="2009-10-05">132</value>
    <value date="2009-10-06">134</value>
    <value date="2009-10-07">145</value>
    <value date="2009-10-08">112</value>
    <value date="2009-10-09">107</value>
    <value date="2009-10-10">78</value>
  </stats>
  <total_days>21</total_days>
  <total_downloads>4439</total_downloads>
  <average_downloads>211.381</average_downloads>
  <last_update>2009-10-11 19:49:28</last_update>
  <hits>12</hits>
</data>

http://wpapi.org/api/plugin/fluency-admin.xml?count=3

<?xml version="1.0" encoding="UTF-8"?>
<data>
  <slug>fluency-admin</slug>
  <type>plugin</type>
  <stats>
    <value date="2009-10-08">112</value>
    <value date="2009-10-09">107</value>
    <value date="2009-10-10">78</value>
  </stats>
  <total_days>21</total_days>
  <total_downloads>4439</total_downloads>
  <average_downloads>211.381</average_downloads>
  <last_update>2009-10-11 19:49:28</last_update>
  <hits>12</hits>
  <count>3</count>
</data>

CSV

URL http://wpapi.org/api/plugin/slug.csv http://wpapi.org/api/theme/slug.csv
Parameter count (integer) - specify how many days of stats to return.

Only returns the download stats for the specified plugin or theme.

Examples

http://wpapi.org/api/plugin/fluency-admin.csv

"date","downloads",
"2009-09-20","694",
"2009-09-21","619",
"2009-09-22","312",
"2009-09-23","302",
"2009-09-24","228",
"2009-09-25","180",
"2009-09-26","158",
"2009-09-27","145",
"2009-09-28","217",
"2009-09-29","204",
"2009-09-30","181",
"2009-10-01","158",
"2009-10-02","115",
"2009-10-03","115",
"2009-10-04","103",
"2009-10-05","132",
"2009-10-06","134",
"2009-10-07","145",
"2009-10-08","112",
"2009-10-09","107",
"2009-10-10","78",

http://wpapi.org/api/plugin/fluency-admin.csv?count=4

"date","downloads",
"2009-10-07","145",
"2009-10-08","112",
"2009-10-09","107",
"2009-10-10","78",

WPAPI updates

October 18, 2009

  • Updated Documentation and Examples (usage examples coming soon).
  • Added CSV output format (stats only).
  • Added 'count' parameter to all formats.

October 12, 2009

  • Added JSONP (with custom callback support) and PHP (serialized string) output formats.
  • Fixed content type for XML and JSON feeds.

October 11, 2009

  • Initial launch
  • Added XML and JSON output formats.