Module:Medal tally
Appearance
local p = {}
function p.getEditCount(username)
local url = "https://en.wikipedia.org/w/api.php"
.. "?action=query&list=users"
.. "&ususers=" .. mw.uri.encode(username)
.. "&usprop=editcount"
.. "&format=json"
local response = mw.http.fetch(url)
if not response then
return "Error: Unable to fetch data."
end
local data = mw.text.jsonDecode(response)
if not data or not data.query or not data.query.users then
return "Error: Invalid response format."
end
local userInfo = data.query.users[1]
if userInfo and userInfo.editcount then
return "User " .. username .. " has " .. userInfo.editcount .. " edits."
else
return "Error: Edit count not found."
end
end
return p