## Description
Overview:
We can greatly reduce the bandwidth and processing needed for calls to [[ https://www.wikifunctions.org/view/en/Z6821 | Z6821/Fetch Wikidata item ]] if we provide parameters allowing those calls to specify
# which content is needed (labels, aliases, descriptions and/or statements)
# which languages are of interest in labels, aliases, and descriptions
# which properties are of interest in statements.
(1) and (2) can be passed through to Wikidata's `wbgetentities` API, which already provides those filters (using the //props// and //languages// parameters, as documented [[ https://www.wikidata.org/w/api.php?action=help&modules=wbgetentities | here ]]). Filtering for (3) can easily be implemented in the orchestrator.
If and when Wikifunctions can have optional parameters, these could be optional. Alternatively, we could have 2 versions of each fetch function – one with and one without these parameters.
**Update, 17 August 2025**: rather than adding parameters to Z6821/2/4/5/6, we could Add them to `Z6820/Fetch Wikidata entities` (which probably didn't exist when this ticket was first written). (`Z6820` has only been used in 2 places so far, so the impact on existing Wikifunctions would be negligible.) Then `Z6820` could also be wrapped in various ways to create non-parameterized functions like "Fetch entity statements", "Fetch entity labels", or single-parameter functions like "Fetch entity content in languages <list of languages>", "Fetch entity statements with property <property reference>", etc.
This would involve 3 new arguments for `Z6820`: (1) could be a new enumeration type for labels, aliases, descriptions, etc. (2) could be a typed list of `Z60/Natural language`. (3) could be a typed list of `Z6092/Wikidata property reference`.
**Benefits of using these parameters:**
- The JSON returned from Wikidata can be far smaller, greatly reducing the bandwidth used for fetches.
- The resulting ZObject can also be much smaller, eliminating some orchestrator processing.
- If the resulting ZObject is passed to another Wikifunction that needs to sift through labels/aliases/descriptions, the much-smaller size of those lists will also help with the performance of that sifting.
- The smaller ZObjects will also mean less processing in WikiLambda for presenting them, and will be somewhat easier to browse in the UI.
**Concerns**
- Getting the benefits requires some user knowledge & effort, in specifying the values of the optimization parameters.
- When a fetch function is called in a composition, and it's desirable to pass these parameters to the fetch function, that might sometimes necessitate adding the parameters to the calling function.
**Background:**
- Wikidata Items typically have labels in many languages, aliases in many languages, and descriptions in many languages.
- Many calls to [[ https://www.wikifunctions.org/view/en/Z6821 | Z6821/Fetch Wikidata item ]] will be made for a specific language-generation purpose, in which the target language is known in advance.
- Similarly, many calls will be made in a context in which the value of a particular statement is needed, and the statement property is known in advance.
- Some known performance problems related to Wikidata fetches (such as the problem underlying T378414) are caused by text snippets in many different languages (such as 90+ glosses in L1).
- In addition to helping with current performance problems, these changes will also provide substantial network & processing savings over time.
We can also consider adding these parameters to the other Wikidata fetch functions; [[ https://www.wikifunctions.org/view/en/Z6821 | Z6821/Fetch Wikidata item ]] is featured here because items tend to have the most labels/aliases/descriptions, and probably the most statements as well.
## Completion checklist
* [ ] Before closing this task, review one by one the checklist available here: https://www.mediawiki.org/wiki/Abstract_Wikipedia_team/Definition_of_Done#Back-end_Task/Bug_completion_checklist