**Main components:**
* Wikibase-Lua
**User story:**
As a Wikipedia template editor / Lua programmer, I want to find the badges a specific Wikipedia article has using Lua in order to use it in my Lua module and template.
**Problem:**
Getting information about badges using Lua is currently possible, but it requires loading the whole entity. This is problematic in some items as it can cause Lua errors (e.g. needs too much memory).
**Solution:**
Add a Lua convenience function `getBadges` (similar to `getSitelink`).
See: https://doc.wikimedia.org/Wikibase/master/php/docs_topics_lua.html#mw.wikibase.getSitelink
This would be run similarly to the 'getSitelink' i.e.
-- @param {string} itemId
-- @param {string} [globalSiteId]
function wikibase.getBadges( itemId, globalSiteId )
and the return value is a Lua table (with numeric indices), containing zero or more badges (identified by the corresponding badge QID).
The globalSiteID can remain empty and this will default to the local wiki.
**BDD:**
GIVEN a Wikipedia article
AND a Wikidata Item has sitelinks with badges for this article
WHEN a Lua 'getBadges' convenience function is run
THEN a Lua table with the QIDs of the badges is returned
**Acceptance criteria:**
[] A Lua 'getBadges' convenience function is available
[] [[ https://doc.wikimedia.org/Wikibase/master/php/docs_topics_lua.html | Wikibade: Lua page ]] is updated with the information on how the 'getBadges' convenience function will operate
**Original:**
https://www.wikidata.org/wiki/Wikidata:Report_a_technical_problem/Archive/2022/04#Add_a_lua_function_%22getBadges%22