Reputation: 2007
I would like to get the population of a specific country or city from the MediaWiki API. Tried this:
https://en.wikipedia.org/w/api.php?action=query&prop=population&titles=France
This gives me the following error:
Unrecognized value for parameter \"prop\": population.
Does anybody have a solution for this? Any help would be greatly appreciated here.
Thank you.
Upvotes: 0
Views: 1708
Reputation: 1009
This error mean that no "population" option in the API request, So it's not going to return the population of country since it is not recognized as an option.
However, you can do that simply using SPARQL wikidata. You can use this query to get population of any country.
SELECT ?country ?countryLabel ?population WHERE {
?country wdt:P31 wd:Q6256.
?country wdt:P17 wd:Q142.
?country wdt:P1082 ?population.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
See it live here
Change the country as you want from the drop down list.
Upvotes: 3
Reputation: 28160
See the docs for allowed values of prop
. It sounds like what you are after is a SPARQL query.
Upvotes: 1