Template:APIQuery categorymembers/doc: Difference between revisions
Appearance
Content deleted Content added
→Usage: split into sections, change API link to * mw:API:Categorymembers API details (on MediaWiki) in "see also" |
m Moving Category:Wikipedia utility templates to Category:Wikipedia formatting templates per Wikipedia:Categories for discussion/Log/2024 August 19#Category:Wikipedia utility templates |
||
(8 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{Documentation subpage}} |
{{Documentation subpage}} |
||
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --> |
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --> |
||
== Usage == |
== Usage == |
||
;Intended use: |
;Intended use: |
||
* Place this on a category page to generate a link call the Wikipedia API to generate a list of pages in the category, limited to 500 results. |
* Place this on a category page to generate a link to call the Wikipedia API to generate a list of pages in the category, limited to 500 results. |
||
;Other uses: |
;Other uses: |
||
* Use this any page to see the number of items in a category of the same name. This is potentially useful on article talk pages which have a category with an identical name. |
* Use this on any page to see the number of items in a category of the same name. This is potentially useful on article talk pages which have a category with an identical name. |
||
* Use this with the {{para|CATPAGE}} parameter to generate a link for a specific category. |
* Use this with the {{para|CATPAGE}} parameter to generate a link for a specific category. |
||
* Use this at [[Special:ExpandTemplates]]. Put the category |
* Use this at [[Special:ExpandTemplates]]. Put the category name in the <code>Context title, for {{FULLPAGENAME}}, etc.:</code> line and '''<nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki>}}</nowiki>''' with the appropriate parameters in the <code>Input wikitext:</code> line. |
||
* Use this multiple times with different parameters, to generate a list or table of links. |
* Use this multiple times with different parameters, to generate a list or table of links. |
||
Line 20: | Line 21: | ||
Note: Most of these are named after the parameters in the URL. Not all URL parameters are supported. |
Note: Most of these are named after the parameters in the URL. Not all URL parameters are supported. |
||
* {{para|CATPAGE}} - overrides the <nowiki>{{PAGENAME}}</nowiki> [[WP:MAGIC|magic word]]. |
* {{para|CATPAGE}} - overrides the <nowiki>{{PAGENAME}}</nowiki> [[WP:MAGIC|magic word]]. |
||
* {{para|cmprop}} - default is {{para||title}}. To add timestamps, use {{para||title<nowiki>{{!}}</nowiki>timestamp}}. |
* {{para|cmprop}} - default is {{para|cmprop|title}}. To add timestamps, use {{para|cmprop|title<nowiki>{{!}}</nowiki>timestamp}}. |
||
* {{para|cmnamespace}} - default is blank. To filter the results by namespace provide the number of the namespace, e.g. 0 (article), 1 (talk), etc. A full list is at [[Wikipedia:Namespace]]. |
* {{para|cmnamespace}} - default is blank. To filter the results by namespace provide the number of the namespace, e.g. 0 (article), 1 (talk), etc. A full list is at [[Wikipedia:Namespace]]. |
||
* {{para|format}} - Default is xml. Other formats supported by the '''query''' API are supported. |
* {{para|format}} - Default is xml. Other formats supported by the '''query''' API are supported. |
||
* {{para|cmsort}} - Default is no sorting. use {{para||timestamp}} to sort by time. See cmprop above. |
* {{para|cmsort}} - Default is no sorting. use {{para|cmsort|timestamp}} to sort by time. See cmprop above. |
||
* {{para|cmdir}} - Sorting direction, default is whatever the underlying API default is. {{para||desc}} or {{para||asc}}. |
* {{para|cmdir}} - Sorting direction, default is whatever the underlying API default is. {{para|cmsort|desc}} or {{para|cmsort|asc}}. |
||
;Example usage: |
;Example usage: |
||
*'''<nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki>|cmnamespace=1}}</nowiki>''' |
*'''<nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki>|cmnamespace=1}}</nowiki>''' |
||
*:generates a URL that will list |
*:generates a URL that will list articles in a category |
||
*'''<nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki>|cmnamespace=4|cmsort=timestamp|cmdir=desc|cmprop=title{{!}}timestamp}}</nowiki>''' |
*'''<nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki>|cmnamespace=4|cmsort=timestamp|cmdir=desc|cmprop=title{{!}}timestamp}}</nowiki>''' |
||
*:generates a URL that will list the user talk pages in a category, sorted by date, descending, with dates |
*:generates a URL that will list the user talk pages in a category, sorted by date, descending, with dates |
||
*'''<nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki>|format=json}}</nowiki>''' |
*'''<nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki>|format=json}}</nowiki>''' |
||
*:generates a URL that will generate JSON-formatted output |
*:generates a URL that will generate JSON-formatted output |
||
*'''<nowiki>{{</nowiki>{{BASEPAGENAME}}|<nowiki>cmnamespace=0|CATPAGE=Pages where |
*'''<nowiki>{{</nowiki>{{BASEPAGENAME}}|<nowiki>cmnamespace=0|CATPAGE=Pages where post-expand include size is exceeded}}</nowiki>''' |
||
*:generates an unsorted list of article pages in [[:Category:Pages where |
*:generates an unsorted list of article pages in [[:Category:Pages where post-expand include size is exceeded]]: |
||
*:<code>{{ {{BASEPAGENAME}}|cmnamespace=0|CATPAGE=Pages where |
*:<code>{{ {{BASEPAGENAME}}|cmnamespace=0|CATPAGE=Pages where post-expand include size is exceeded}}</code> |
||
== Technical details == |
== Technical details == |
||
Line 44: | Line 45: | ||
</nowiki> |
</nowiki> |
||
</code> |
</code> |
||
== Related templates == |
|||
* [[{{NAMESPACE}}:{{ROOTPAGENAME}}/row]] - creates a single row. Example: |
|||
*:{{{{NAMESPACE}}:{{ROOTPAGENAME}}/row|CATPAGE=Pages_where_post-expand_include_size_is_exceeded|cmnamespace=2}} |
|||
*:This example lists <code>User:</code> and <code>User talk:</code> pages in [[:Category:Pages where post-expand include size is exceeded]] |
|||
* [[{{NAMESPACE}}:{{ROOTPAGENAME}}/table]] - Table of all namespaces, using [[{{NAMESPACE}}:{{ROOTPAGENAME}}/row]] |
|||
== See also == |
== See also == |
||
* [[Special:TrackingCategories]] - a list of Wikipedia maintenance categories. This template may be useful in some of these categories. |
* [[Special:TrackingCategories]] - a list of Wikipedia maintenance categories. This template may be useful in some of these categories. |
||
* [[:mw:API:Categorymembers]] API details (on MediaWiki) |
* [[:mw:API:Categorymembers]] API details (on MediaWiki) |
||
* [[Help:Searching#incategory:]] Using the search box to find pages in a category, can be combined with other search features like namespace selection |
|||
<includeonly>{{sandbox other|| |
<includeonly>{{sandbox other|| |
||
<!-- Categories below this line, please; interwikis at Wikidata --> |
<!-- Categories below this line, please; interwikis at Wikidata --> |
||
[[ |
[[Category:Wikipedia formatting templates]] |
||
}}</includeonly> |
}}</includeonly> |
Latest revision as of 18:20, 15 October 2024
This is a documentation subpage for Template:APIQuery categorymembers. It may contain usage information, categories and other content that is not part of the original template page. |
Usage
[edit]- Intended use
- Place this on a category page to generate a link to call the Wikipedia API to generate a list of pages in the category, limited to 500 results.
- Other uses
- Use this on any page to see the number of items in a category of the same name. This is potentially useful on article talk pages which have a category with an identical name.
- Use this with the
|CATPAGE=
parameter to generate a link for a specific category.
- Use this at Special:ExpandTemplates. Put the category name in the
Context title, for Template:APIQuery categorymembers/doc, etc.:
line and {{APIQuery categorymembers}} with the appropriate parameters in theInput wikitext:
line.
- Use this multiple times with different parameters, to generate a list or table of links.
Parameters
[edit]Note: Most of these are named after the parameters in the URL. Not all URL parameters are supported.
|CATPAGE=
- overrides the {{PAGENAME}} magic word.|cmprop=
- default is|cmprop=title
. To add timestamps, use|cmprop=title{{!}}timestamp
.|cmnamespace=
- default is blank. To filter the results by namespace provide the number of the namespace, e.g. 0 (article), 1 (talk), etc. A full list is at Wikipedia:Namespace.|format=
- Default is xml. Other formats supported by the query API are supported.|cmsort=
- Default is no sorting. use|cmsort=timestamp
to sort by time. See cmprop above.|cmdir=
- Sorting direction, default is whatever the underlying API default is.|cmsort=desc
or|cmsort=asc
.
- Example usage
- {{APIQuery categorymembers|cmnamespace=1}}
- generates a URL that will list articles in a category
- {{APIQuery categorymembers|cmnamespace=4|cmsort=timestamp|cmdir=desc|cmprop=title{{!}}timestamp}}
- generates a URL that will list the user talk pages in a category, sorted by date, descending, with dates
- {{APIQuery categorymembers|format=json}}
- generates a URL that will generate JSON-formatted output
- {{APIQuery categorymembers|cmnamespace=0|CATPAGE=Pages where post-expand include size is exceeded}}
- generates an unsorted list of article pages in Category:Pages where post-expand include size is exceeded:
//en.wikipedia.org/enwiki/w/api.php?action=query&list=categorymembers&cmtitle=Category:Pages_where_post-expand_include_size_is_exceeded&cmprop=title&cmlimit=500&cmnamespace=0&format=xml
Technical details
[edit]This template generates a "plain link" URL whose text is the namespace if the |csnamespace=
parameter is used.
//en.wikipedia.org/enwiki/w/api.php?action=query&list=categorymembers&cmtitle=Category%3A{{{CATPAGE|{{PAGENAMEE}}}}}&cmprop={{{cmprop|title}}}&cmlimit=500&cmnamespace={{{cmnamespace|}}}&format={{{format|xml}}}{{#if: {{{cmsort|}}}|&cmsort={{{cmsort}}}}}{{#if: {{{cmdir|}}}|&cmdir={{{cmdir}}}
Related templates
[edit]- Template:APIQuery categorymembers/row - creates a single row. Example:
- User, (recent), User talk, (recent)
- This example lists
User:
andUser talk:
pages in Category:Pages where post-expand include size is exceeded
- Template:APIQuery categorymembers/table - Table of all namespaces, using Template:APIQuery categorymembers/row
See also
[edit]- Special:TrackingCategories - a list of Wikipedia maintenance categories. This template may be useful in some of these categories.
- mw:API:Categorymembers API details (on MediaWiki)
- Help:Searching#incategory: Using the search box to find pages in a category, can be combined with other search features like namespace selection