User:MartinPoulter
Appearance
The Wikidata example queries that were here are now at wikidata:User:MartinPoulter/queries.
MediaWiki API examples
[edit]Preview (XML extract and thumbnail) of a Wikipedia article
[edit]api.php? action=query& format=xml&formatversion=2& prop=extracts%7Cinfo%7Cpageprops%7Cpageimages& exintro=true& piprop=thumbnail& pithumbsize=281& exchars=1000& titles=Thomas%20Beach [try in ApiSandbox]
External links from an English Wikipedia page
[edit]api.php? action=query& format=json& prop=extlinks& titles=Ashmolean_Museum& ellimit=500 [try in ApiSandbox]
External links from a Commons file
[edit]api.php? action=query& format=json& prop=extlinks& titles=File%3AWilliam_Holman_Hunt_-_A_Converted_British_Family.jpg& ellimit=500 [try in ApiSandbox]
List files in a Commons category (but not subcategories)
[edit]api.php? action=query& format=json& list=categorymembers&cmnamespace=6& cmtitle=Category%3APaintings_in_the_Ashmolean_Museum& cmlimit=500 [try in ApiSandbox]
List subcategories of a Commons category
[edit]api.php? action=query& format=json& list=categorymembers&cmtype=subcat& cmtitle=Category%3ACollections_of_the_Ashmolean_Museum& cmlimit=500 [try in ApiSandbox]
Incoming links to a Wikipedia article, excluding redirects, from other articles
[edit]NB: Use the direct links for this query and the next: there is a problem with the API Sandbox (which has been reported)
api.php? action=query& format=json& prop=linkshere& titles=Bodleian_Library& lhshow=!redirect& lhnamespace=0& lhlimit=500 [try in ApiSandbox]
Incoming links to a Wikipedia article, excluding redirects, from pages in Wikipedia: namespace
[edit]api.php? action=query& format=json& prop=linkshere& titles=Ashmolean_Museum& lhnamespace=4& lhshow=!redirect& lhlimit=500 [try in ApiSandbox]
Incoming links to a Commons institution template, excluding redirects
[edit]api.php? action=query& format=json& prop=linkshere& lhlimit=500& lhshow=!redirect& titles=Institution:Ashmolean_Museum [try in ApiSandbox]
Uses of an image in articles on English Wikipedia
[edit]api.php? action=query& format=json& prop=fileusage& fushow=!redirect& funamespace=0& titles=File:Conica_of_Apollonius_of_Perga_fol._162b_and_164a.jpg [try in ApiSandbox]
Templates used in a Wikipedia article
[edit]api.php? action=query& format=json& prop=templates& tlnamespace=10& titles=Albert%20Einstein [try in ApiSandbox]
All files in a Commons category (including subcats)
[edit]Returns max of 500 results per batch
api.php? action=query& format=json& srnamespace=6& deepcat=500& list=search& srsearch=deepcat:Khalili_Collections& srlimit=max [try in ApiSandbox]
All files in a Commons category (search as generator)
[edit]api.php? action=query& format=json& gsrnamespace=6& deepcat=500& generator=search& gsrsearch=deepcat:Khalili_Collections& gsrlimit=max [try in ApiSandbox]
All contributors to a given file
[edit]api.php? action=query& format=json& prop=contributors& titles=File:Khalili_Collection_Japanese_Meiji_Art_M159.jpg& utf8=1 [try in ApiSandbox]