Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which fields are available for the &fields parameter in the Graph API /search endpoint?

I'm working with the Facebook Graph API and I was wondering which fields are available for the &fields parameter and also where do I find any documentation about those fields.

I could only find the Search types for the &type parameter in the documentation for example the page Search type let's you search for a page if you provide a name to be queried.

Example request

search?q=Facebook&type=page

Example response

{
  "data": [
    {
      "category": "Computers/technology", 
      "name": "Facebook Engineering", 
      "id": "9445547199"
    }, 
    {
      "category": "Product/service", 
      "name": "Facebook", 
      "id": "103274306376166"
    }, 
    {
      "category": "Product/service", 
      "name": "Facebook Developers", 
      "id": "19292868552"
    }, 
    {
      "category": "Media/news/publishing", 
      "name": "Facebook Stories", 
      "id": "114770288670819"
    }
  ]
}

If I now need some specified fields from this collection I know from a previous experience that I could use the &fields parameter to extract them or filter them out.

Example request

search?q=Facebook&type=page&fields=name, likes, location

Example response

{
  "data": [
    {
      "name": "Facebook NY", 
      "likes": 71564, 
      "location": {
      "street": "770 Broadway", 
      "city": "New York", 
      "state": "NY", 
      "country": "United States", 
      "zip": "10003", 
      "latitude": 40.730901749524, 
      "longitude": -73.991377364328
      }, 
      "id": "28864583650"
    }, 
    {
      "name": "Facebook London", 
      "likes": 56441, 
      "location": {
      "street": "10 Brock Street", 
      "city": "London", 
      "state": "", 
      "country": "United Kingdom", 
      "zip": "NW1 3FG", 
      "latitude": 51.5258476, 
      "longitude": -0.1394228
      }, 
      "id": "265781023507354"
    }, 
    {
      "name": "Facebook Paris", 
      "likes": 29740, 
      "location": {
      "street": "", 
      "city": "Paris", 
      "state": "", 
      "country": "France", 
      "zip": "75017", 
      "latitude": 48.883443087419, 
      "longitude": 2.3023060392957
      }, 
      "id": "147424071942327"
    } 
  ]
}

I used the Graph API Explorer to do this

TLDR; is there a list or documentation available for all the options/specific fields in the &fields parameter?

like image 536
0x1ad2 Avatar asked Dec 15 '22 18:12

0x1ad2


1 Answers

Although there is no complete documentation, for any element you can query {id}?metadata=1

this will give you a full list of fields and edges that are available for that object type (as well as its type at the very bottom)

sample call: https://graph.facebook.com/v2.8/me?metadata=1

like image 158
TheCodeMonkey Avatar answered May 17 '23 11:05

TheCodeMonkey