I'm now working on a web application which is mostly based of facebook graph api. I hold some data about users - actually , the possible public data available - such as name and id. I also know that a profile picture is a part of the public data, and I wondered how I'll be able to get a direct link to a profile picture of a user only by using their id?
-
Possible duplicate of [Facebook API - How do I get a Facebook user's profile image through the Facebook API (without requiring the user to "Allow" the application)](http://stackoverflow.com/questions/2821061/facebook-api-how-do-i-get-a-facebook-users-profile-image-through-the-facebook) – Ciro Santilli OurBigBook.com May 26 '16 at 08:22
16 Answers
http://graph.facebook.com/" + facebookId + "/picture?type=square For instance: http://graph.facebook.com/67563683055/picture?type=square
There are also more sizes besides "square". See the docs.
Update September 2020
As Facebook have updated their docs this method is not working anymore without a token. You need to append some kind of access_token
. You can find further information and how to do it correctly in the fb docs to the graph api of user picture
Requirements Change This endpoint supports App-Scoped User IDs (ASID), User IDs (UID), and Page-Scoped User IDs (PSID). Currently you can query ASIDs and UIDs with no requirements. However, beginning October 24, 2020, an access token will be required for all UID-based queries. If you query a UID and thus must include a token:
use a User access token for Facebook Login authenticated requests
use a Page access token for page-scoped requests
use an App access token for server-side requests
use a Client access token for mobile or web client-side requests
Quote of fb docs

- 3,492
- 2
- 22
- 24

- 3,703
- 1
- 18
- 11
-
31For anyone wanting the link to the docs: https://developers.facebook.com/docs/graph-api/reference/user/picture/ – Frankie Jarrett Feb 15 '14 at 23:31
-
33Best to look at the docs because they have all the other options too. For example, if you want a large, square image (since the square default is small), you have to use `https://graph.facebook.com/{facebookId}/picture?type=large&width=720&height=720`. – sudo Jul 28 '14 at 17:29
-
2is there a way to just query for the image url not the image itself? Would like to upload the image on the front-end not through the server if possible – Alexander Mills Feb 20 '16 at 22:30
-
4use redirect=0 to get JSON description (incl. url) instead of image itself – Ilya Denisov Dec 12 '16 at 15:01
-
current alternatives to `square` are `small, normal, album, large, square`. and no it doesn't describe what they are - and yes they are all square! – Simon_Weaver Jan 03 '18 at 04:50
-
What if it is a private profile e.g. not accessible from public? It returns null? – ninbit Aug 09 '18 at 12:35
-
That link returns the *cover photo* not the profile picture, at least for my and some of my friends' accounts. What am I doing wrong? Edit: I was using the wrong `fbid` – Marcello Romani Sep 15 '20 at 15:36
-
1Update for September 2020: You need to pass some kind of token now to get the picture. More infos on fb docs: https://developers.facebook.com/docs/graph-api/reference/user/picture/ – Gkiokan Oct 13 '20 at 08:52
-
1@Gkiokan I read all facebook docs and couldn't find out how to get back the profile image, where do I need to attach this token? Funny thing, I see stack overflow didn't get the memo as well, my profile picture here is gone lol.. – Offir Oct 23 '20 at 21:11
-
@Gkiokan https://stackoverflow.com/questions/64434913/facebook-profile-images-api-access-deactivated-to-reactivate-go-to-the-app-d – Offir Oct 23 '20 at 21:14
-
Here is an an example of how I did it in PHP for Laravel: https://stackoverflow.com/questions/64434913/get-facebook-user-profile-image-after-facebook-changesoctober-24/64507817#64507817 – Gkiokan Oct 23 '20 at 22:06
-
works great - anyone wondering how to get a facebook id can use this tool - https://findmyfbid.in – user2475624 Dec 28 '20 at 07:20
-
-
@dim Turned out that the FB account must "allow" the FB app first then you should be able to fetch the profile picture with FB app access token – UserProg Jul 02 '21 at 03:27
-
since the link doesn't lead anywhere now, is there another link or a new update on how to get the profile_pic or how to get the needed access token ? the response from the api always says I need a Page Access Token !! – Omar Shawky Sep 17 '21 at 21:23
You can use following urls to obtain different sizes of profile images. Please make sure to add Facebook id to url.
Large size photo https://graph.facebook.com/{facebookId}/picture?type=large
Medium size photo https://graph.facebook.com/{facebookId}/picture?type=normal
Small size photo https://graph.facebook.com/{facebookId}/picture?type=small
Square photo https://graph.facebook.com/{facebookId}/picture?type=square

- 2,088
- 1
- 19
- 18
-
3This was how I was able to discover my own FacebookId: https://developers.facebook.com/tools/explorer/?method=GET&path=me%3Ffields%3Did%2Cname&version=v2.5 – Ryan Dec 11 '15 at 07:23
To get largest size of the image
https://graph.facebook.com/{userID}?fields=picture.width(720).height(720)
or anything else you need as size. Based on experience, type=large is not the largest result you can obtain.

- 496
- 6
- 9
-
1also can pass : https://graph.facebook.com/{userID}?fields=picture.type(large) this is useful when you have something like this, String url = "https://graph.facebook.com/me?fields=id,name,email,picture.type(large) as mentioned in other answers you can replace large with normal,small,square... – yajnesh Dec 16 '15 at 11:47
-
1
From the Graph API documentation.
/OBJECT_ID/picture
returns a redirect to the object's picture (in this case the users)/OBJECT_ID/?fields=picture
returns the picture's URL
Examples:
<img src="https://graph.facebook.com/4/picture"/>
uses a HTTP 301 redirect to Zuck's profile picture
https://graph.facebook.com/4?fields=picture
returns the URL itself

- 43,710
- 8
- 89
- 115
-
1Alas, it's no longer on the homepage of the Graph API docs, it's now here: https://developers.facebook.com/docs/graph-api/using-graph-api – Igy Jan 16 '14 at 05:24
-
4*NO*, it's not on the frontpage of the Graph API documentation. You'd better avoid time-constraint statements on SO. You know.. things change quite fast those days... – Gianluca Ghettini Dec 13 '15 at 10:02
-
and ironically your answer is much more useful with more relevant info than the graph api page anyway :-) – Simon_Weaver Jan 03 '18 at 04:47
This will be helpful link:
http://graph.facebook.com/893914824028397/picture?type=large&redirect=true&width=500&height=500
You can set height and width as you needed
893914824028397 is facebookid
UPDATE September 2020
Facebook has new requirements change: an access token will be required for all UID-based queries
So you have to add your app access token to the url:
https://graph.facebook.com/{profile_id}/picture?type=large&access_token={app_access_token}
To get your app_access_token
use the following url:
https://graph.facebook.com/oauth/access_token?client_id={your-app-id}&client_secret={your-app-secret}&grant_type=client_credentials
You find your-app-id
and your-app-secret
in the Basic Settings of your Facebook app in Facebook developers

