Jump to content

Wikifunctions:Status updates/2026-09-10

From Wikifunctions
◀ Wikifunctions Status updates Translate ▶

Abstract Wikipedia via mailing list Volunteer Response Team Abstract Wikipedia on IRC Wikifunctions on Telegram Wikifunctions on Mastodon Wikifunctions on Twitter Wikifunctions on Facebook Wikifunctions on YouTube Wikifunctions website Translate

Your code can now call back to the Wikidata fetch functions

This week we have deployed an initial capability by which a code Implementation (in JavaScript or Python) can call certain other Wikifunctions Functions, get back the result, and have it available for further processing. The primary motivation for this new capability is to provide greater flexibility in the use of code, so that more can be done with them – which allows you to get the benefit of their performance advantages and enables a more streamlined Implementation structure for some Functions.

At present, due to security and performance concerns, only the following built-in Wikidata fetch and search Functions can be called in this way: Z6820 (Fetch Wikidata entities), Z6821 (Fetch Wikidata item), Z6822 (Fetch Wikidata property), Z6824 (Fetch Wikidata lexeme form), Z6825 (Fetch Wikidata lexeme), Z6826 (Fetch Wikidata lexeme sense), Z6830 (Find lexemes for item), and Z6831 (Find lexemes for lexeme sense). This capability is in an initial stage of deployment; we hope to allow calls to a broader range of Functions in the future. We focused on these first as they're impossible in user-written code (due to security lock-downs preventing all network access), rather than just irritating to need to re-implement like calls to other built-in functions or user-written ones would be.

Let’s look at a JavaScript Implementation containing a callback. This fetches an Item from Wikidata, extracts the label of that Item in a given language, and returns the label. The item to fetch is given by argument Z400K1, and the language is given by Z400K2.

function Z400( Z400K1, Z400K2 ) {
    const item = Wikifunctions.Call('Z6821', Z400K1);
    for (const label of item.Z6001K2.Z12K1) {
        if (label.Z11K1.Z60K1 === Z400K2.Z60K1) {
           return label.Z11K2;
        }
    }
    return 'NOT FOUND';
}

A callback is made by calling Wikifunctions.Call, as shown in the example. The first argument to Wikifunctions.Call is always the ZID of the Function to be called – in this case, Z6821/Fetch Wikidata item, which takes a single argument. Following that, the arguments to be passed to that Function are listed, separated by commas. Here, that argument, Z400K1, is the same value that was passed to Z400. This is a common pattern of argument passing to callbacks, but their arguments can also be built inline, or obtained in other ways.

The value of Z400K1 would be an instance of Z6091/Wikidata item reference, containing the QID of the item to be fetched. Line 2 of the example calls Z6821 to fetch that item from Wikidata and assigns the resulting ZObject to the const item. The remaining code iterates over the item’s labels until it finds the one matching the language given by Z400K2.

For the example above, we have used Z6821 for simplicity. However, unless an entire entity is truly needed by the Implementation, it is strongly recommended to use Z6820 rather than Z6821 to retrieve Wikidata items, which can be quite large and thus slow to load and transfer. Although a call to Z6820 is a bit more complex, its parameters allow for fetching selected portions of a Wikidata item, which can greatly improve performance, and avoid some errors, by reducing the network bandwidth and processing time that are needed. In the online documentation for callbacks, we show how Z6820 can be used to implement the same Function as above.

Live demo example: We've used the callback feature to provide a new, more streamlined Implementation (Z40967) for the German noun declension table (Z28602). Previously, this Function was only implementable using compositions, and both of the provided compositions were somewhat awkward. (Each of them used repeated calls to helper Functions to fetch and process Wikidata items, causing them to be bulky, somewhat unreadable, and susceptible to performance challenges associated with compositions.) Because callbacks provide the ability to directly fetch Wikidata entities from code Implementations, it's now possible to contain all the processing of German noun declension table within a single code Implementation. (There are still a few details regarding the table headers to be added.) In the passing Test case, the callback-based Implementation takes 0.2s instead of 1.0 and 1.2s the two existing compositions take.

Other things to note:

  • Even though code implementations are now able to fetch Wikidata entities, it is recommended that they not be written to return entire entities. This is because of current limitations on the size of the value returned from a code implementation. To fetch an entire entity, it’s better to call the fetch function from a composition.
  • Only one callback can execute at a time. For security reasons, it is not possible to use the concurrency features of JavaScript or Python to execute multiple callbacks in parallel.
  • There is currently a 3 MiB limit on the size of Wikidata content that can be returned to a code implementation, by a single callback.

Recent Changes in the software

This week, we added a link from fragment error messages on Abstract Wikipedia to run the same call on Wikifunctions, where you may be better able to diagnose and fix the issue (T435712). We also made it easier to navigate longer abstract articles: when you click on an abstract fragment call or result, the other column now scrolls to bring the matching pair into view (T429214). In addition, when prompted with a list of languages, we now show your user language (for example, Igbo) before the “UN 6,” making it easier to add language-related calls on Abstract Wikipedia and Wikifunctions (T435712). Finally, we fixed a problem when showing images on Abstract Wikipedia; sorry for the disruption (T436579).

News in Types: Julian calendar date

A new Type for representing Julian calendar dates has been introduced based on the respective proposal. We already had Gregorian calendar dates for a long time, and now are introducing Julian calendar dates as a second supported calendar system. Structurally, the two are the same, but they are off by up to a dozen days or so.

The type has also been set-up to be connected to the Wikidata fetching code, so that Julian calendar dates from Wikidata are now being imported to Wikifunctions and made available to Abstract Wikipedia. Thanks to the community for being so patient! We are looking forward to seeing how the new Type is being used.

Thanks to Ameisenigel, Feeglgeef, GrounderUK, 99of9, Dv103, and JhowieNitnek for their participation in the proposal. We invite you all to create new and discuss the existing Type proposals so we can keep on creating new Types. We are particularly curious about more calendar models! Thanks to all the community members contributing to the discussion and writing proposals, making it possible to extend Wikifunctions to new domains!

Recording of Volunteer’s Corner from September 7

For this week’s Volunteer’s corner, we only recorded the initial update part, which is available on Commons.

We used the rest of the time for a lively discussion with the volunteers who joined in, but we decided beforehand not to record it. Thanks to the participants!

The next Volunteers’ Corner is planned for Monday, 5 October 2026.

Denny at WikiCon 2026 in Regensburg, Germany

Next weekend is WikiCon 2026 in Regensburg, Germany. Denny will participate, and if you’d like to discuss Abstract Wikipedia, Wikifunctions, or knowledge representation, please get in touch with him.

Fresh Functions weekly: 210 new Functions

This week we had another record in the number of new Functions: 210 new Functions have been created in the last week. Here is an incomplete list of functions with implementations and passing tests to get a taste of what functions have been created. Thanks everybody for contributing!

A complete list of all functions sorted by when they were created is available.