Wikifunctions python library
This library allows you to interface with the Wikifunctions API in your Python code. Wikifunctions is a project of more than 3,800 community-created and community-maintained functions. You can find a list of these on the catalogue.
Installation
pip install wikifunctions
Usage examples
import wikifunctions as wf
result = wf.call("Z801", "echo")["Z22K1"]
print(result)
This code will print "echo", because Z801 is the echo function.
Building ZObjects
Wikifunctions requires strict JSON structures for its arguments. This library includes helper functions to make building these native types much easier in Python:
import wikifunctions as wf
result = wf.call("Z801", wf.ZNaturalNumber(4))["Z22K1"]
print(result["Z13518K1"])
This code will print "4." To see a full list of ZObject building functions and their parameters, see below.
Disclaimers
- Community-Maintained: Wikifunctions is completely community-created and maintained. The author of this project does not control the underlying logic of functions. Users should check that the functions work as expected before using them, and be aware that anyone with functioneer rights on the Wiki may modify the underlying logic.
- External Processing & Privacy: Using this package means sending content over to servers operated by the Wikimedia Foundation for execution. An internet connection is required to utilize the package, and the author of this project has no control over the reliability of WMF services. Users should not send sensitive data through the wrapper.
Functions
- call(function: str, *args): uses the api to call the function with the specified arguments.
- ZObject(type: str, **properties): creates an object with the specified type and properties. All of the other object builders rely on this function but add abstraction. Z1.
- ZFunctionCall(function: str, *arguments): works similarly to call, but instead creates the relevant function call without sending it to the Wikifunctions API. This is useful for nesting calls. Z7.
- ZReference(item: str): creates a reference to a specific item by its ZID. Z9.
- ZMonolingualText(language: str, content: str): creates a monolingual text from the ZID of a natural language and string content. Z11.
- ZBoolean(value: bool): creates a WF boolean from a Python boolean. Z40.
- ZNaturalNumber(num: int): creates a natural number. Will take the absolute value if given a negative number. Z13518.
- ZHTMLFragment(content: str): wraps a string in an HTML fragment. Z89.
- ZSign(num: int): given a number, returns the sign of that number (e.g. negative for -1). Z16659.
- ZInteger(num: int): converts a python int to a WF integer. Z16683.
- Wikidata references (ZWikidataItemReference, ZWikidataPropertyReference, ZWikidataLexemeFormReference, ZWikidataLexemeReference, ZWikidataLexemeSenseReference): create the relevant reference type given a string representing their ID. Z6091-Z6096.
- ZRationalNumber(numerator: int, denominator: int): creates a WF rational number from a numerator and denominator. Z19677.
- ZKleenean(number: int): creates a Kleenean based on a number. 1 = True, 0 = Maybe, -1 = False. Z22112.
License
This project is licensed under the Apache License 2.0.
Source code and issues
Release files for wikifunctions 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| wikifunctions-0.2.1.tar.gz | 10.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| wikifunctions-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.5 kB
Release files / wikifunctions-0.2.1.tar.gz
| Download URL | wikifunctions-0.2.1.tar.gz |
|---|---|
| Size | 10.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f00453d92895fb9c5a3f531e9f7d06dbbecdc28e36b155e553fd7b468407ab17
|
|
BLAKE2b-256 checksum How to use checksums |
4e419077cc71c7e79c471ce462011af4156f2bc8deb7fa8a0b3dc62a5393a2e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / wikifunctions-0.2.1-py3-none-any.whl
| Download URL | wikifunctions-0.2.1-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
990fe5bc6240213eaa71d017b2a7a09260888fec2b66478776ebb52f049a9894
|
|
BLAKE2b-256 checksum How to use checksums |
024433ce1ada792fe45a99412e72bba2849613c4085524288d395c8ef18bf902
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|