Graph API Version

Location

Represents a location.

Reading

Get information about a location.

Requirements

The Page Public Content Access feature is required to scrape the LocationNode data of public pages.

Sample Request

curl -i -X GET \
 "https://graph.facebook.com/{graph-api-version}/{location-id}&access_token={user-access-token}"

Sample Response

{
  "name": "{city}, {state}",
  "id": "{location-id}"
}

Get User Location Information

Requirements

The user_location permission is required.

Sample Request

curl -i -X GET \
  "https://graph.facebook.com/{graph-api-version}/{user-id}?    
    fields=location{location{city,state,region_id}}&access_token={user-access-token}"

Sample Response

{
  "location": {
    "location": {
      "city": "San Jose",
      "state": "CA",
      "region_id": 3847
    },
    "id": "111948542155151"   //location-id
  },
  "id": "{user-id}"
}

Get Page Location Information

Requirements

The manage_pages permission is required.

Sample code of a Page location
curl -i -X GET \
 "https://graph.facebook.com/{graph-api-version}/{page-id}?fields=location&access_token={page-access-token}"

Sample Response

{
  "location": {
    "city": "Menlo Park",
    "country": "United States",
    "latitude": 37.4786342,
    "located_in": "166793820034304",
    "longitude": -122.163581,
    "state": "CA",
    "street": "1 Hacker Way",
    "zip": "94025"
  },
  "id": "{page-id}"
}

Example

Graph API Explorer
GET v5.0/...?fields={fieldname_of_type_Location} HTTP/1.1
Host: graph.facebook.com
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->get(
    '...?fields={fieldname_of_type_Location}',
    '{access-token}'
  );
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */
/* make the API call */
FB.api(
    "...?fields={fieldname_of_type_Location}",
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "...?fields={fieldname_of_type_Location}",
    null,
    HttpMethod.GET,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
// For more complex open graph stories, use `FBSDKShareAPI`
// with `FBSDKShareOpenGraphContent`
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"...?fields={fieldname_of_type_Location}"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];
If you want to learn how to use the Graph API, read our Using Graph API guide.

Parameters

This endpoint doesn't have any parameters.

Fields

FieldDescription
city
string

City

city_id
unsigned int32

City ID. Any city identified is also a city you can use for targeting ads.

country
string

Country

country_code
string

Country code

latitude
float

Latitude

located_in
id

The parent location if this location is located within another location

longitude
float

Longitude

name
string

Name

region
string

Region

region_id
unsigned int32

Region ID. Specifies a geographic region, such as California. An identified region is the same as one you can use to target ads.

state
string

State

street
string

Street

zip
string

Zip code

Creating

You can't perform this operation on this endpoint.

Updating

You can't perform this operation on this endpoint.

Deleting

You can't perform this operation on this endpoint.