I am using the following wikimedia API to list all pages with a certain category: https://www.mediawiki.org/wiki/API:Categorymembers
E.g. https://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Physics
This gives me a list of pages with title and id, but I would also like to see all categories for each page. However it seems that there is no cmprop for that.
cmprop: Which properties to get. (Default: ids|title)
ids: Page ID
title: Page title
sortkey: The sortkey used for sorting in the category (hexadecimal string)
sortkeyprefix: The sortkey prefix used for sorting in the category (human-readable part of the sortkey) 1.17+
type: Type that the page has been categorised as (page, subcat or file) 1.17+
timestamp: Time and date the article was added to the category
I have considered to query each page and use prop=categories to get the categories for each page, but that would mean a very large number of queries. Is there any better way of doing this?
Categories allow readers to navigate through Wikipedia and find related articles. Categories are not displayed in the mobile version. Mobile users can click "Desktop" at the bottom of a page to see the desktop version with categories. Registered users can enable Advanced mode which includes a "Categories" button.
Creating a category page A category is created by creating a page in the Category: namespace. A category page can be created the same way as other wiki pages (see Help:Starting a new page ); just add " Category: " before the page title. To avoid extra work, try searching within your wiki before creating a new category.
Simply scroll down to the bottom of a page and: Click on the Add category button, and start typing in a category name. You can use an already-established category (suggestions will appear as you type) or add a new one.
You can use categorymembers
as a generator. If you do that, you can then apply prop=categories
:
https://en.wikipedia.org/w/api.php?action=query&generator=categorymembers&gcmtitle=Category:Physics&prop=categories&cllimit=max&gcmlimit=max
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