Home Web API

Web API



The Web API can be used to retrieve raw data from WhatPulse users and/or teams. You can use this API to show statistics on your website, blog or use it for your own applications. In the following examples, we will assume that you want to display your statistics on a website. We will also assume that you have some working knowledge of web development.

User Statistics
You can find the user statistics here: http://api.whatpulse.org/user.php?user=<userid or username>. You can either specific a WhatPulse userid or a username at the end of the URL.

Options
/user.php?formatted=yes Format all numbers. (turns 1000, into 1,000)
/user.php?format=xml Outputs data in xml format (default)
/user.php?format=json Outputs data in json format

Team Statistics
You can find the team statistics here: http://api.whatpulse.org/team.php?team=<teamid or name>. You can either specific a WhatPulse teamid or a team name at the end of the URL.

Options
/team.php?formatted=yes Format all numbers. (turns 1000, into 1,000)
/team.php?format=xml Outputs data in xml format (default)
/team.php?format=json Outputs data in json format
/team.php?members=yes Includes list of members. (can be big)

Pulse Statistics
You can retrieve pulse statistics from users and teams. Check the options below and this URL for an example: http://api.whatpulse.org/pulses.php?user=smitmartijn.

Options
/pulses.php?formatted=yes Format all numbers. (turns 1000, into 1,000)
/pulses.php?format=xml Outputs data in xml format (default)
/pulses.php?format=json Outputs data in json format
/pulses.php?team=<teamid or name> Show pulses from all users inside a team
/pulses.php?user=<userid or username> Show pulses from a specific user
/pulses.php?start=<unix timestamp> Show between a certain date. Needs to be used in conjunction with end
/pulses.php?end=<unix timestamp> Show between a certain date. Needs to be used in conjunction with start

Output Caching
To prevent overloading our servers, the API has a built in caching method. The cache duration is currently set to 1 hour. This means that the first time you retrieve the stats of a certain user, the API output will not update for 1 hour (even if the user has pulsed).


PHP Example

Let's retrieve the statistics of a user and end up with a XML format

<?php
	// retrieve data via cURL
	$ch = curl_init();

	curl_setopt($ch, CURLOPT_URL, "http://api.whatpulse.org/user.php?user=1&formatted=yes");
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	$xml_content = curl_exec($ch);
	curl_close($ch);

	// now you can process the XML content (i.e. via a xml to array function)
	echo $xml_content;
?>

Now, let's retrieve the same statistics but in a JSON format. We can then use the builtin PHP functions for JSON to process/use the stats.

<?php
	// retrieve data via cURL
	$ch = curl_init();

	curl_setopt($ch, CURLOPT_URL, "http://api.whatpulse.org/user.php?user=1&formatted=yes&format=json");
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	$json_content = curl_exec($ch);
	curl_close($ch);

	// process JSON content
	$data = json_decode($json_content);
	// use data
	var_dump($data);
?>