- 2,051
- 3
- 22
- 46
-
Hey, is there some library for this in react yet? Seems like "react-avatar" package is not yet supporting this – TechCrap Oct 08 '20 at 14:38
-
It's an API that returns the profile image when given a username for a variety of social networks including Twitter, Facebook, Instagram, and gravatar. It has libraries for iOS, Android, Ruby, Node, PHP, Python, and JavaScript.

- 170
- 5
- 14
-
1That really is fantastic! Just because SO likes links to be described in a bit more detail; it's an API that returns the profile image when given a username for a variety of social networks including Twitter, Facebook, Instagram, and gravatar. It has libraries for iOS, Android, Ruby, Node, PHP, Python, and JavaScript. An exceptional piece of software. It can be found [on GitHub](https://github.com/chute/avatars-io). – Ari Cooper-Davis May 17 '17 at 17:07
-
1
you can get it with using this url : you will get the picture HD (max size)
https://graph.facebook.com/{userID}?fields=picture.width(720).height(720)&redirect=false
don't forget redirect=false or it will return an error

- 107
- 12
Use url as:https://graph.facebook.com/user_id/picture?type=square in src of img tag. type may be small,large.

- 1,326
- 8
- 14
You can use AngularJs for this, Its two -way data binding feature will get solution with minimum effort and less code.
<div>
<input type="text" name="" ng-model="fbid"><br/>
<img src="https://graph.facebook.com/{{fbid}}/picture?type=normal">
</div>
I hope this answers your query.Note: You can use other library as well.

