'How to tell a user is verified using Tweepy, Python

Given a user ID, I'd like to know whether they're a verified (blue check) Twitter user. I don't see anything in the documentation.. Is there any strategy I can use? For example:

import tweepy

consumer_key = '...'
consumer_secret = '...'
access_token = '...'
access_token_secret = '...'
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)

ezra = api.get_user('ezraklein')
ezra.is_verified() ???

With the method returning True, as 'ezraklein' is a verified user?



Solution 1:[1]

The tweepy documentation is a bit lacking, but, inspecting the source, you can clearly see that this property is parsed from the API JSON response.

Watch out, this is an attribute, not a method, so you have to check without parenthesis.

>>> user = api.get_user("BarackObama")
>>> user.verified
True

EDIT: Updated the source link, fixing latest commit - aa3658e at time of writing.

Solution 2:[2]

Hoping to help other people with this, but it's a simple ezra.verified() or ezra.verified. I don't know what python version you're using.

You may have to use a str(...) because it's a bool.

the output for a verified user will be True

the output for a nonverified user will be False

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Watz