6

Is there a a predictable url to retrieve a user's profile images either by username or id?

...similar to google or facebook:

"https://graph.facebook.com/#{FACEBOOK ID}/picture"
"https://profiles.google.com/s2/photos/profile/#{GOOGLE ID}"

I found this https://dev.twitter.com/docs/user-profile-images-and-banners but it looks like I'll have to do a whole separate request just to get the profile image.

jwerre
  • 9,179
  • 9
  • 60
  • 69

2 Answers2

10

A predictable URL similar to Facebook or Google to retrieve a user's profile images by username is as follows:

"https://twitter.com/[screen_name]/profile_image?size=original"

For example

"https://twitter.com/sqlpowershell/profile_image?size=original"

Other sizes include

  • mini - 24x24 px
  • normal - 48x48
  • bigger - 73x73

Totally relieved not to have to use the API!

Community
  • 1
  • 1
Chrissy LeMaire
  • 1,367
  • 12
  • 14
  • This method will not work on mobile devices and screen sizez. Twitter wont allow images to be served to a mobile device. In order to do this you must use the api. – Verty00 Mar 27 '18 at 01:06
2

Before we were able to access the the user's profile image without authentication using the twitter version 1 api.

Now that this has been deprecated, we much use /1.1/users/show.json to pull the profile image with authentication information.

maiko
  • 405
  • 1
  • 4
  • 15
  • Ya, I saw this but it's not good since it requires two requests (show.json and image) as apposed to the Facebook and Goggle method which only requires one. Not to mention the extra callback and code you have to write to get the image url our of the json. – jwerre Dec 09 '13 at 19:29
  • I agree it's an unnecessary pain. Save's twitter lot's of money, I bet. ... This is hacky, and I don't know about your backend, but if in php or any other capable backend language you can grab the html of the page and parse it with (Simple HTML DOM Parser for example) for the class 'profile-picture media-thumbnail' which contains the image and return it to wherever you're sending it. – maiko Feb 22 '14 at 23:57