A fast command-line tool to fetch Wikipedia content via the MediaWiki REST API.
- Supports all language Wikipedias (300+)
- Accepts Wikipedia URLs directly—extracts language and title automatically
- Multiple output formats: text, JSON, HTML
- Single static binary with no dependencies
go install github.com/teal-bauer/wikitool@latestOr build from source:
git clone https://github.com/teal-bauer/wikitool.git
cd wikitool
go build -o wikitoolGenerate completions for your shell:
# Bash
wikitool completion bash > /etc/bash_completion.d/wikitool
# Zsh
wikitool completion zsh > "${fpath[1]}/_wikitool"
# Fish
wikitool completion fish > ~/.config/fish/completions/wikitool.fish
# PowerShell
wikitool completion powershell | Out-String | Invoke-ExpressionRun wikitool completion <shell> --help for detailed setup instructions.
# Get a page (returns wikitext source)
wikitool get Earth
wikitool get "Albert Einstein"
# Pass a Wikipedia URL directly
wikitool get https://de.wikipedia.org/wiki/Erde
wikitool get https://fr.wikipedia.org/wiki/Terre
# Get HTML instead of wikitext
wikitool get Jupiter --html
# Get metadata only
wikitool get Mars --info
# Follow redirects (like curl -L)
wikitool get "ISO 7064" -L
# Search Wikipedia
wikitool search "solar system"
wikitool search "quantum physics" --limit 20
# Search only in titles
wikitool search "einstein" --title
# Filter by category
wikitool search "waves" --category "Physics"
# Title autocomplete (typeahead)
wikitool search "einst" --autocomplete
# Different language
wikitool search "Tour Eiffel" --lang fr
# Get available language versions
wikitool languages Earth
# Get file/media info
wikitool file "File:The_Blue_Marble.jpg"
# Get revision details
wikitool revision 764138197
# JSON output
wikitool get Earth --output json
wikitool search "mars" --output json| Command | Description |
|---|---|
get <title|url> |
Get page content (aliases: page) |
search <query> |
Search Wikipedia |
languages <title> |
Get available language versions (aliases: langs) |
file <title> |
Get file/media information |
revision <id> |
Get revision details (aliases: rev) |
| Flag | Description |
|---|---|
-l, --lang |
Wikipedia language code (default: en) |
-o, --output |
Output format: text, json, html (default: text) |
| Flag | Description |
|---|---|
--html |
Get rendered HTML instead of wikitext source |
--info |
Get metadata only (no content) |
-L, --location |
Follow redirects automatically |
Wikipedia uses CirrusSearch (Elasticsearch-based), which supports advanced query syntax:
| Syntax | Example | Description |
|---|---|---|
"phrase" |
"theory of relativity" |
Exact phrase match |
intitle: |
intitle:einstein |
Search only in page titles |
incategory: |
incategory:"Nobel laureates" |
Filter by category |
* |
einst* |
Wildcard prefix matching |
~ |
quantim~ |
Explicit fuzzy match (typo-tolerant by default) |
- |
einstein -albert |
Exclude term from results |
OR |
einstein OR feynman |
Boolean OR |
hastemplate: |
hastemplate:Infobox |
Pages using a specific template |
# Phrase search
wikitool search '"theory of relativity"'
# Title-only search
wikitool search "intitle:einstein"
# Exclude terms
wikitool search "physics -quantum"
# Category filter
wikitool search 'incategory:"Physics" waves'GPL-3.0 - see LICENSE