Wikipedia Commands

Overview

The netapi wiki commands provide CLI access to Wikipedia via two APIs. All commands support -f json for jq piping.

Prerequisites

No authentication required. Both APIs are public, free, and have no documented rate limits. Set a descriptive User-Agent for courtesy.

# No tokens or keys needed
netapi wiki summary "OAuth"

Commands (10 total)

Command Description

summary

Get article summary (title, description, extract)

search

Search articles by query

extract

Get full article text or specific sections

links

List links from an article

categories

List categories an article belongs to

langlinks

List available language versions

related

Get related articles

random

Get random article(s)

on-this-day

Events on a specific date

api

Raw API access

JSON Output

All commands support -f json for machine-readable output:

netapi wiki summary "OAuth" -f json
netapi wiki search "network access control" -f json
netapi wiki extract "RADIUS" -f json

jq Patterns

Exploring Structure

# See all keys in summary response
netapi wiki summary "OAuth" -f json | jq 'keys'

# Full summary object
netapi wiki summary "OAuth" -f json | jq '.'

Article Summaries

# Title + extract
netapi wiki summary "HMAC" -f json | jq '{title, description, extract}'

# Just the extract text
netapi wiki summary "802.1X" -f json | jq -r '.extract'

# Thumbnail URL
netapi wiki summary "Cisco Systems" -f json | jq -r '.thumbnail.source // "No thumbnail"'

# Article URL
netapi wiki summary "RADIUS" -f json | jq -r '.content_urls.desktop.page'

Search Results

# Search with title + snippet
netapi wiki search "network access control" -f json | jq '.[] | {title, snippet}'

# Titles only
netapi wiki search "certificate authority" -f json | jq -r '.[].title'

# Search with result count
netapi wiki search "authentication protocol" -f json | jq 'length'

Multi-Article Lookup

# Look up multiple terms
for term in "OAuth" "RADIUS" "802.1X" "HMAC" "TLS"; do
  netapi wiki summary "$term" -f json | jq --arg t "$term" '{term: $t, extract: .extract[0:150]}'
done | jq -s '.'

# Quick glossary
for term in "SAML" "LDAP" "Kerberos"; do
  netapi wiki summary "$term" -f json | jq -r '"\(.title): \(.description // .extract[0:100])"'
done

Full Article Extracts

# Full article text
netapi wiki extract "RADIUS" -f json | jq -r '.extract'

# First N characters
netapi wiki extract "OAuth" -f json | jq -r '.extract[0:500]'

Raw API Access

# REST v1: any endpoint
netapi wiki api /page/summary/OAuth | jq '.'

# Action API: any query
netapi wiki api "action=query&list=search&srsearch=firewall&format=json" | jq '.'

Environment Variables

Variable Description

WIKI_LANG

Language edition (default: en). Example: de, fr, ja

WIKI_USER_AGENT

Custom User-Agent (optional, courteous)

Useful jq Recipes

Quick Definition Lookup

netapi wiki summary "OAuth" -f json | jq -r '"\(.title) — \(.description)\n\n\(.extract)"'

Export Glossary to Markdown

for term in "OAuth" "SAML" "LDAP" "RADIUS" "Kerberos" "HMAC" "TLS" "802.1X"; do
  netapi wiki summary "$term" -f json | jq -r '"## \(.title)\n\(.extract[0:200])...\n"'
done

Compare Articles

# Side-by-side comparison
for term in "OAuth" "SAML"; do
  netapi wiki summary "$term" -f json | jq '{title, description, extract_length: (.extract | length)}'
done | jq -s '.'

curl Equivalents (Works Now)

These raw curl + jq patterns work today without the netapi CLI. No authentication required.

Article Summary (REST v1)

# Get article summary
curl -s "https://en.wikipedia.org/api/rest_v1/page/summary/OAuth" \
  | jq '{title, description, extract}'

# Quick definition
curl -s "https://en.wikipedia.org/api/rest_v1/page/summary/HMAC" \
  | jq -r '"\(.title): \(.extract[0:200])"'

# Multiple lookups
for term in "OAuth" "RADIUS" "802.1X" "HMAC" "TLS"; do
  curl -s "https://en.wikipedia.org/api/rest_v1/page/summary/${term}" \
    | jq -r '"\(.title): \(.description // .extract[0:80])"'
done

# Get article URL
curl -s "https://en.wikipedia.org/api/rest_v1/page/summary/Cisco_Systems" \
  | jq -r '.content_urls.desktop.page'

Search Articles (Action API)

# Search for articles
curl -s "https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=network+access+control&format=json&srlimit=5" \
  | jq '.query.search[] | {title, snippet: (.snippet | gsub("<[^>]+>"; ""))[0:120]}'

# Titles only
curl -s "https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=certificate+authority&format=json&srlimit=10" \
  | jq -r '.query.search[].title'

# Search with total hit count
curl -s "https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=authentication+protocol&format=json&srlimit=5" \
  | jq '{total: .query.searchinfo.totalhits, results: [.query.search[].title]}'

Full Article Extract

# Get full article text (plain text, no HTML)
curl -s "https://en.wikipedia.org/w/api.php?action=query&titles=RADIUS&prop=extracts&explaintext=true&format=json" \
  | jq -r '.query.pages[].extract[0:500]'

# Get article intro only
curl -s "https://en.wikipedia.org/w/api.php?action=query&titles=OAuth&prop=extracts&explaintext=true&exintro=true&format=json" \
  | jq -r '.query.pages[].extract'

Article Categories and Links

# Categories
curl -s "https://en.wikipedia.org/w/api.php?action=query&titles=RADIUS&prop=categories&format=json&cllimit=20" \
  | jq -r '.query.pages[].categories[].title'

# Outgoing links
curl -s "https://en.wikipedia.org/w/api.php?action=query&titles=OAuth&prop=links&format=json&pllimit=20" \
  | jq -r '.query.pages[].links[].title'

# Language versions available
curl -s "https://en.wikipedia.org/w/api.php?action=query&titles=OAuth&prop=langlinks&format=json&lllimit=50" \
  | jq -r '.query.pages[].langlinks[] | "\(.lang): \(.["*"])"'

Random Article

# Random article summary (needs -L to follow redirect)
curl -sL "https://en.wikipedia.org/api/rest_v1/page/random/summary" \
  | jq '{title, description, extract: .extract[0:200]}'

On This Day

# Events on today's date
curl -s "https://en.wikipedia.org/api/rest_v1/feed/onthisday/events/$(date +%m)/$(date +%d)" \
  | jq '.events[:5] | .[] | {year, text}'

Glossary Builder

# Build a security glossary in markdown
for term in "OAuth" "SAML" "LDAP" "RADIUS" "Kerberos" "HMAC" "TLS" "802.1X" "IPsec" "PKI"; do
  curl -s "https://en.wikipedia.org/api/rest_v1/page/summary/${term}" \
    | jq -r '"## \(.title)\n\(.description // "")\n\n\(.extract[0:300])...\n"'
done

# Security protocol comparison table
for term in "OAuth" "SAML" "Kerberos" "RADIUS"; do
  curl -s "https://en.wikipedia.org/api/rest_v1/page/summary/${term}" \
    | jq -r '"\(.title)\t\(.description // "—")"'
done | column -t -s$'\t'

Other Language Editions

# French Wikipedia
curl -s "https://fr.wikipedia.org/api/rest_v1/page/summary/OAuth" \
  | jq '{title, extract: .extract[0:200]}'

# Japanese Wikipedia
curl -s "https://ja.wikipedia.org/api/rest_v1/page/summary/OAuth" \
  | jq '{title, extract: .extract[0:200]}'