Help
Difference between revisions of "APIs"
APIs are interface system allowing an url query to access data on a server. In the case of LinguaLibre, two APIs are used: LinguaLibre and Commons Wikimedia. Below are some useful examples.
(32 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{#Subtitle:'''APIs''' are interface system allowing an url query to access data on a server. In the case of LinguaLibre, two APIs are used: LinguaLibre and Commons Wikimedia. Below are some useful examples.}} | ||
{{Draft}} | {{Draft}} | ||
− | + | ||
− | {| class="wikitable" | + | == Commons API == |
− | ! API point | + | {| class="wikitable" style="word-break: normal;" |
+ | ! API point | ||
+ | ! Query | ||
+ | ! Example of returned sub-item | ||
|- | |- | ||
− | | [https://commons.wikimedia.org/w/api.php Commons] || [https://commons.wikimedia.org/w/api.php?origin=*&action=query&format=json&ailimit=500&aistart=2018-01-01T00:00:01Z&aiuser=Yug&list=allimages&aisort=timestamp&aiprop=user%7Cmime%7Csize%7Curl List of 500 files by User:Yug, since 2018-01-01 and after, with | + | | [https://commons.wikimedia.org/w/api.php Commons] > [[:mw:Special:MyLanguage/API:Allimages|API:Allimages]] || [https://commons.wikimedia.org/w/api.php?origin=*&action=query&format=json&ailimit=500&aistart=2018-01-01T00:00:01Z&aiuser=Yug&list=allimages&aisort=timestamp&aiprop=user%7Cmime%7Csize%7Curl List of 500 files by User:Yug, since 2018-01-01 and after, with username, mime, size and url] || <syntaxhighlight lang="javascript">{ |
"name": "LL-Q150_(fra)-Yug-retour.wav", | "name": "LL-Q150_(fra)-Yug-retour.wav", | ||
"user": "Yug", | "user": "Yug", | ||
Line 18: | Line 22: | ||
"title": "File:LL-Q150 (fra)-Yug-retour.wav" | "title": "File:LL-Q150 (fra)-Yug-retour.wav" | ||
} | } | ||
− | </ | + | </syntaxhighlight> |
|- | |- | ||
− | | Commons || [https://commons.wikimedia.org/w/api.php?origin=*&action=query&format=json&ailimit=500&aiprefix=LL-Q150_(fra)&list=allimages&aisort=name&aiprop=user%7Cmime%7Csize%7Curl List of 500 files prifixed by 'LL-Q150_(fra)', aka French language files, sorted by name | + | | Commons > [[:mw:Special:MyLanguage/API:Allimages|API:Allimages]] || [https://commons.wikimedia.org/w/api.php?origin=*&action=query&format=json&ailimit=500&aiprefix=LL-Q150_(fra)&list=allimages&aisort=name&aiprop=user%7Cmime%7Csize%7Curl List of 500 files prifixed by 'LL-Q150_(fra)', aka French language files, sorted by name, with username, mime, size and url] || <syntaxhighlight lang="javascript">{ |
"name": "LL-Q150_(fra)-Yug-retour.wav", | "name": "LL-Q150_(fra)-Yug-retour.wav", | ||
"user": "Yug", | "user": "Yug", | ||
Line 34: | Line 38: | ||
"title": "File:LL-Q150 (fra)-Yug-retour.wav" | "title": "File:LL-Q150 (fra)-Yug-retour.wav" | ||
} | } | ||
− | </ | + | </syntaxhighlight> |
|- | |- | ||
− | | Commons || [https://commons.wikimedia.org/w/api.php?origin=*&action=query&format=json&ailimit=500&aiprefix=LL-Q150_(fra)-Yug&list=allimages&aisort=name&aiprop=user%7Cmime%7Csize%7Curl List of 500 files prefixed by 'LL-Q150_(fra)-Yug', aka French language files by user:Yug, sorted by name | + | | Commons > [[:mw:Special:MyLanguage/API:Allimages|API:Allimages]] || [https://commons.wikimedia.org/w/api.php?origin=*&action=query&format=json&ailimit=500&aiprefix=LL-Q150_(fra)-Yug&list=allimages&aisort=name&aiprop=user%7Cmime%7Csize%7Curl List of 500 files prefixed by 'LL-Q150_(fra)-Yug', aka French language files by user:Yug, sorted by name, with username, mime, size and url] || <syntaxhighlight lang="javascript">{ |
"name": "LL-Q150_(fra)-Yug-retour.wav", | "name": "LL-Q150_(fra)-Yug-retour.wav", | ||
"user": "Yug", | "user": "Yug", | ||
Line 50: | Line 54: | ||
"title": "File:LL-Q150 (fra)-Yug-retour.wav" | "title": "File:LL-Q150 (fra)-Yug-retour.wav" | ||
} | } | ||
− | </ | + | </syntaxhighlight> |
|- | |- | ||
− | | [https://commons.wikimedia.org/w/api.php Commons] || [https://commons.wikimedia.org/w/api.php?origin=*&action=query&format=json&lelimit=500&lestart=2022-01-01T00:00:01Z&leuser=Yug&list=logevents&leaction=upload/upload List of 500 log events by User:Yug, type upload/upload, from 2022-01-01 and before] || < | + | | [https://commons.wikimedia.org/w/api.php Commons] > [[:mw:Special:MyLanguage/API:Logevents|API:Logevents]] || [https://commons.wikimedia.org/w/api.php?origin=*&action=query&format=json&lelimit=500&lestart=2022-01-01T00:00:01Z&leuser=Yug&list=logevents&leaction=upload/upload List of 500 log events by User:Yug, type upload/upload, from 2022-01-01 and before] || <syntaxhighlight lang="javascript">{ |
"logid": 310250995, | "logid": 310250995, | ||
"ns": 6, | "ns": 6, | ||
Line 67: | Line 71: | ||
"timestamp": "2021-04-25T22:08:17Z", | "timestamp": "2021-04-25T22:08:17Z", | ||
"comment": "" | "comment": "" | ||
− | }</ | + | }</syntaxhighlight> |
+ | |- | ||
+ | | Commons > [[:mw:Special:MyLanguage/API:Opensearch|API:Opensearch]] || [https://commons.wikimedia.org/w/api.php?action=opensearch&search=LL-Q140193%20(bci)-Olivier%20Yao-&profile=fuzzy&namespace=6&limit=3&format=json Search for files, prefixed with <code>LL-Q140193 (bci)-Olivier Yao-</code>, return in OpenSearch format] ||<syntaxhighlight lang="javascript">[ | ||
+ | "LL-Q140193 (bci)-Olivier Yao-", | ||
+ | [ "File:LL-Q140193 (bci)-Olivier Yao-n\u0254n.wav", "File:LL-Q140193 (bci)-Olivier Yao-oto.wav" ], | ||
+ | [ "", "" ], | ||
+ | [ | ||
+ | "https://commons.wikimedia.org/wiki/File:LL-Q140193_(bci)-Olivier_Yao-n%C9%94n.wav", | ||
+ | "https://commons.wikimedia.org/wiki/File:LL-Q140193_(bci)-Olivier_Yao-oto.wav" | ||
+ | ] | ||
+ | ]</syntaxhighlight> | ||
+ | |- | ||
+ | | Commons > [[:mw:Special:MyLanguage/API:Search|API:Search]] || [https://commons.wikimedia.org/w/api.php?action=query&list=search&srlimit=100&srsearch=intitle:/LL-Q150+%5C%28fra%5C%29-%5B%5E-%5D*-vert%5C.wav&utf8=true/&srnamespace=6&srwhat=text&srprop=timestamp Search via regex <code><nowiki>intitle:/LL-Q150 \(fra\)-[^-]*-vert\.wav/</nowiki></code>]. ⚠️ This will not show recordings from users with a '''-''' in their username. | ||
+ | || <syntaxhighlight lang="javascript">{ | ||
+ | "ns": 6, | ||
+ | "title": "File:LL-Q150 (fra)-Roll-Morton-vert.wav", | ||
+ | "pageid": 70168118, | ||
+ | "timestamp": "2021-08-23T12:22:30Z" | ||
+ | }</syntaxhighlight> | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |- | ||
+ | | Commons > [[:mw:Special:MyLanguage/API:Categorymembers|API:Categorymembers]] || [https://commons.wikimedia.org/wiki/Special:ApiSandbox#action=query&format=json&prop=imageinfo&generator=categorymembers&iiprop=url%7Ctimestamp&iimetadataversion=1&iiextmetadatafilter=Categories&gcmtitle=Category%3ALingua_Libre_pronunciation-fra&gcmprop=ids%7Ctitle&gcmnamespace=6&gcmlimit=500 Given a category of image, return its imageinfo with url, timestamp and other] | ||
+ | |<syntaxhighlight lang="javascript"> | ||
+ | "104331639": { | ||
+ | "pageid": 104331639, | ||
+ | "ns": 6, | ||
+ | "title": "File:LL-Q150 (fra)-Kitel WP-%.wav", | ||
+ | "imagerepository": "local", | ||
+ | "imageinfo": [{ | ||
+ | "timestamp": "2021-04-25T15:49:00Z", | ||
+ | "url": "https://upload.wikimedia.org/wikipedia/commons/a/a3/LL-Q150_%28fra%29-Kitel_WP-%25.wav", | ||
+ | "descriptionurl": "https://commons.wikimedia.org/wiki/File:LL-Q150_(fra)-Kitel_WP-%25.wav", | ||
+ | "descriptionshorturl": "https://commons.wikimedia.org/w/index.php?curid=104331639" | ||
+ | }] | ||
+ | }, | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | |- | ||
+ | | Commons > [[:mw:Special:MyLanguage/API:Parse|API:Parse]] || [https://commons.wikimedia.org/w/api.php?action=parse&page=File:LL-Q150%20(fra)-Poslovitch-vert.wav&format=jsonfm&prop=wikitext%7Cproperties Given file's title, return wikitext & recorded word] | ||
+ | |style="width:60%;"| <syntaxhighlight lang="javascript">{ | ||
+ | "parse": { | ||
+ | "title": "File:LL-Q150 (fra)-Persepha-Vert-Saint-Denis.wav", | ||
+ | "pageid": 91887625, | ||
+ | "wikitext": { | ||
+ | "*": `== {{int:filedesc}} ==\n | ||
+ | {{Lingua Libre record\n | ||
+ | |speaker=Persepha |speakerId=Q334514 |speakerGender=female |author=[[User:Persepha|Persepha]] \n | ||
+ | |languageId=Q150 |transcription=Vert-Saint-Denis |qualifier= |date=2020-07-04}} \n | ||
+ | == {{int:license-header}} ==\n{{cc-by-sa-4.0}}` | ||
+ | }, | ||
+ | "properties": [ | ||
+ | { … }, | ||
+ | { | ||
+ | "name": "defaultsort", | ||
+ | "*": "Vert-Saint-Denis" | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | }</syntaxhighlight> | ||
+ | |- | ||
+ | | Commons > [https://commons.wikimedia.org/wiki/Special:ApiSandbox#action=query&format=json&prop=imageinfo%7Cpageprops&generator=search&iiprop=url%7Cextmetadata&iimetadataversion=1&iiextmetadatafilter=Categories&gsrsearch=intitle%3A%2FLL-Q150.*-orange%5C.wav%2F&gsrnamespace=6&gsrlimit=50&gsrwhat=text API sandbox] || [https://commons.wikimedia.org/w/api.php?action=query&format=jsonfm&prop=imageinfo%7Cpageprops&generator=search&iiprop=url%7Cextmetadata&iimetadataversion=1&iiextmetadatafilter=Categories&gsrsearch=intitle:/LL-Q150.*-vert\.wav/&gsrnamespace=6&gsrlimit=50&gsrwhat=text Combined query with search (regex filter) ; imageinfo (url) ; categories (speaker)] || <syntaxhighlight lang="javascript">"78990843": { | ||
+ | "pageid": 78990843, | ||
+ | "ns": 6, | ||
+ | "title": "File:LL-Q150 (fra)-Aemines1-orange.wav", | ||
+ | "index": 8, | ||
+ | "imagerepository": "local", | ||
+ | "imageinfo": [{ | ||
+ | "url": "https://upload.wikimedia.org/wikipedia/commons/f/fa/LL-Q150_%28fra%29-Aemines1-orange.wav", | ||
+ | "descriptionurl": "https://commons.wikimedia.org/wiki/File:LL-Q150_(fra)-Aemines1-orange.wav", | ||
+ | "descriptionshorturl": "https://commons.wikimedia.org/w/index.php?curid=78990843", | ||
+ | "extmetadata": { | ||
+ | "Categories": { | ||
+ | "value": "Lingua Libre pronunciation-fra|Lingua Libre pronunciation by Aemines1", | ||
+ | "source": "commons-categories", | ||
+ | "hidden": "" | ||
+ | } | ||
+ | } | ||
+ | }], | ||
+ | "pageprops": { | ||
+ | "defaultsort": "orange" | ||
+ | } | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |- | ||
+ | | Commons > [https://commons.wikimedia.org/wiki/Special:ApiSandbox#action=query&format=json&list=search&srsearch=intitle:\\-hund.wav+incategory%3A%22Lingua_Libre_pronunciation-gsw%22&srnamespace=6&origin=* API sandbox] || [https://commons.wikimedia.org/w/api.php?action=query&format=json&list=search&srsearch=intitle:\\-hund.wav+incategory%3A%22Lingua_Libre_pronunciation-gsw%22&srnamespace=6&origin=* Query on <code>Commons:Category:Lingual Libre pronuncitation-gsw</code> (Alemannic) > word: <code>hund</code>, sorted by most relevant] || | ||
+ | <syntaxhighlight lang="javascript"> | ||
+ | { | ||
+ | "batchcomplete": true, | ||
+ | "query": { | ||
+ | "searchinfo": { | ||
+ | "totalhits": 1 | ||
+ | }, | ||
+ | "search": [ | ||
+ | { | ||
+ | "ns": 6, | ||
+ | "title": "File:LL-Q131339 (gsw)-Mathieu Kappler-Hund.wav", | ||
+ | "pageid": 119047661, | ||
+ | "size": 93, | ||
+ | "wordcount": 136, | ||
+ | "snippet": "Description<span class=\"searchmatch\">LL</span>-Q131339 (gsw)-Mathieu Kappler-<span class=\"searchmatch\">Hund</span>.<span class=\"searchmatch\">wav</span> Audio pronunciation file from the Lingua Libre project. Language InfoField Alemannic Transcription", | ||
+ | "timestamp": "2023-05-17T21:53:07Z" | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |- | ||
+ | | Commons > [https://commons.wikimedia.org/wiki/Special:ApiSandbox#action=query&format=json&prop=imageinfo&generator=search&formatversion=2&iiprop=user%7Curl&gsrsearch=intitle%3A%2F-bleu\.wav%2Fi+incategory%3A%22Lingua_Libre_pronunciation-fra%22&gsrnamespace=6 API sandbox] || [https://commons.wikimedia.org/w/api.php?action=query&format=json&prop=imageinfo&generator=search&formatversion=2&iiprop=user%7Curl&gsrsearch=intitle%3A%2F-bleu\.wav%2Fi+incategory%3A%22Lingua_Libre_pronunciation-fra%22&gsrnamespace=6 Query on <code>Commons:Category:Lingual Libre pronuncitation-nor</code> (Norwegian) > word: <code>hund</code>, sorted by most relevant] : with additional properties data || | ||
+ | <syntaxhighlight lang="javascript"> | ||
+ | { | ||
+ | "continue": { | ||
+ | "wbeucontinue": "143752235|Q9043|L.en", | ||
+ | "continue": "||imageinfo|pageprops|pageterms|info|entityterms" | ||
+ | }, | ||
+ | "query": { | ||
+ | "pages": [ | ||
+ | { | ||
+ | "pageid": 125360514, | ||
+ | "ns": 6, | ||
+ | "title": "File:LL-Q9043 (nor)-EdoAug-hund.wav", | ||
+ | "index": 2, | ||
+ | "imagerepository": "local", | ||
+ | "imageinfo": [ | ||
+ | { | ||
+ | "url": "https://upload.wikimedia.org/wikipedia/commons/5/5a/LL-Q9043_%28nor%29-EdoAug-hund.wav", | ||
+ | "descriptionurl": "https://commons.wikimedia.org/wiki/File:LL-Q9043_(nor)-EdoAug-hund.wav", | ||
+ | "descriptionshorturl": "https://commons.wikimedia.org/w/index.php?curid=125360514", | ||
+ | "extmetadata": { | ||
+ | "Categories": { | ||
+ | "value": "Lingua Libre pronunciation-nor|Lingua Libre pronunciation by EdoAug", | ||
+ | "source": "commons-categories", | ||
+ | "hidden": "" | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | ], | ||
+ | "pageprops": { | ||
+ | "defaultsort": "hund", | ||
+ | "jsonconfig_getdata": "1" | ||
+ | }, | ||
+ | "contentmodel": "wikitext", | ||
+ | "pagelanguage": "en", | ||
+ | "pagelanguagehtmlcode": "en", | ||
+ | "pagelanguagedir": "ltr", | ||
+ | "touched": "2024-06-17T19:07:23Z", | ||
+ | "lastrevid": 741317026, | ||
+ | "length": 90, | ||
+ | "wbentityusage": { | ||
+ | "M125360514": { | ||
+ | "aspects": [ | ||
+ | "O", | ||
+ | "T" | ||
+ | ] | ||
+ | }, | ||
+ | "Q60024037": { | ||
+ | "aspects": [ | ||
+ | "L" | ||
+ | ] | ||
+ | }, | ||
+ | "Q9043": { | ||
+ | "aspects": [ | ||
+ | "D", | ||
+ | "L.en", | ||
+ | "O", | ||
+ | "S" | ||
+ | ] | ||
+ | } | ||
+ | } | ||
+ | }, | ||
+ | { ... } | ||
+ | ] | ||
+ | } | ||
+ | } | ||
+ | </syntaxhighlight> | ||
|} | |} | ||
+ | |||
+ | == Tools == | ||
+ | ==== [[Special:ApiSandbox]] ==== | ||
+ | :''See also [[:Commons:Special:ApiSandbox]] | ||
+ | It is an API requests generator. | ||
+ | * Left block allows to : | ||
+ | ** Main: navigate the API tree | ||
+ | ** Results: visualize the JSON | ||
+ | * The right block allows to : | ||
+ | ** present the elements clearly | ||
+ | ** allows to select, search, add, remove props (property, parameters) with autocompletion | ||
+ | * Top right buttons allows to : | ||
+ | ** Make a request in a new tab of your browser | ||
+ | ** Clear all. | ||
== API pages == | == API pages == | ||
− | * [https://www.mediawiki.org/w/api.php?action=help&modules=query Query] | + | * API > [https://www.mediawiki.org/w/api.php?action=help&modules=query Query] |
− | ** [ | + | ** [[:mw:Special:MyLanguage/API:Allimages|API:Allimages]] |
− | ** [ | + | ** [[:mw:Special:MyLanguage/API:Logevents|API:Logevents]] |
+ | ** [[:mw:Special:MyLanguage/API:Search|API:Search]] | ||
+ | ** [[:mw:Special:MyLanguage/API:Categorymembers|API:Categorymembers]] | ||
== See also == | == See also == | ||
− | * [[Help:SPARQL]] | + | * [[Special:MyLanguage/Help:SPARQL|Help:SPARQL]] |
+ | * [https://codepen.io/hugolpz/pen/ByoKOK Generalist demo on API queries over Wikipedia]. | ||
+ | * https://github.com/themoeway/yomitan/pull/1129 & https://jsfiddle.net/6rbcu1yw/2/ | ||
+ | |||
+ | {{Technicals}} | ||
+ | |||
[[Category:Lingua Libre:Help{{#translation:}}]] | [[Category:Lingua Libre:Help{{#translation:}}]] |
Latest revision as of 19:43, 25 June 2024
Commons API
API point | Query | Example of returned sub-item |
---|---|---|
Commons > API:Allimages | List of 500 files by User:Yug, since 2018-01-01 and after, with username, mime, size and url | {
"name": "LL-Q150_(fra)-Yug-retour.wav",
"user": "Yug",
"size": 99604,
"width": 0,
"height": 0,
"duration": 1.128798185941043,
"url": "https://upload.wikimedia.org/wikipedia/commons/5/5d/LL-Q150_%28fra%29-Yug-retour.wav",
"descriptionurl": "https://commons.wikimedia.org/wiki/File:LL-Q150_(fra)-Yug-retour.wav",
"descriptionshorturl": "https://commons.wikimedia.org/w/index.php?curid=104350594",
"mime": "audio/wav",
"ns": 6,
"title": "File:LL-Q150 (fra)-Yug-retour.wav"
}
|
Commons > API:Allimages | List of 500 files prifixed by 'LL-Q150_(fra)', aka French language files, sorted by name, with username, mime, size and url | {
"name": "LL-Q150_(fra)-Yug-retour.wav",
"user": "Yug",
"size": 99604,
"width": 0,
"height": 0,
"duration": 1.128798185941043,
"url": "https://upload.wikimedia.org/wikipedia/commons/5/5d/LL-Q150_%28fra%29-Yug-retour.wav",
"descriptionurl": "https://commons.wikimedia.org/wiki/File:LL-Q150_(fra)-Yug-retour.wav",
"descriptionshorturl": "https://commons.wikimedia.org/w/index.php?curid=104350594",
"mime": "audio/wav",
"ns": 6,
"title": "File:LL-Q150 (fra)-Yug-retour.wav"
}
|
Commons > API:Allimages | List of 500 files prefixed by 'LL-Q150_(fra)-Yug', aka French language files by user:Yug, sorted by name, with username, mime, size and url | {
"name": "LL-Q150_(fra)-Yug-retour.wav",
"user": "Yug",
"size": 99604,
"width": 0,
"height": 0,
"duration": 1.128798185941043,
"url": "https://upload.wikimedia.org/wikipedia/commons/5/5d/LL-Q150_%28fra%29-Yug-retour.wav",
"descriptionurl": "https://commons.wikimedia.org/wiki/File:LL-Q150_(fra)-Yug-retour.wav",
"descriptionshorturl": "https://commons.wikimedia.org/w/index.php?curid=104350594",
"mime": "audio/wav",
"ns": 6,
"title": "File:LL-Q150 (fra)-Yug-retour.wav"
}
|
Commons > API:Logevents | List of 500 log events by User:Yug, type upload/upload, from 2022-01-01 and before | {
"logid": 310250995,
"ns": 6,
"title": "File:LL-Q150 (fra)-Yug-retour.wav",
"pageid": 104350594,
"logpage": 104350594,
"params": {
"img_sha1": "annmkt852o46z5icpp2thdzyei7fla1",
"img_timestamp": "2021-04-25T22:08:17Z"
},
"type": "upload",
"action": "upload",
"user": "Yug",
"timestamp": "2021-04-25T22:08:17Z",
"comment": ""
}
|
Commons > API:Opensearch | Search for files, prefixed with LL-Q140193 (bci)-Olivier Yao- , return in OpenSearch format |
[
"LL-Q140193 (bci)-Olivier Yao-",
[ "File:LL-Q140193 (bci)-Olivier Yao-n\u0254n.wav", "File:LL-Q140193 (bci)-Olivier Yao-oto.wav" ],
[ "", "" ],
[
"https://commons.wikimedia.org/wiki/File:LL-Q140193_(bci)-Olivier_Yao-n%C9%94n.wav",
"https://commons.wikimedia.org/wiki/File:LL-Q140193_(bci)-Olivier_Yao-oto.wav"
]
]
|
Commons > API:Search | Search via regex intitle:/LL-Q150 \(fra\)-[^-]*-vert\.wav/ . ⚠️ This will not show recordings from users with a - in their username.
|
{
"ns": 6,
"title": "File:LL-Q150 (fra)-Roll-Morton-vert.wav",
"pageid": 70168118,
"timestamp": "2021-08-23T12:22:30Z"
}
|
Commons > API:Categorymembers | Given a category of image, return its imageinfo with url, timestamp and other | "104331639": {
"pageid": 104331639,
"ns": 6,
"title": "File:LL-Q150 (fra)-Kitel WP-%.wav",
"imagerepository": "local",
"imageinfo": [{
"timestamp": "2021-04-25T15:49:00Z",
"url": "https://upload.wikimedia.org/wikipedia/commons/a/a3/LL-Q150_%28fra%29-Kitel_WP-%25.wav",
"descriptionurl": "https://commons.wikimedia.org/wiki/File:LL-Q150_(fra)-Kitel_WP-%25.wav",
"descriptionshorturl": "https://commons.wikimedia.org/w/index.php?curid=104331639"
}]
},
|
Commons > API:Parse | Given file's title, return wikitext & recorded word | {
"parse": {
"title": "File:LL-Q150 (fra)-Persepha-Vert-Saint-Denis.wav",
"pageid": 91887625,
"wikitext": {
"*": `== {{int:filedesc}} ==\n
{{Lingua Libre record\n
|speaker=Persepha |speakerId=Q334514 |speakerGender=female |author=[[User:Persepha|Persepha]] \n
|languageId=Q150 |transcription=Vert-Saint-Denis |qualifier= |date=2020-07-04}} \n
== {{int:license-header}} ==\n{{cc-by-sa-4.0}}`
},
"properties": [
{ … },
{
"name": "defaultsort",
"*": "Vert-Saint-Denis"
}
]
}
}
|
Commons > API sandbox | Combined query with search (regex filter) ; imageinfo (url) ; categories (speaker) | "78990843": {
"pageid": 78990843,
"ns": 6,
"title": "File:LL-Q150 (fra)-Aemines1-orange.wav",
"index": 8,
"imagerepository": "local",
"imageinfo": [{
"url": "https://upload.wikimedia.org/wikipedia/commons/f/fa/LL-Q150_%28fra%29-Aemines1-orange.wav",
"descriptionurl": "https://commons.wikimedia.org/wiki/File:LL-Q150_(fra)-Aemines1-orange.wav",
"descriptionshorturl": "https://commons.wikimedia.org/w/index.php?curid=78990843",
"extmetadata": {
"Categories": {
"value": "Lingua Libre pronunciation-fra|Lingua Libre pronunciation by Aemines1",
"source": "commons-categories",
"hidden": ""
}
}
}],
"pageprops": {
"defaultsort": "orange"
}
}
|
Commons > API sandbox | Query on Commons:Category:Lingual Libre pronuncitation-gsw (Alemannic) > word: hund , sorted by most relevant |
{
"batchcomplete": true,
"query": {
"searchinfo": {
"totalhits": 1
},
"search": [
{
"ns": 6,
"title": "File:LL-Q131339 (gsw)-Mathieu Kappler-Hund.wav",
"pageid": 119047661,
"size": 93,
"wordcount": 136,
"snippet": "Description<span class=\"searchmatch\">LL</span>-Q131339 (gsw)-Mathieu Kappler-<span class=\"searchmatch\">Hund</span>.<span class=\"searchmatch\">wav</span> Audio pronunciation file from the Lingua Libre project. Language InfoField Alemannic Transcription",
"timestamp": "2023-05-17T21:53:07Z"
}
]
}
}
|
Commons > API sandbox | Query on Commons:Category:Lingual Libre pronuncitation-nor (Norwegian) > word: hund , sorted by most relevant : with additional properties data |
{
"continue": {
"wbeucontinue": "143752235|Q9043|L.en",
"continue": "||imageinfo|pageprops|pageterms|info|entityterms"
},
"query": {
"pages": [
{
"pageid": 125360514,
"ns": 6,
"title": "File:LL-Q9043 (nor)-EdoAug-hund.wav",
"index": 2,
"imagerepository": "local",
"imageinfo": [
{
"url": "https://upload.wikimedia.org/wikipedia/commons/5/5a/LL-Q9043_%28nor%29-EdoAug-hund.wav",
"descriptionurl": "https://commons.wikimedia.org/wiki/File:LL-Q9043_(nor)-EdoAug-hund.wav",
"descriptionshorturl": "https://commons.wikimedia.org/w/index.php?curid=125360514",
"extmetadata": {
"Categories": {
"value": "Lingua Libre pronunciation-nor|Lingua Libre pronunciation by EdoAug",
"source": "commons-categories",
"hidden": ""
}
}
}
],
"pageprops": {
"defaultsort": "hund",
"jsonconfig_getdata": "1"
},
"contentmodel": "wikitext",
"pagelanguage": "en",
"pagelanguagehtmlcode": "en",
"pagelanguagedir": "ltr",
"touched": "2024-06-17T19:07:23Z",
"lastrevid": 741317026,
"length": 90,
"wbentityusage": {
"M125360514": {
"aspects": [
"O",
"T"
]
},
"Q60024037": {
"aspects": [
"L"
]
},
"Q9043": {
"aspects": [
"D",
"L.en",
"O",
"S"
]
}
}
},
{ ... }
]
}
}
|
Tools
Special:ApiSandbox
- See also Commons:Special:ApiSandbox
It is an API requests generator.
- Left block allows to :
- Main: navigate the API tree
- Results: visualize the JSON
- The right block allows to :
- present the elements clearly
- allows to select, search, add, remove props (property, parameters) with autocompletion
- Top right buttons allows to :
- Make a request in a new tab of your browser
- Clear all.
API pages
See also
- Help:SPARQL
- Generalist demo on API queries over Wikipedia.
- https://github.com/themoeway/yomitan/pull/1129 & https://jsfiddle.net/6rbcu1yw/2/