facebookinstagramsocial-mediagoogle-knowledge-graph

How to get social media links from Google Knowledge


I'm working on a project that requires me to collect celebrities followers number (from instagram or facebook).

To get that number, i have to get

  1. celebrities instagram link
  2. celebrities facebook link
  3. send a request to instagram or facebook API to get their followers number

I have been researching for google knowledge API for celebrities instagram and facebook link. but what I get from it isn't satisfying. For example, I put a request on google Knowledge,

https://kgsearch.googleapis.com/v1/entities:search?query=Ariana+Grande&limit=1&indent=1&key={API-CODE}

and the result is

{"@context": {

"@vocab": "schema.org/",
"goog": "schema.googleapis.com/",
"EntitySearchResult": "goog:EntitySearchResult",
"detailedDescription": "goog:detailedDescription",
"resultScore": "goog:resultScore",
"kg": "g.co/kg"
},
"@type": "ItemList",
"itemListElement": [
{
"@type": "EntitySearchResult",
"result": {
"@id": "kg:/m/09gkdy4",
"name": "Ariana Grande",
"@type": [
"Thing",
"Person"
],
"description": "Singer",
"image": {
"contentUrl": "t0.gstatic.com/images?q=tbn:ANd9GcS3KH3ae6ChLCPLguyQXbLbEXDTNMZ1Sb2LsMx6Vr-pjeuHg5AZ",
"url": "da.wikipedia.org/wiki/Ariana_Grande",
"license": "creativecommons.org/licenses/by/2.0"
},
"detailedDescription": {
"articleBody": "Ariana Grande-Butera, known professionally as Ariana Grande, is an American singer and actress. She began her career in the Broadway musical 13, before landing the role of Cat Valentine on the Nickelodeon television series Victorious in 2009. ",
"url": "en.wikipedia.org/wiki/Ariana_Grande",
"license": "en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"
},
"url": "www.arianagrande.com"
},
"resultScore": 802.862244
}
]
}

There's no information regarding her instagram or facebook link from the result, but if we search manually on google, it shows her instagram and facebook link on search result.

My question are:

  1. Any way to get those link from Google knowledge?
  2. Or any easier way to get follower number from celebrities beside my way? (jugling from 2-3 different APIs)

Solution

  • You can use wikidata.org. There are steps:

    1. Search https://www.wikidata.org/w/api.php?action=wbsearchentities&search=Ariana+Grande&language=en&format=json

      {"searchinfo":{"search":"Ariana Grande"},"search":[{"id":"Q151892","concepturi":"http://www.wikidata.org/entity/Q151892","url":"//www.wikidata.org/wiki/Q151892","title":"Q151892","pageid":153289,"label":"Ariana Grande","description":"American actress, singer, composer and dancer","match":{"type":"label","language":"en","text":"Ariana Grande"}}],"success":1}

    2. Get id Q151892 from the response and get the entity https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q151892&format=json&props=claims

    There is a big response. You need the value arianagrande of claim P2003 from a list of claims. It refers to Instagram username (P2013 for Facebook)

    1. Get public info from https://www.instagram.com/arianagrande/?__a=1

      user:
      follows:
          count
      followed_by:
          count
      media:
          count