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
1 2 3 4 5 6 |
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…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
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…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
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) |