Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency in API output #21

Closed
thagxt opened this issue Jul 21, 2020 · 6 comments
Closed

Inconsistency in API output #21

thagxt opened this issue Jul 21, 2020 · 6 comments

Comments

@thagxt
Copy link

thagxt commented Jul 21, 2020

There's an annoying inconsistency in the API. The Latest posts' output is different from older ones.

https://api.tumblr.com/v2/blog/MY-BLOG/posts/photo/?api_key=MY-API-KEY&offset=80&page_number=5

The newest posts output is like so:
body": "<figure class=\"tmblr-full\" data-orig-height=\"2048\" data-orig-width=\"1365\"><img src=\"https://64.media.tumblr.com/.../s640x960/..85.jpg\" data-orig-height=\"2048\" data-orig-width=\"1365\"></figure><p>description</p>"

But the oldest doesn't have the body, instead they have:

photos": [
    {
        "caption": "",
        "original_size": {
            "url": "https://64.media.tumblr.com/.../tumblr_xxl_1280.jpg",

Both are PHOTO posts. Why is that?

@cyle
Copy link
Member

cyle commented Jul 23, 2020

This is likely a consequence of the newer post being saved in the Neue Post Format, and the older one being saved in the legacy format. Generally speaking, post types are becoming deprecated on Tumblr under the hood. You can read more about this here and on the Engineering blog in general, as well as the documentation in this repo for the NPF spec. I strongly encourage you to check out leveraging ?npf=true and the Neue Post Format JSON so you can get consistent results here. You can still use filters like /posts/photo, but it may not always work the way you expect for new posts, see the legacy post type mapping here. Hope this helps!

@sorin-costea
Copy link

Just to understand better, you mean that the above weird answer is a consequence of requesting a NPF post over the old API?

@cyle
Copy link
Member

cyle commented Jul 23, 2020

Yes, exactly. Sorry if that was a bit confusing.

All of the current API endpoints for fetching posts (like the one above) can possibly return legacy posts alongside new NPF posts, depending on how the post was made. To maintain backwards compatibility, new NPF posts will look and act like legacy text/regular type posts using these endpoints (hence why they have body set). You can change this behavior and have post content served consistently as NPF by setting npf=true via a query string parameter, which is more closely aligned with how we deal with post content within Tumblr's official clients.

@thagxt
Copy link
Author

thagxt commented Jul 24, 2020

Thank you for your answer @cyle! I've tried and it works with npf=true.
I think you should state that in the docs, it's not really clear.

@cyle
Copy link
Member

cyle commented Jul 24, 2020

I think you should state that in the docs, it's not really clear.

Sure, happy to try to make this clearer. I'll see what I can do. 👌

@thagxt thagxt closed this as completed Jul 26, 2020
@cyle
Copy link
Member

cyle commented Jul 27, 2020

Updated the docs with some blurbs about this, FYI ba6c02e

charlesbullsd pushed a commit to charlesbullsd/tumblr_docs that referenced this issue Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants