Open API
Our open API allows developers to integrate PressTrends into their current web and mobile apps. Below is a list of services available to developers for various environments including marketplaces and general web apps surrounding WordPress.
- Theme Data – Retrieve Theme Specific Adoption Data
- Plugin Data – Retrieve Plugin Specific Adoption Data
- Marketplaces – Allow authors to easily use PressTrends
Theme Data
Our data out API service for themes allows theme authors to pull real-time stats for their themes. These stats can be utilized in different ways including integrating with sales and download data or even just to display on theme pages for end-user info.
The Call
http://api.presstrends.io/index.php/api/app/theme/auth/[Theme Auth Code]/
Theme Auth Code – Auth Code for theme found in Account.
Sample Call
http://api.presstrends.io/index.php/api/app/theme/auth/dv6wpuf8puh5ekqghmbdgn9gelsg14w6i/
Return
You can set the return to either JSON or XML by adding format/json or format/xml to the end of the call.
Name: Name of theme
Category: Category of theme
Date Added: Data theme was added to PressTrends
Total Sites: Total sites activated to date
Current Week Sites: Sites activated this week
Previous Week Sites: Sites activated previous week
Month Sites: Site currently active this month
Sample XML Return
<xml>
<name>Dillon</name>
<category>Blog</category>
<created>2012-06-12 08:54:42</created>
<total_sites>47</total_sites>
<current_week_sites>0</current_week_sites>
<previous_week_sites>1</previous_week_sites>
<month_sites>40</month_sites>
</xml>
Parse the Return
An easy way to parse the XML response using PHP and cURL is shown below:
<?php $url = "http://api.presstrends.io/index.php/api/app/theme/auth/dv6wpuf8puh5ekqghmbdgn9gelsg14w6i/"; $ch = curl_init(); // initialize curl handle curl_setopt($ch, CURLOPT_URL,$url); // set url to post to curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable curl_setopt($ch, CURLOPT_TIMEOUT, 4); // times out after 4s $result = curl_exec($ch); // run the whole process $xml = simplexml_load_string($result); // echo does the casting for you $theme_name = $xml->item->name; $total_sites = $xml->item->total_sites; echo ''.$theme_name.' is on '.$total_sites.' sites'; ?>
Plugin Data
Our data out API service for plugins allows plugin authors to pull real-time stats for their plugins. These stats can be utilized in different ways including integrating with sales and download data or even just to display on plugin pages for end-user info.
The Call
http://api.presstrends.io/index.php/api/app/plugin/auth/[Plugin Auth Code]/
Plugin Auth Code – Auth Code for plugin found in Account.
Sample Call
http://api.presstrends.io/index.php/api/app/plugin/auth/61n5oidpnnlg1xpx4yzz9p9lw9yyznyoi/
Return
You can set the return to either JSON or XML by adding format/json or format/xml to the end of the call.
Name: Name of plugin
Category: Category of plugin
Date Added: Data plugin was added to PressTrends
Total Sites: Total sites activated to date
Current Week Sites: Sites activated this week
Previous Week Sites: Sites activated previous week
Month Sites: Site currently active this month
Sample XML Return
<xml>
<name>PressTrends</name>
<category>Analytics</category>
<date_added>2012-08-08 19:24:56</date_added>
<total_sites>54</total_sites>
<current_week_sites>15</current_week_sites>
<previous_week_sites>17</previous_week_sites>
<month_sites>53</month_sites>
</xml>
Parse the Return
An easy way to parse the XML response using PHP and cURL is shown below:
<?php $url = "http://api.presstrends.io/index.php/api/app/plugin/auth/61n5oidpnnlg1xpx4yzz9p9lw9yyznyoi/"; $ch = curl_init(); // initialize curl handle curl_setopt($ch, CURLOPT_URL,$url); // set url to post to curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable curl_setopt($ch, CURLOPT_TIMEOUT, 4); // times out after 4s $result = curl_exec($ch); // run the whole process $xml = simplexml_load_string($result); // echo does the casting for you $plugin_name = $xml->item->name; $total_sites = $xml->item->total_sites; echo ''.$plugin_name.' is on '.$total_sites.' sites'; ?>
Marketplaces
For marketplaces, we offer a simple service that handles registrations, themes, and metrics all at once.
The Call
http://api.presstrends.io/index.php/api/themes/theme/name/[Theme Name]/category/[Category Name]/fname/[First Name]/email/[Email]/username/[Users Marketplace Username]
Theme Name – Name of the theme you are adding.
Category – Name of category theme is under.
First Name – First Name of user or theme author.
Email – Email address for user or theme author.
Username – Marketplace username of user or theme author.
Return
You can set the return to either JSON or XML by adding format/json or format/xml to the end of the call.
Sample XML Return
<xml>
<item>
<api_key>yrvgvjqem0qs6pdg016qlj1gmw72qqli441w</api_key>
<auth>rd2qt2zno5qndfm7e0o1q7mfpwefx6a9q</auth>
</item>
</xml>
Parse the Return
An easy way to parse the XML response using PHP and cURL is shown below:
<?php $url = "http://api.presstrends.io/index.php/api/themes/theme/name/ThemeName/category/Portfolio/fname/George/email/goerge@presstrends.io/username/prstrends/format/xml"; $ch = curl_init(); // initialize curl handle curl_setopt($ch, CURLOPT_URL,$url); // set url to post to curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable curl_setopt($ch, CURLOPT_TIMEOUT, 4); // times out after 4s $result = curl_exec($ch); // run the whole process $xml = simplexml_load_string($result); // echo does the casting for you $api_key = $xml->item->api_key; $auth = $xml->item->auth; echo ''.$api_key.''.$auth.''; ?>