Is there any API by which one can get all the categories of a page using the title or page id or url of that page? I tried searching on net but all I could find was getting dumps for specific categories. Any sort of help will be highly appreciated. Thanks
Categories are used in Wikipedia to link articles under a common topic and are found at the bottom of the article page. Clicking the category name displays a list of articles in that category, below a list of sub-categories (categories in that category) (if any).
Within the Toolbox section on the left-hand side of every page is a link labeled "What links here". This is used to see a list of the pages that link to (or redirect to, or transclude) the current page. These are sometimes referred to as backlinks.
The article categories are separated into nine major groups: Everyday life, Geography, History, Knowledge, Language, Literature, People, Religion, and Science. Each of these groups is separated into smaller groups or sub-categories which have even smaller groups inside them.
The API you are looking for is here https://en.wikipedia.org/w/api.php This is the media wiki API and has lots of documentation.
As said above you are looking for prop=categories so... ?format=xml&action=query&prop=categories&titles=Google for example
https://en.wikipedia.org/w/api.php?format=xml&action=query&prop=categories&titles=Google
If you are looking to use this in a program it may be worth looking at the following Wikipedia page that has a series of classes and libraries for various languages to deal with handling the Wikipedia API e.t.c
Wikipedia:Creating_a_bot#Programming_languages_and_libraries
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With