chrisscartier
chrisscartier

Reputation: 101

Twitter API.get_user() TypeError: takes 1 positional argument but 2 were given ​

I'm still really new to coding and currently taking courses online, in which we are beginning to work with the Twitter API. I am trying to capture the ID of a Twitter account and display it below, but I keep getting this TypeError and can't figure out for the life of me how to fix it. Any help would be appreciated, thanks. My Code

Upvotes: 10

Views: 11078

Answers (2)

Luis Costa Brochado
Luis Costa Brochado

Reputation: 151

Follow the official documentation on tweepy. Please display code instead of images.

You can use:

api = tweepy.API(auth)
user = api.get_user(screen_name='dak')

print(user.id)

Upvotes: 15

Harmon758
Harmon758

Reputation: 5157

Tweepy v4.0.0 changed API.get_user to not accept any positional arguments.
The 1 positional argument being referred to in the error is self.
You can pass 'dak' as the screen_name keyword argument instead.

Upvotes: 11

Related Questions