Yes we have an API, and It's pretty damn simple to use. We offer three types of responses: JSONP, JSON, and XML. We do ask two things from you though, the first is maybe a linkback in your notice to the user that tumblr is messing up. And the second is if you have a very high-volume service please cache our response every 5 minutes.
You should use Tumblr Uptime if you want to provide a great user experience even when Tumblr is not working. Plus you get to tell the user that it's not your fault for the crappy uptime.
JSONP Example
http://tumblruptime.apigee.com/json?callback=callbackFunction
The output of this page when decoded should look like this:
Object ( [methods] => Object ( [/api/authenticate] => Object ( [up] => 1 ) [/api/read] => Object ( [up] => ) [/api/write] => Object ( [up] => 1 ) [/oauth] => Object ( [up] => 1 ) [/oauth/delete] => Object ( [up] => ) ) )
So when you're checking if a specific method is working all you need to do is check against the method. Here is an example in javascript using JQuery:
// load the api response
$.getJSON('http://tumblruptime.apigee.com/json?callback=?', function (response) {
// check if an api method is broken
if (!response.methods['/api/read'].up) {
alert('method is not working, show the user something');
}
});
JSON Example
http://tumblruptime.apigee.com/json
The output of this page when decoded should look like this:
Object ( [methods] => Object ( [/api/authenticate] => Object ( [up] => 1 ) [/api/read] => Object ( [up] => ) [/api/write] => Object ( [up] => 1 ) [/oauth] => Object ( [up] => 1 ) [/oauth/delete] => Object ( [up] => ) ) )
So when you're checking if a specific method is working all you need to do is check against the method. Here is an example in php:
// load the api response
$json = json_decode(file_get_contents('http://tumblruptime.apigee.com/json'));
// check if an api method works
if ($json->methods->{'/api/read'}->up) {
echo 'api works';
}
XML Example
http://tumblruptime.apigee.com/xml
The output of this page when decoded should look like this:
<?xml version="1.0" encoding="UTF-8"?> <methods> <api-authenticate>1</api-authenticate> <api-read/> <api-write>1</api-write> <oauth>1</oauth> <oauth-delete/> </methods>
So when you're checking if a specific method is working all you need to do is check against the method. Here is an example in php:
// load the api response
$xml = simplexml_load_string(file_get_contents('http://tumblruptime.apigee.com/xml'));
// check if an api method works
if ((int) $xml->{'api-read'}) {
echo 'api works';
}