Filtering API responses by content category
Use the contents_type
parameter to filter the results by content category.
Example Content
Check the results when filtering the following content:
Topic ID | Title | Content Category ID | Category Name |
---|---|---|---|
1152 | Article of parent category | 17 | Parent NEWS |
1153 | Article of child category | 54 | Child NEWS |
1154 | Article of grandchild category | 55 | Grandchild NEWS |
Content Category Settings:
Content List:
Narrowing down by contents_type
Filtering by contents_type
does not consider the parent-child relationships in content categories. Therefore, the list of content belonging to the specified content category is returned.
Filtering by contents_type=[17]
Only "Article of parent category" is displayed.
Request URL:
https://example.g.kuroco.app/rcms-api/13/news?contents_type%5B%5D=17
Response body:
{
"errors": [],
"messages": [],
"list": [
{
"topics_id": 1152,
"ymd": "2023-02-16",
"contents_type": 17,
"contents": "",
"subject": "Article of parent category",
・
・
・
}
],
"pageInfo": {
"totalCnt": 1,
・
・
・
}
}
Filtering by contents_type=[17,54]
"Article of parent category" and "Article of child category" are displayed.
Request URL:
https://example.g.kuroco.app/rcms-api/13/news?contents_type%5B%5D=17&contents_type%5B%5D=54
Response body:
{
"errors": [],
"messages": [],
"list": [
{
"topics_id": 1152,
"ymd": "2023-02-16",
"contents_type": 17,
"contents": "",
"subject": "Article of parent category",
・
・
・
},
{
"topics_id": 1153,
"ymd": "2023-02-16",
"contents_type": 54,
"contents": "",
"subject": "Article of child category",
・
・
・
}
],
"pageInfo": {
"totalCnt": 2,
・
・
・
}
}
Narrowing down by category_parent_id
Filtering by category_parent_id
considers the parent-child relationships in content categories. Therefore, the list of content belonging to the specified content category and its subcategories is returned.
Filtering by category_parent_id=[17]
"Article of parent category", "Article of child category", and "Article of grandchild category" are displayed.
Request URL:
https://example.g.kuroco.app/rcms-api/13/news?category_parent_id%5B%5D=17
Response body:
{
"errors": [],
"messages": [],
"list": [
{
"topics_id": 1152,
"ymd": "2023-02-16",
"contents_type": 17,
"contents": "",
"subject": "Article of parent category",
・
・
・
},
{
"topics_id": 1153,
"ymd": "2023-02-16",
"contents_type": 54,
"contents": "",
"subject": "Article of child category",
・
・
・
},
{
"topics_id": 1154,
"ymd": null,
"contents_type": 55,
"contents": "",
"subject": "Article of grandchild category",
・
・
・
}
],
"pageInfo": {
"totalCnt": 3,
・
・
・
}
}
Filtering by category_parent_id=[54]
"Article of child category" and "Article of grandchild category" are displayed.
Request URL:
https://example.g.kuroco.app/rcms-api/13/news?category_parent_id%5B%5D=54
Response body:
{
"errors": [],
"messages": [],
"list": [
{
"topics_id": 1153,
"ymd": "2023-02-16",
"contents_type": 54,
"contents": "",
"subject": "Article of child category",
・
・
・
},
{
"topics_id": 1154,
"ymd": null,
"contents_type": 55,
"contents": "",
"subject": "Article of grandchild category",
・
・
・
}
],
"pageInfo": {
"totalCnt": 2,
・
・
・
}
}
Narrowing down by exclude_category_parent_id
Using exclude_category_parent_id
allows you to exclude the list of content belonging to the specified content category and its subcategories from the response.
Filtering by exclude_category_parent_id=[54]
Only "Article of parent category" is displayed.
Request URL:
https://example.g.kuroco.app/rcms-api/13/news?exclude_category_parent_id%5B%5D=54
Response body:
{
"errors": [],
"messages": [],
"list": [
{
"topics_id": 1152,
"ymd": "2023-02-16",
"contents_type": 17,
"contents": "",
"subject": "Article of parent category",
・
・
・
}
],
"pageInfo": {
"totalCnt": 1,
・
・
・
}
}
Related Documentation
Support
If you have any other questions, please contact us or check out Our Slack Community.