The following documentation is the output of Special:ApiHelp/query+allusers, automatically generated by the pre-release version of MediaWiki that is running on this site (MediaWiki.org).
#!/usr/bin/python3""" get_allusers.py MediaWiki API Demos Demo of `Allusers` module: Get all users, starting from those whose name begins with the string, 'Drov'. MIT License"""importrequestsS=requests.Session()URL="https://en.wikipedia.org/w/api.php"PARAMS={"action":"query","format":"json","list":"allusers","auprefix":"Drov"}R=S.get(url=URL,params=PARAMS)DATA=R.json()USERS=DATA["query"]["allusers"]foruserinUSERS:print(user["name"])
PHP
<?php/* get_allusers.php MediaWiki API Demos Demo of `Allusers` module: Get all users, starting from those whose name begins with the string, 'Drov'. MIT License*/$endPoint="https://en.wikipedia.org/w/api.php";$params=["action"=>"query","format"=>"json","list"=>"allusers","auprefix"=>"Drov"];$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"]["allusers"]as$k=>$v){echo($v["name"]."\n");}
JavaScript
/* get_allusers.js MediaWiki API Demos Demo of `Allusers` module: Get all users, starting from those whose name begins with the string, 'Drov'. MIT License*/varurl="https://en.wikipedia.org/w/api.php";varparams={action:"query",format:"json",list:"allusers",auprefix:"Drov"};url=url+"?origin=*";Object.keys(params).forEach(function(key){url+="&"+key+"="+params[key];});fetch(url).then(function(response){returnresponse.json();}).then(function(response){varusers=response.query.allusers;for(varuinusers){console.log(users[u].name);}}).catch(function(error){console.log(error);});
MediaWiki JS
/* get_allusers.js MediaWiki API Demos Demo of `Allusers` module: Get all users, starting from those whose name begins with the string, 'Drov'. MIT License*/varparams={action:'query',format:'json',list:'allusers',auprefix:'Drov'},api=newmw.Api();api.get(params).done(function(data){varusers=data.query.allusers,u;for(uinusers){console.log(users[u].name);}});
ข้อบกพร่อง (error) ที่อาจเกิด
รหัส (Code)
ข้อมูล (Info)
augroup-excludegroup
group and excludegroup cannot be used together
Parameter history
v1.12: Introduced auprop=registration
บันทึกเพิ่มเติม
This API call is case sensitive, so aufrom=DROV doesn't return the same results as aufrom=Drov.
All registered usernames are saved and retrieved in capitalized form.
If you are using aufrom or auprefix in your query, make sure you are passing them values that start with an uppercase character.
Although the default behavior is to list any user in the database, we can also limit our response to only those users who belong to a certain group, such as sysops, or bots.
User groups are how MediaWiki grants users certain rights and privileges; see วิธีใช้:สิทธิและกลุ่มผู้ใช้ for more details on how this system works.
ดูเพิ่ม
API:Users - finds information about a list of users.