A command-line tool for interacting with MediaWiki APIs.
cargo build --release
# binary at target/release/mediawiki-cli| Option | Default | Description |
|---|---|---|
--api-url |
https://prts.wiki/api.php |
MediaWiki API endpoint |
--cookie |
— | Custom Cookie header, overrides stored login cookie |
--log-level |
warn |
Log level: error | warn | info | debug | trace |
Log in and store the session cookie. Prompts for password interactively. Supports 2FA — if the wiki requires a second factor, you'll be prompted for it automatically.
mediawiki-cli auth login MyUserSession cookies are persisted to ~/.config/mediawiki-cli/cookies.json (keyed by API URL).
Show current login status: username, user groups, rights, edit count, registration date, and email.
mediawiki-cli auth statusFetch raw wikitext for a page or a specific revision. You must specify either a title or --revid.
mediawiki-cli page get "Main Page"
mediawiki-cli page get --revid 12345Edit a page. Content can be provided via stdin, a file, the --content flag, the --replace flag, or as a null edit.
| Option | Description |
|---|---|
-s, --summary <text> |
Edit summary |
--minor |
Mark as minor edit |
--create-only |
Only create the page; fail if it already exists |
-f, --file <path> |
Read content from a file |
-c, --content <text> |
Provide content directly on the command line |
--replace <OLD> <NEW> |
Replace a single occurrence of OLD with NEW in the page |
--null-edit |
Submit a null edit (resubmit current content without changes) |
# from stdin
echo "new content" | mediawiki-cli page edit "Sandbox" -s "update"
# from file
mediawiki-cli page edit "Sandbox" -f content.txt -s "update from file"
# inline content
mediawiki-cli page edit "Sandbox" --content "hello world"
# find-and-replace (exact one match required)
mediawiki-cli page edit "Sandbox" --replace "old text" "new text"
# null edit
mediawiki-cli page edit "Sandbox" --null-editShow page metadata (title, page ID, URL, categories). Use --templates to list all transcluded templates.
mediawiki-cli page info "Main Page"
mediawiki-cli page info "Main Page" --templates
mediawiki-cli page info --revid 12345List page revision history. Outputs rev ID, timestamp, user, size, and comment in a tab-separated format.
mediawiki-cli page history "Main Page"
mediawiki-cli page history "Main Page" --limit 50List all pages in a category. The category name can be provided with or without the "Category:" prefix. By default, all members are listed; use --limit to cap the number of results.
mediawiki-cli page category "Templates"
mediawiki-cli page category "Category:Templates" --limit 50Search pages by keyword. Outputs title, page ID, and snippet.
mediawiki-cli page search "arknights"
mediawiki-cli page search "arknights" --limit 20List pages that embed (transclude) the given page. Useful for finding where a template is used.
mediawiki-cli page embedded-in "Template:Infobox"
mediawiki-cli page embedded-in "Template:Infobox" --limit 50List all Cargo database tables on the wiki. Outputs table names sorted alphabetically.
mediawiki-cli cargo tablesShow all fields and their types for a given Cargo table. Outputs field name and type (e.g. String, Wikitext) in a tab-separated format.
mediawiki-cli cargo fields charaRun a Cargo query against the wiki database. Results are output as tab-separated values with a header row.
| Option | Description |
|---|---|
--tables <tables> |
Comma-separated table names to query |
--fields <fields> |
Comma-separated field names to retrieve |
--where <clause> |
SQL-style WHERE condition |
--join-on <clause> |
SQL-style JOIN ON condition |
--group-by <clause> |
SQL-style GROUP BY clause |
--having <clause> |
SQL-style HAVING clause |
--order-by <clause> |
SQL-style ORDER BY clause |
--limit <N> |
Maximum number of results (default: 50) |
--offset <N> |
Query offset |
mediawiki-cli cargo query --tables chara --fields name,rarity --limit 5
mediawiki-cli cargo query --tables building_skill2 --fields name,room --where "room='控制中枢'" --limit 10mediawiki-cli uses the MediaWiki clientlogin API for authentication. After logging in with auth login, the session cookie is stored locally and automatically sent with subsequent requests. You can also pass a cookie directly with --cookie without using the login flow.