ID Unpacking
Instead of passing raw ID strings to parameters, you can pass the entire dictionary object representing the entity. Mastodon.py will automatically extract the id field.
# Instead of this:
api.status_post("Hello!", in_reply_to_id=toot['id'])
# You can do this:
api.status_post("Hello!", in_reply_to_id=toot)
Snowflake IDs
On Mastodon and its forks, status IDs are Snowflake IDs, which correspond to timestamps. You can pass a datetime object directly as an ID parameter, and Mastodon.py will convert it to a Snowflake ID for you. This allows you to search for posts between specific dates.
Note: This is not compatible with non-Mastodon servers like Pleroma or Misskey.
import datetime
# Searching for posts using a datetime object (Snowflake conversion)
api.statuses_search(since_id=datetime.datetime(2023, 1, 1))