Profile_location field is missing on GET users/lookup requests


#1

The responses I’m getting from requests to GET users/lookup endpoint are missing the profile_location field.
For a single user, I can query GET users/show endpoint and then the response does include the field. Unluckly, using this second endpoint is not an option in my project.

Here you can see an example for both endpoints using a same screen name. Location info only appears in second one : (

GET users/lookup.json?screen_name=87ydh&include_entities=true

[{u'contributors_enabled': False,
  u'created_at': u'Fri Jun 23 12:33:04 +0000 2017',
  u'default_profile': False,
  u'default_profile_image': True,
  u'description': u'Yoo Deok-ho, \u5ebe\u5fb7\u93ac',
  u'entities': {u'description': {u'urls': []},
   u'url': {u'urls': [{u'display_url': u'instagram.com/87ydh/',
      u'expanded_url': u'https://www.instagram.com/87ydh/',
      u'indices': [0, 23],
      u'url': u'https://t.co/KOgFAcjUf4'}]}},
  u'favourites_count': 84,
  u'follow_request_sent': False,
  u'followers_count': 1,
  u'following': False,
  u'friends_count': 29,
  u'geo_enabled': False,
  u'has_extended_profile': True,
  u'id': 878229418266603521,
  u'id_str': u'878229418266603521',
  u'is_translation_enabled': False,
  u'is_translator': False,
  u'lang': u'ko',
  u'listed_count': 0,
  u'location': u'Republic of Korea',
  u'name': u'\uc720\ub355\ud638',
  u'notifications': False,
  u'profile_background_color': u'000000',
  u'profile_background_image_url': u'http://abs.twimg.com/images/themes/theme1/bg.png',
  u'profile_background_image_url_https': u'https://abs.twimg.com/images/themes/theme1/bg.png',
  u'profile_background_tile': False,
  u'profile_image_url': u'http://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png',
  u'profile_image_url_https': u'https://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png',
  u'profile_link_color': u'1B95E0',
  u'profile_sidebar_border_color': u'000000',
  u'profile_sidebar_fill_color': u'000000',
  u'profile_text_color': u'000000',
  u'profile_use_background_image': False,
  u'protected': True,
  u'screen_name': u'87ydh',
  u'statuses_count': 0,
  u'time_zone': u'Seoul',
  u'translator_type': u'none',
  u'url': u'https://t.co/KOgFAcjUf4',
  u'utc_offset': 32400,
  u'verified': False}]
GET users/show.json?screen_name=87ydh
{u'contributors_enabled': False,
 u'created_at': u'Fri Jun 23 12:33:04 +0000 2017',
 u'default_profile': False,
 u'default_profile_image': True,
 u'description': u'Yoo Deok-ho, \u5ebe\u5fb7\u93ac',
 u'entities': {u'description': {u'urls': []},
  u'url': {u'urls': [{u'display_url': u'instagram.com/87ydh/',
     u'expanded_url': u'https://www.instagram.com/87ydh/',
     u'indices': [0, 23],
     u'url': u'https://t.co/KOgFAcjUf4'}]}},
 u'favourites_count': 84,
 u'follow_request_sent': False,
 u'followers_count': 1,
 u'following': False,
 u'friends_count': 29,
 u'geo_enabled': False,
 u'has_extended_profile': True,
 u'id': 878229418266603521,
 u'id_str': u'878229418266603521',
 u'is_translation_enabled': False,
 u'is_translator': False,
 u'lang': u'ko',
 u'listed_count': 0,
 u'location': u'Republic of Korea',
 u'name': u'\uc720\ub355\ud638',
 u'notifications': False,
 u'profile_background_color': u'000000',
 u'profile_background_image_url': u'http://abs.twimg.com/images/themes/theme1/bg.png',
 u'profile_background_image_url_https': u'https://abs.twimg.com/images/themes/theme1/bg.png',
 u'profile_background_tile': False,
 u'profile_image_url': u'http://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png',
 u'profile_image_url_https': u'https://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png',
 u'profile_link_color': u'1B95E0',
 u'profile_location': {u'attributes': {},
  u'bounding_box': None,
  u'contained_within': [],
  u'country': u'',
  u'country_code': u'',
  u'full_name': u'Republic of Korea',
  u'id': u'c00e5392b3fa46fb',
  u'name': u'Republic of Korea',
  u'place_type': u'unknown',
  u'url': u'https://api.twitter.com/1.1/geo/id/c00e5392b3fa46fb.json'},
 u'profile_sidebar_border_color': u'000000',
 u'profile_sidebar_fill_color': u'000000',
 u'profile_text_color': u'000000',
 u'profile_use_background_image': False,
 u'protected': True,
 u'screen_name': u'87ydh',
 u'statuses_count': 0,
 u'time_zone': u'Seoul',
 u'translator_type': u'none',
 u'url': u'https://t.co/KOgFAcjUf4',
 u'utc_offset': 32400,
 u'verified': False}

#2

I’ve been experiencing a weird behaviour with GET users/show endpoint. Running 100 requests for a same user id returned about a 20% of responses missing profile_location info.


#3

Hi @jmartinter, thanks for the questions on this. I can tell you I learned some things myself from looking into this one! :man_student:

I agree it may seem strange to see a different result fron users/lookup, but this is a performance optimisation. The endpoint supports bulk lookups, and the profile location data is hydrated into the user object via an additional internal call, so you can imagine if you are (for example) requesting 100 user IDs in a single call, that would potentially double the amount of load on the systems depending on whether a profile location was set for the individual users. I’ll make sure that we get this clarified in our documentation for the endpoints to reduce the chances of future confusion.

Your more recent post is a little less easy to respond to, but in cases like that where the response are sometimes slightly different, it could be a case of the additional call to fetch the profile data failing or timing out due to load internally and then silently dropped from the response. Alternatively, your calls may be routed to different data centers where the data is temporarily not available (the standard APIs are eventually consistent, but may sometimes have small discrepancies like this).