< SPARQL
Mediawiki API Service allows to call out to Mediawiki API from SPARQL, and receive the results from inside the SPARQL query.
The query is initiated by SERVICE with URL wikibase:mwapi. Currently supported Mediawiki endpoints are: *.wikipedia.org, commons.wikimedia.org, www.mediawiki.org, www.wikidata.org, test.wikidata.org
.
Currently the following services are supported:
Service | Documentation | Inputs | Outputs | Description |
---|---|---|---|---|
Generator | see here | generator, prop, pprop | title, item, pageid, lastrevid, timestamp | Call any generator API. Use "generator" parameter to specify, and specific generator parameters to further amend the search (see the example below). |
Categories | see here | titles,cllimit | category, title | Get a list of categories on the page. |
Search | see here | srsearch,srwhat,srlimit | title | Full-text search in wiki. |
EntitySearch | see here | search,language,type,limit | item,label | Wikibase entity search, by title. |
Required parameters are in bold. Please refer to the service documentation (linked in Documentation column) for the meaning of input parameters.
Please see full description on Mediawiki API Service documentation page.
Example (finding category members):
SELECT * WHERE {
wd:Q6501349 wdt:P910 ?category . # Parking lot - Main category
?link schema:about ?category; schema:isPartOf <https://en.wikipedia.org/>; schema:name ?title .
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:api "Generator" .
bd:serviceParam wikibase:endpoint "en.wikipedia.org" .
bd:serviceParam mwapi:gcmtitle ?title .
bd:serviceParam mwapi:generator "categorymembers" .
bd:serviceParam mwapi:gcmprop "ids|title|type" .
bd:serviceParam mwapi:gcmlimit "max" .
bd:serviceParam wikibase:limit 50 .
# out
?subcat wikibase:apiOutput mwapi:title .
?ns wikibase:apiOutput "@ns" .
?item wikibase:apiOutputItem mwapi:item .
}
}
References
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.