Search code examples
jsongettumblr

Can I retrieve more than 20 post title names on Tumblr? (via JSON)


I made a script to retrieve the strings of all the post titles of one of my blogs. The problem is that i can't retrieve more than 20 title.

Theoritically, http://www.tumblr.com/docs/en/api/v1 says: "The most recent 20 posts are included by default. You may pass these optional GET parameters: .... num - The number of posts to return. The default is 20, and the maximum is 50. ..... "

so should i be able to get the maximum 50?

My GET code looks like this:

$.ajax({
    url: "http://api.tumblr.com/v2/blog/var-lak.tumblr.com/posts?api_key=(my-api-key)text?limit=50&format=text",
    dataType: 'jsonp',
    success: function(results){
    //.....

Thanks in advance, Attila


Solution

  • According to the documentation, you are passing wrong URL there. GET parameters mentioned in the documentation are separated by & sign in the address, so in:

    http://api.tumblr.com/v2/blog/var-lak.tumblr.com/posts?api_key=(my-api-key)text?limit=50&format=text
    

    You are passing to the server following GET variables:

    api_key = (my-api-key)text?limit=50
    format = text
    

    By the docs to v2 API, you have to pass limit variable, so you should provide:

    api_key = (my-api-key)
    limit = 50
    format = text
    

    That means the URL should look like:

    http://api.tumblr.com/v2/blog/var-lak.tumblr.com/posts?api_key=(my-api-key)&limit=50&format=text
    

    This should work.