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

Viewed 2690

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.

3 Answers

Tweepy v4.0.0 removed API.me use API.get_user That is the replacement for now

yes api.get_user is the replacement in tweepy v4.0.0

Related