tumblr / docs

Tumblr's public platform documentation.
Apache License 2.0
109 stars 27 forks source link

Not all likes are returned by the API #92

Closed nateify closed 1 year ago

nateify commented 2 years ago

Hello, I have found an issue where not all likes are returned by this API URI: api.tumblr.com/v2/user/likes The issue happens with both the pytumblr module for Python and raw HTTP requests. I am authenticated however I find that the final likes count is 13 fewer likes than what I can actually see by going to the likes section of the dashboard (https://www.tumblr.com/likes). I found some likes in there that never show up in the API.

For context, I confirmed the missing likes are from posts that are: not reblogs, not from a deactivated blog, the post has a community label of "Everyone", the blog is NOT dashboard-only (it can be viewed at username.tumblr.com) and NOT marked as sensitive.

Here is a little simple bit of Python code where I am iterating over the likes and offsetting by the before param, I added a check to ensure that I get 20 results back and I do every time up until the last request since my total number of likes is not divisible by 20:

while True:
    posts = client.likes(**params)["liked_posts"]
    if not posts:
        break
    urls = [x["post_url"] for x in posts]
    print(f"API returns {len(urls)} likes for the request")
    logger.info("\n".join(urls))
    params["before"] = posts[-1]["liked_timestamp"]
nateify commented 1 year ago

I later determined that the API is working as intended. Here is how I found a missing like:

  1. Blog A makes a post
  2. Blog B reblogs that post
  3. I click the like button on blog B's reblog
  4. Blog B gets deleted/deactivated
  5. Neither the reblog nor source post appear in my likes or API
  6. I visit Blog A by chance and find the source post has a filled in red heart ♥ leading me to believe it was a missing like

Tumblr support confirmed this is expected behavior and unfortunately there is no way for me to get the data of semi-missing source likes via API or data archival request.