DEV Community

Dave Parizek
Dave Parizek

Posted on • Updated on

How to Find the Page ID for a Wikipedia page (e.g. to use with the MediaWiki Action API)

If you use WikiPedia's API to access pages, such as to print a summary like I do here on this bell hooks quotes page, you sometimes need to know the actual WikiPedia Page ID of the page to successfully get the right information.

To explain better -- when using the MediaWiki Action API to access pages, you can search for a page and will often get an exact match, e.g. in Python code, the below call works:

wikipage = wikipedia.page("bell hooks")

(I am using the excellent Python library that wraps the WikiMedia API by Jon Goldsmith above)

but some terms do not return an exact match, or not the one you meant, e.g.:

wikipage = wikipedia.page("John Smith")

So instead you should use a wikipedia page id. Find this by going to wikipedia.org and finding your page, e.g: https://en.wikipedia.org/wiki/Bell_hooks. Then on that page -- in the left sidebar -- there is a "Tools" section:

Image description

Select the "Page Information" section under the Tools category.

Then you can see the Page ID:

Image description

Top comments (0)