I am trying to get a list of people I follow, and a lost of people I am followed by, but the functions give the same number?
myid = mastodon.account_verify_credentials()["id"]
followed_by = mastodon.account_followers(myid) #Fetch users the given user is followed by.
following = mastodon.account_following(myid) # Fetch users the given user is following.
binoff = []
print ("followed_by={}, following={}, binoff={}".format(len(followed_by),len(following),len(binoff)))
The result is:
followed_by=40, following=40, binoff=0
followed_by=40, following=40, binoff=40
Where have I gone wrong
Brian Tompsett - 汤莱恩
5,92772 gold badges64 silver badges135 bronze badges
asked Aug 6, 2023 at 9:02
Rick Dearman
3864 silver badges15 bronze badges
1 Answer 1
I discovered the problem. The issue is that there is a rate limit (pagination parameters) on the API. So it only gave me the first 40 accounts. To get the remainder you need to do add the lines:
followed_by = mastodon.fetch_remaining(followed_by)
following = mastodon.fetch_remaining(following)
So the API will pull the remaining accounts for you.
answered Aug 6, 2023 at 12:02
Rick Dearman
3864 silver badges15 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py
myidif possible? Also, a sample offollowed_byorfollowingwould be nice. Have you tried on another user's id?