GET request to fetch a list of all logged events as shown in Special:Log.
Dokumentacja API
Poniższa dokumentacja jest rezultatem Special:ApiHelp/query+logevents, automatycznie wygenerowanym przez przedwczesną wersję MediaWiki, na której działa ta witryna (MediaWiki.org).
One of the following values: Can be empty, or abusefilter, abusefilter-protected-vars, abusefilterblockeddomainhit, abusefilterprivatedetails, block, checkuser-temporary-account, contentmodel, create, delete, gblblock, gblrename, gblrights, globalauth, import, ipinfo, liquidthreads, managetags, massmessage, merge, messagebundle, move, newsletter, newusers, notifytranslators, oath, pagelang, pagetranslation, patrol, protect, renameuser, rights, spamblacklist, suppress, tag, thanks, timedmediahandler, titleblacklist, translationreview, upload, urlshortener, usermerge
leaction
Filter log actions to only this action. Overrides letype. In the list of possible values, values with the asterisk wildcard such as action/* can have different strings after the slash (/).
{"batchcomplete":"","continue":{"continue":"-||","lecontinue":"20190606150600|99729503"},"query":{"logevents":[{"action":"create","comment":"added to WikiProject (via [[WP:JWB]])","logid":99729506,"logpage":60974819,"ns":15,"pageid":60974819,"params":{},"timestamp":"2019-06-06T15:06:07Z","title":"Category talk:Electronic albums by Senegalese artists","type":"create","user":"Jevansen"}...]}}
Przykładowy kod
Python
#!/usr/bin/python3""" get_logevents.py MediaWiki API Demos Demo of `Logevents` module: Get the three most recent logevents. MIT License"""importrequestsS=requests.Session()URL="https://en.wikipedia.org/w/api.php"PARAMS={"action":"query","format":"json","list":"logevents","lelimit":"3"}R=S.get(url=URL,params=PARAMS)DATA=R.json()LOGS=DATA["query"]["logevents"]forlinLOGS:print("There is "+l["type"]+" log for page "+l["title"])
PHP
<?php/* get_logevents.php MediaWiki API Demos Demo of `Logevents` module: Get the three most recent logevents. MIT License*/$endPoint="https://en.wikipedia.org/w/api.php";$params=["action"=>"query","format"=>"json","list"=>"logevents","lelimit"=>"3"];$url=$endPoint."?".http_build_query($params);$ch=curl_init($url);curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);$output=curl_exec($ch);curl_close($ch);$result=json_decode($output,true);foreach($result["query"]["logevents"]as$k=>$v){echo("There is ".$v["type"]." log for page ".$v["title"]."\n");}
JavaScript
/* get_logevents.js MediaWiki API Demos Demo of `Logevents` module: Get the three most recent logevents. MIT License*/varurl="https://en.wikipedia.org/w/api.php";varparams={action:"query",format:"json",list:"logevents",lelimit:"3"};url=url+"?origin=*";Object.keys(params).forEach(function(key){url+="&"+key+"="+params[key];});fetch(url).then(function(response){returnresponse.json();}).then(function(response){varlogs=response.query.logevents;for(varlinlogs){console.log("There is "+logs[l].type+" log for page "+logs[l].title);}}).catch(function(error){console.log(error);});
MediaWiki JS
/* get_logevents.js MediaWiki API Demos Demo of `Logevents` module: Get the three most recent logevents. MIT License*/varparams={action:'query',format:'json',list:'logevents',lelimit:'3'},api=newmw.Api();api.get(params).done(function(data){varlogs=data.query.logevents,l;for(linlogs){console.log('There is '+logs[l].type+' log for page '+logs[l].title);}});
Możliwe błędy
Kod
Info
leparam_user
User name username not found.
leparam_title
Zły tytuł „title”. This happens when you set letitle to an invalid title.
For autoblock unblock entries, the title returned is shown as "User:$blockid". To nie jest strona użytkownika, ale sposób, w jaki jest przechowywana. Zobacz zadanie T19781.
When userid is specified for account creation events, the userid of the creating user is returned. When absent, the userid returned is that of the created account. See zadanie T73020.