1

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,753
  • 72
  • 57
  • 129
Rick Dearman
  • 356
  • 2
  • 12
  • Could you include `myid` if possible? Also, a sample of `followed_by` or `following` would be nice. Have you tried on another user's id? – doneforaiur Aug 06 '23 at 09:47

1 Answers1

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.

Rick Dearman
  • 356
  • 2
  • 12