Skip to content

Instantly share code, notes, and snippets.

@velizarn
Created July 2, 2025 18:09
Show Gist options
  • Save velizarn/28959acff325a8c86032917d1e7027ed to your computer and use it in GitHub Desktop.
Save velizarn/28959acff325a8c86032917d1e7027ed to your computer and use it in GitHub Desktop.
Wikipedia API - Search for a content

Example search for Megadeth album Rust In Peace

parameters:

  • action=query
  • format=json
  • prop=info
  • titles=Megadeth Rust In Peace|Rust In Peace|Rust_In_Peace
  • formatversion=2
curl --location 'https://en.wikipedia.org/w/api.php?action=query&format=json&titles=Megadeth%20Rust%20In%20Peace%7CRust%20In%20Peace%7CRust_In_Peace&prop=info&formatversion=2'

Response:

{
    "batchcomplete": true,
    "query": {
        "normalized": [
            {
                "fromencoded": false,
                "from": "Rust_In_Peace",
                "to": "Rust In Peace"
            }
        ],
        "pages": [
            {
                "ns": 0,
                "title": "Megadeth Rust In Peace",
                "missing": true,
                "contentmodel": "wikitext",
                "pagelanguage": "en",
                "pagelanguagehtmlcode": "en",
                "pagelanguagedir": "ltr"
            },
            {
                "pageid": 228128,
                "ns": 0,
                "title": "Rust In Peace",
                "contentmodel": "wikitext",
                "pagelanguage": "en",
                "pagelanguagehtmlcode": "en",
                "pagelanguagedir": "ltr",
                "touched": "2025-06-25T15:53:36Z",
                "lastrevid": 783933256,
                "length": 92,
                "redirect": true
            }
        ]
    }
}

Get the page actual content by using pageid:

curl https://en.wikipedia.org/?curid=228128

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment