'How to get born date of personalities from Wikipedia

I am making a web application and I want the born date of the personalities on my pages. I want to use the Wikipedia API to get the born data but I can't find the correct URL to get the born date. Can anyone help?



Solution 1:[1]

You need to use the Wikidata API for this. wikidata api retrieve properties from entity (wikidata entry) has an example and expanding upon that, use e.g. https://en.wikipedia.org/w/api.php?action=query&prop=pageprops&ppprop=wikibase_item&titles=Donald%20Trump&formatversion=2 to get the Wikidata ID, then use https://www.wikidata.org/w/api.php?action=wbgetentities&props=claims&ids=Q22686&format=json and the date of birth exists at e.g.

json['entities']['Q22686']['claims']['P569'][0]['mainsnak']['datavalue']['value']['time']

There's probably a more elegant way to do it using SPARQL too https://wdqs-tutorial.toolforge.org/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 smartse