-
Notifications
You must be signed in to change notification settings - Fork 29
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
How to paginate /tagged responses? #131
Comments
I think you're supposed to use
Edit: Yep, seems to work fine on both "PhotoToaster" and "gif": (async () => {
let lastTimestamp;
let url = `https://api.tumblr.com/v2/tagged?tag=PhotoToaster&api_key=[removed]`;
for (let i = 0; i < 3; i++) {
const response = await fetch(url).then((response) => response.json());
console.log(response.response.map(({ id, timestamp, post_url }) => `${id} ${timestamp} ${post_url}`));
const lastPost = response.response.at(-1);
lastTimestamp = lastPost.featured_timestamp || lastPost.timestamp;
url = `https://api.tumblr.com/v2/tagged?tag=PhotoToaster&before=${lastTimestamp}&api_key=[removed]`;
}
})(); |
The docs say the following
|
I am getting this for the first 10 responses for "PhotoToaster":
The only obvious difference in my approach compared to yours is I'm using OAuth2 rather than an ApiKey. |
Yeah, moon6969 mentioned |
Yes, in addition to those fields there should be a |
Isn't the date field just the timestamp converted to GMT? |
Sure, but the integer form is what you can use to paginate. Are you seeing |
I'm getting the full post object and using the timestamp for 'before' parameter. Are you getting the same 'PhotoToaster' post IDs as me (below)? Further testing has revealed 3 confusing behaviours with the 'tagged' results... 1. The timestamps are not in orderSo it's not certain that the timestamp of the last post returned in a batch is in fact higher than all remaining posts in the query.
2. Using the 'limit' parameter returns a different set of resultsWhy does the same query as above with "limit=5" not return the same first 5 posts?
This also shows the issue if the timestamps are not in order. 3. Why does tagged not consistently return 20 records?With no limit specified, the number of posts returned from each 'before' call return trails off |
Please how do I paginate the results returned from api.tumblr.com/v2/tagged?
v2/tagged endpoint response is limited to 20 posts.
v2/tagged endpoint does not support 'offset' parameter and does not appear to support a sort parameter.
The responses returned from v2/tagged endpoint appear to be in 'id' order rather than 'timestamp' order, so the 'before' parameter is not useful.
None of the results returned (for the tag 'PhotoToaster' I am testing with) contain 'featured_timestamp' field.
Thanks.
The text was updated successfully, but these errors were encountered: