Tweepy User object structure

I’m working on a Python app that uses the Tweepy API.  The docs aren’t entirely thorough so I thought I’d put this out there for anyone who needed it like I did.

So for example, you have the below

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

api = tweepy.API(auth)
other_user = api.get_user(user_name)
my_info = api.me()

other_user now has this structure…

User(time_zone='Eastern Time (US & Canada)' has_extended_profile=False, 
	profile_sidebar_fill_color='C5CEC0', 
	profile_use_background_image=True, 
 	listed_count=42774, 
 	profile_banner_url='https://xxxx', 
 	_api=<tweepy.api.API object at 0x105a23a58>, 
 	notifications=False, 
 	profile_background_image_url_https='https://xxxx', 
 	statuses_count=###, 
 	default_profile_image=False, 
 	status=Status(retweet_count=###, 
 	contributors=None, 
 	in_reply_to_user_id=None, 
 	source='Twitter for -----', 
 	in_reply_to_status_id=None, 
 	favorited=False, 
 	in_reply_to_screen_name=None, 
 	id=########, 
 	text='blah blah', 
	place=None, 
 	is_quote_status=False, 
 	truncated=False, 
 	source_url='http://twitter.com/download/xxxxx', 
 	favorite_count=#####, 
 	retweeted=False, 
 	lang='en', 
 	_api=<tweepy.api.API object at 0x105a23a58>, 
 	in_reply_to_user_id_str=None, 
 	created_at=datetime.datetime(year, month, day, hour, minute, second), 
 	coordinates=None, 
 	id_str='#######', 
 	_json={'entities': {'urls': [], 
 			'hashtags': [], 
 			'symbols': [], 
 			'user_mentions': []}, 
 		'id_str': '#######', 
 		'retweet_count': #####, 
 		'in_reply_to_user_id': None, 
 		'source': '<a href="http://twitter.com/download/android" rel="nofollow">Twitter for Android</a>', 
 		'in_reply_to_status_id': None, 
 		'favorited': False, 
 		'geo': None, 
 		'place': None, 
 		'favorite_count': #####, 
 		'truncated': False, 
 		'in_reply_to_screen_name': None, 
 		'id': #######, 
 		'retweeted': False, 
 		'lang': 'en', 
 		'in_reply_to_user_id_str': None, 
 		'text': 'blah blah', 
 		'created_at': 'Fri Sep 21 13:42:44 +0000 2013', 
 		'coordinates': None, 
 		'in_reply_to_status_id_str': None, 
 		'is_quote_status': False, 
 		'contributors': None}, 
 	entities={'urls': [], 
 		'hashtags': [], 
 		'symbols': [], 
 		'user_mentions': []}, 
 	geo=None, 
 	in_reply_to_status_id_str=None), 
 	created_at=datetime.datetime(year, month, day, hour, minute, second), 
 	id=#######, 
 	location='xxxx', 
 	screen_name='xxxx', 
 	followers_count=####, 
 	translator_type='none', 
 	default_profile=False, 
 	profile_sidebar_border_color='BDDCAD', 
 	_json={'time_zone': 'Eastern Time (US & Canada)', 
 		'lang': 'en', 
 		'has_extended_profile': False, 
 		'profile_sidebar_fill_color': 'C5CEC0', 
 		'profile_use_background_image': True, 
 		'listed_count': #####, 
 		'profile_banner_url': 'https://xxxx', 
 		'notifications': False, 
 		'profile_background_image_url_https': 'https://xxxx', 
 		'statuses_count': #####, 
 		'followers_count': #####, 
 		'is_translator': False, 
 		'translator_type': 'none', 
 		'id': #######, 
 		'location': 'xxxx', 
 		'screen_name': 'xxxx', 
 		'default_profile_image': False, 
 		'created_at': 'day_abbreviation month date hour:minute:second +time_zone_offset year', 
 		'default_profile': False, 
 		'profile_sidebar_border_color': 'BDDCAD', 
 		'entities': {'description': {'urls': []}, 
 			'url': {'urls': [{'expanded_url': 'http://www.xxxx.com', 
 					'indices': [0, 23], 
 					'url': 'https://xxxx', 
 					'display_url': 'xxxx.com'}]}}, 
 		'protected': False, 
 		'profile_image_url': 'xxxx', 
 		'geo_enabled': True, 
 		'url': 'https://xxxx', 
 		'name': 'xxxx', 
 		'profile_image_url_https': 'xxxx', 
 		'utc_offset': -18000, 
 		'profile_link_color': '0D5B73', 
 		'following': False, 
 		'status': {'entities': {'urls': [], 
 				'hashtags': [], 
 				'symbols': [], 
 				'user_mentions': []}, 
			'id_str': '#######', 
 			'retweet_count': 24493, 
 			'in_reply_to_user_id': None, 
 			'source': '<a href="http://twitter.com/download/android" rel="nofollow">Twitter for Android</a>', 
 			'in_reply_to_status_id': None, 
 			'favorited': False, 
 			'geo': None, 
 			'place': None, 
 			'favorite_count': #####, 
 			'truncated': False, 
 			'in_reply_to_screen_name': None, 
 			'id': #######, 
 			'retweeted': False, 
 			'lang': 'en', 
 			'in_reply_to_user_id_str': None, 
 			'text': 'blah blah', 
			'created_at': 'day_abbreviation month date hour:minute:second +time_zone_offset year', 
 			'coordinates': None, 
 			'in_reply_to_status_id_str': None, 
 			'is_quote_status': False, 
 			'contributors': None}, 
 		'friends_count': ##, 
 		'profile_background_image_url': 'http://xxxx', 
 		'profile_background_tile': True, 
 		'id_str': '#####', 
 		'is_translation_enabled': True, 
 		'profile_text_color': '333333', 
 		'profile_location': None, 
 		'profile_background_color': '6D5C18', 
 		'verified': True, 
 		'follow_request_sent': False, 
 		'description': 'blah blah', 
 		'favourites_count': ##, 
 		'contributors_enabled': False}, 
 	entities={'description': {'urls': []}, 
 			'url': {'urls': [{'expanded_url': 'http://www.xxxx.com', 
 						'indices': [0, 23], 
 						'url': 'https://xxxx', 
 						'display_url': 'xxxx.com'}]}}, 
 	protected=False, 
 	profile_image_url='xxxx', 
 	geo_enabled=True, 
 	url='https://xxxx', 
 	name='xxxx', 
 	profile_image_url_https='xxxx', 
 	utc_offset=-18000, 
 	following=False, 
 	profile_link_color='0D5B73', 
 	profile_background_image_url='http://xxxx', 
 	is_translator=False, 
 	friends_count=##, 
 	profile_background_tile=True, 
 	id_str='#######', 
 	is_translation_enabled=True, 
 	profile_text_color='333333', 
 	profile_location=None, 
 	profile_background_color='6D5C18', 
 	lang='en', 
 	follow_request_sent=False, 
 	description='blah blah', 
 	verified=True, 
 	favourites_count=##, 
 	contributors_enabled=False)

(I manually indented these so *fingers crossed* that it’s correct)

and my_info has this structure…

User(default_profile=True,
 	translator_type='none',
 	entities={'description': {'urls': []}},
 	_api=<tweepy.api.API object at 0x1058eea90>,
 	contributors_enabled=False,
 	profile_background_color='F5F8FA',
 	has_extended_profile=False,
 	profile_background_tile=False,
 	is_translator=False,
 	description='',
 	geo_enabled=False,
 	statuses_count=0,
 	location='',
 	screen_name='xxxx',
 	protected=False,
 	lang='en',
 	_json={'default_profile': True,
 		'translator_type': 'none',
 		'entities': {'description': {'urls': []}},
 		'contributors_enabled': False,
 		'profile_background_color': 'F5F8FA',
 		'has_extended_profile': False,
 		'profile_background_tile': False,
 		'is_translator': False,
 		'description': '',
 		'geo_enabled': False,
 		'statuses_count': 0,
 		'location': '',
 		'screen_name': 'xxxx',
 		'protected': False,
 		'suspended': False,
 		'profile_background_image_url': None,
 		'profile_sidebar_fill_color': 'DDEEF6',
 		'default_profile_image': True,
 		'profile_link_color': '1DA1F2',
 		'lang': 'en',
 		'url': None,
 		'follow_request_sent': False,
 		'favourites_count': 0,
 		'profile_image_url': 'http://xxxx',
 		'following': False,
 		'listed_count': 0,
 		'needs_phone_verification': False,
 		'profile_sidebar_border_color': 'C0DEED',
 		'is_translation_enabled': False,
 		'followers_count': 0,
 		'verified': False,
 		'id': #######,
 		'profile_text_color': '333333',
 		'profile_location': None,
 		'created_at': 'Sun Nov 06 23:34:12 +0000 2016',
 		'notifications': False,
 		'profile_use_background_image': True,
 		'profile_background_image_url_https': None,
 		'friends_count': 0,
 		'time_zone': None,
 		'profile_image_url_https': 'https://xxxx',
 		'id_str': '#######',
 		'name': 'xxxx',
 		'utc_offset': None},
 	profile_background_image_url=None,
 	profile_sidebar_fill_color='DDEEF6',
 	default_profile_image=True,
 	profile_link_color='1DA1F2',
 	suspended=False,
 	url=None,
 	follow_request_sent=False,
 	favourites_count=0,
 	profile_image_url='http://xxxx',
 	following=False,
 	listed_count=0,
 	needs_phone_verification=False,
 	profile_sidebar_border_color='C0DEED',
 	is_translation_enabled=False,
 	followers_count=0,
 	verified=False,
 	id=#######,
 	profile_text_color='333333',
 	profile_location=None,
 	created_at=datetime.datetime(2012, 4, 3, 23, 34, 12),
 	notifications=False,
 	profile_use_background_image=True,
 	profile_background_image_url_https=None,
 	friends_count=0,
 	time_zone=None,
 	profile_image_url_https='https://xxxx',
 	id_str='#######',
 	name='xxxx',
 	utc_offset=None)

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Post Navigation