halcy / Mastodon.py

Python wrapper for the Mastodon ( https://github.com/mastodon/mastodon/ ) API.
MIT License
867 stars 150 forks source link

max_id does not work? #335

Closed shamiv closed 1 year ago

shamiv commented 1 year ago

The code below prints the same id twice. It seems like max_id does not work?

from datetime import datetime, timedelta
from mastodon import Mastodon

#  Set up access
instance = "xxxxxxxxxxxxxxxx"
mastodon = Mastodon(api_base_url=instance, access_token="xxxxxxxxxxxxxxxxx" )

favourites = mastodon.favourites(limit=20)
last_id=favourites[-1]['id']
print(last_id)
favourites = mastodon.favourites(limit=20,max_id=last_id)
last_id=favourites[-1]['id']
print(last_id)
codl commented 1 year ago

Mastodon.favourites's max_id, min_id, and since_id parameters do not expect status ids but internal favourite ids, which are not available through the api. You should not be passing those yourself, you should use the pagination function Mastodon.fetch_next instead https://mastodonpy.readthedocs.io/en/stable/12_utilities.html#mastodon.Mastodon.fetch_next