- 21
- 1
Through the Javascript SDK (v2.12 - April, 2017) you can get the details of the picture request this way:
FB.api("/" + uid + "/picture?redirect=0", function (response) {
console.log(response);
// prints the following:
//data: {
// height: 50
// is_silhouette: false
// url: "https://lookaside.facebook.com/platform/profilepic/?asid=…&height=50&width=50&ext=…&hash…"
// width: 50
//}
if (response && !response.error) {
// change the src attribute of img elements
[...document.getElementsByClassName('fb-user-img')].forEach(
i => i.src = response.data.url
);
// OR redirect to the URL above
location.assign(response.data.url);
}
});
For getting the JSON response the parameter redirect
with 0 (zero) as value is important since the request redirects to the image by default. You may still add other parameters in the same URL. Examples:
"/" + uid + "/picture?redirect=0&width=100&height=100"
: a 100x100 image will be returned;"/" + uid + "/picture?redirect=0&type=large"
: a 200x200 image is returned. Other possible type values include: small, normal, album, and square.

- 12,379
- 5
- 59
- 71
As per the current latest Facebook API version 3.2, For users you can use this generic method for getting profile picture is https://graph.facebook.com/v3.2/{user-id}/picture?type=square you can visit documentation for user picture here. The possible values for type parameter in URL can be small, normal, album, large, square
For Groups and Pages, the profile picture is not available directly. You have to get them using access token. For Groups you have to use User Access Token and for Pages you can use both User Access Token and Page Access Token.
You can get Group's or Page's Profile Picture using the generic URL: https://graph.facebook.com/v3.2/{user-id}/picture?access_token={access-token}&type=square
I hope this is helpful for people who are looking for Page or Group Profile picture.

- 31
- 4
-
For most of the pages, I am getting the pages profile picture without access-token but for some pages it's returning a question mark image as response in below format. { "data": { "is_silhouette": true, "url": "https://static.xx.fbcdn.net/rsrc.php/v3/y6/r/_xS7LcbxKS4.gif" } } Any Clue ? – xyz Nov 21 '19 at 14:44
Simply Follow as below URL
https://graph.facebook.com/facebook_user_id/picture?type=square
type may be normal,small,medium,large. Or square (f you want to get square picture, the square size is limited to 50x50).

- 2,117
- 75
- 29
- 42

- 991
- 4
- 12
-
2If you want to get square picture.The square size is limited to 50x50. – Rahul Gupta Oct 29 '18 at 08:36
-
For more detail follow Facebook Graph API https://developers.facebook.com/docs/graph-api/reference/v3.2/user/picture – Rahul Gupta Oct 30 '18 at 04:51
today I found a problem, the profile images was returning the default profile picture because a new requirement from Facebook to all the UID based queries, so just add &access_token=[apptoken]
to the url, you can obtain your app token from here

- 764
- 8
- 19
You can use the following endpoint to get the image.jfif instead of jpg:
https://graph.facebook.com/v3.2/{user-id}/picture
Note that you won't be able to see the image, only download it.

- 239,200
- 50
- 490
- 574

- 27
- 3
Update July 2021
On top of answer by @EddyG, turned out that if you still not able to fetch the profile picture with app access token, the FB account must "allow" the FB app first then you should be able to fetch the profile picture with FB app access token.

- 629
- 1
- 8
- 22