Help
Difference between revisions of "APIs"
Line 103: | Line 103: | ||
} | } | ||
}</pre> | }</pre> | ||
+ | |- | ||
+ | | Commons > [https://commons.wikimedia.org/wiki/Special:ApiSandbox#action=query&format=json&prop=imageinfo%7Cpageprops%7Ccategories&generator=search&iiprop=url%7Cextmetadata&iimetadataversion=1&iiextmetadatafilter=Categories&clprop=sortkey&clshow=!hidden&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=json&prop=imageinfo%7Cpageprops%7Ccategories&generator=search&iiprop=url%7Cextmetadata&iimetadataversion=1&iiextmetadatafilter=Categories&clprop=sortkey&clshow=!hidden&gsrsearch=intitle%3A%2FLL-Q150.*-orange%5C.wav%2F&gsrnamespace=6&gsrlimit=50&gsrwhat=text Combined query with search (regex filter) ; imageinfo (url) ; categories (speaker)] || <pre></pre> | ||
|} | |} | ||
+ | == [[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 == | ||
* API > [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] |
Revision as of 18:17, 3 December 2021
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.
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:Parse | properties 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\n | speakerId = Q334514\n | speakerGender = female\n | author = [[User:Persepha|Persepha]]\n | languageId = Q150\n | transcription = Vert-Saint-Denis\n | qualifier = \n | date = 2020-07-04\n}}\n\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) |
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.