From Wikibooks, open books for an open world
Jump to navigation Jump to search
SERVICE - around and box SPARQL
SERVICE - mwapi

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: *,,,,

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):

  wd:Q6501349 wdt:P910 ?category . # Parking lot - Main category
  ?link schema:about ?category; schema:isPartOf <>; schema:name ?title .
  SERVICE wikibase:mwapi {
     bd:serviceParam wikibase:api "Generator" .
     bd:serviceParam wikibase:endpoint "" .
     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 .

Try it!

References[edit | edit source]

SERVICE - around and box SPARQL
SERVICE - mwapi