Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tweepy error 'API' object has no attribute 'me'

Tags:

python

tweepy

I am trying to run the code from https://github.com/CreepyD246/Twitter-Reply-Bot/blob/main/TwitterReplyBot.py on Replit.

#Importing modules/libraries
import tweepy
import time
import os

# Initialization code
auth = tweepy.OAuthHandler(os.getenv("key2"),os.getenv("skey2"))
auth.set_access_token(os.getenv("token2"),os.getenv("stoken2"))
api = tweepy.API(auth)

# Some important variables which will be used later
bot_id = int(api.me().id_str)
#Other things after

But I get this error:

Traceback (most recent call last):
File "main.py", line 12, in <module>
bot_id = int(api.me().id_str)
AttributeError: 'API' object has no attribute 'me'

I don't find anything in the Tweepy's documentation about API.me() so what's wrong? The Tweepy version is 4.1.0.

like image 761
Larwive Avatar asked Oct 27 '25 18:10

Larwive


1 Answers

Tweepy v4.0.0 removed API.me. You can use API.verify_credentials instead.

like image 153
Harmon758 Avatar answered Oct 29 '25 08:10

Harmon758



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!