A Tumblr API wrapper for PHP.
Latest commit e131801 Feb 1, 2015 @bschaeffer Deprecate
Failed to load latest commit information.
tumblr remove Templatize class May 13, 2011
LICENSE add LICENSE Apr 13, 2011
README.md Deprecate Feb 1, 2015
tumblr.php remove Templatize class May 13, 2011


NO LONGER MAINTAINED: This repository is caput. There are probably numerous other libraries that do exactly what this library does, only better.

Tumblr PHP

This library is a PHP wrapper for Tumblr's API. I wrote it for another project, but decided to extract and develop it separately. It's immature, but here for your enjoyment!


All methods return the raw output from the API request, but don't fret. This library has two methods which accept this data and return a PHP array. See the Conversion section of this guide for more information.

Static Methods


// Get blog and post data
$raw_json = Tumblr::read($username, $options = array(), $request_json = TRUE);

// Get custom pages data (see 'Authenticated Read' for private posts)
$raw_xml = Tumblr::pages($username, $get_private = FALSE);


// First, you have to 'login' (set the email and password)
Tumblr::login($email, $password, $force = FALSE);

// Authenticate the given credentials (returns TRUE/FALSE)
$is_valid = Tumblr::authenticate();

Note: Tumblr::authenticate will be called for each API request that requires authentication. However, it will only actually validate the request (make the API call) once for each call to Tumblr::login (and won't even do that unless a method requires it).

Optionally, passing TRUE as a third parameter will forego the initial authentication API call (saving an HTTP request) and assume that you entered the correct $email and $password:

Tumblr::login($email, $password, TRUE);

Authenticated Reading

// Remember to 'login'
Tumblr::login($email, $password);

// Get your dashboard
$raw_xml = Tumblr::dashboard($options = array());

// Get your liked posts
$raw_xml = Tumblr::liked($options = array());

// Get custom pages, including private ones (requires valid 'login')
$raw_xml = Tumblr::pages($username, TRUE);


// All write methods require authentication, so...
Tumblr::login($email, $password);

// Like/Unlike a post
$bool = Tumblr::like($post_id, $reblog_key);
$bool = Tumblr::unlike($post_id, $reblog_key);


Conversion to PHP arrays does not happen automatically... but it's still easy.


$raw_json = Tumblr::read('manasto');
$array = Tumblr::json_to_array($raw_json);

To simply purge returned JSON API data of unwanted things like var tumblr_api_read = {...}; or someCallback({...}); and end up with {...}, do this:

$json = Tumblr::clean_json($raw_json);


$raw_xml = Tumblr::read('manasto', NULL, FALSE);
$array = Tumblr::xml_to_array($raw_xml);

Because converting the simplexml_load_string object to an array creates @attributes keys, Tumblr::xml_to_array automatically purges the newly created array of these keys while still preserving the attribute relationship.

If you would like to keep the @attributes keys, just pass FALSE as a second parameter to the function:

$array = Tumblr::xml_to_array($raw_xml, FALSE);


For now, we either return the data or FALSE. Real error handling will appear someday...


Tumblr PHP is Copyright © 2011 Braden Schaeffer. It is free software, and may be redistributed under the terms specified in the LICENSE file.