mwiki.art
MediaWiki API wrapper for Arturo
What does this package do?
This package provides a complete MediaWiki API wrapper for Arturo, enabling seamless interaction with any MediaWiki-powered wiki (Wikipedia, Wikia, etc.). It handles authentication, page retrieval and editing, search, category browsing, and more - with automatic cookie management under the hood.
How do I use it?
Simply import it and start interacting with your favorite wiki:
import 'mwiki!
; Connect to a MediaWiki instance
wiki: to :MW ["https://rosettacode.org/w/api.php"]!
; Retrieve a page
page: wiki\page "Fibonacci sequence"
print page\content
; Search for pages
results: wiki\search.limit:5 "palindrome"
print.lines results
; Get category members
cat: wiki\category "Programming Tasks"
print [cat\name "has" size cat\members "members"]
; Login and edit (requires credentials)
using wiki [
if \login "username" "password" ->
\editPage "Test Page" "Hello, wiki!" "Created test page"
]
Type reference
🔹 MW
The main MediaWiki API client
Constructor
to :MW [apiUrl :string]
Fields
\apiUrl- the MediaWiki API endpoint\cookies- session cookies (managed automatically)\loggedIn- authentication status
Methods
login
Authenticate with MediaWiki API.
login username :string password :string
Returns
- :logical -
trueif authentication successful,falseotherwise
page
Retrieve page content by title.
page title :string
Returns
- :mwPage - page object containing title and content
- :null - page not found or request failure
editPage
Edit or create a wiki page.
editPage title :string content :string summary :string
Returns
- :logical -
trueif edit successful,falseotherwise
category
Get all members of given category.
category name :string
Returns
- :mwCategory - category object containing name and member list
- :null - request failure
search
Search wiki pages using given query.
search query :string
Attributes
| Option | Type | Description |
|---|---|---|
| what | :string :literal | 'title, 'text, or 'nearmatch (default: 'title) |
| limit | :integer | Limit search results (default: 10) |
Returns
- :block - array of page titles matching the search query
user
Get current user information.
user
Returns
- :mwUser - user object with information, groups, rights, and edit count
- :null - request failure
recent
Get recent wiki changes.
recent limit :integer :null
Returns
- :block - array of recent changes (default limit: 10)
🔹 mwPage
Represents a wiki page with its content
Constructor
to :mwPage [title :string, content :string]
Fields
\title- page title\content- page wikitext content
🔹 mwUser
Represents a MediaWiki user
Constructor
to :mwUser [details :dictionary]
Fields
\details- user information dictionary
🔹 mwCategory
Represents a wiki category with its members
Constructor
to :mwCategory [name :string, members :integer]
Fields
\name- category name\members- list of members
Tip
The wrapper automatically handles session cookies and CSRF tokens, so you don't need to worry about authentication state management! 😉
License
MIT License
Copyright (c) 2025 Yanis Zafirópulos
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
| 0.3.0 | 12 November 2025 | 15214 / 5 files |
| 0.2.0 | 11 November 2025 | 13980 / 5 files |
| 0.1.0 | 10 November 2025 | 12745 / 4 files |
No dependencies.