Фільтри
Фільтри використовуються для отримання конкретного вмісту в REST API.
Приклад: фільтрувати новини за статусом ‘draft’
Section titled “Приклад: фільтрувати новини за статусом ‘draft’”?filter
Section titled “?filter”Як параметр запиту, ви можете використовувати фільтри для отримання конкретного вмісту за полем в REST API.
GET /api/cms/news?filter=status=draft
{ "time": { // ... }, "total": 2, "filtered": 1, "count": 1, "pk": "id", "rows": [ { "id": "8c16854ca914", "slug": "novina-1", "title": "Новина 1", "status": "published", "published_at": "2025-07-10 00:00:00", "meta": { "title": "SEO Title", "description": "SEO Description", "keywords": "cms" }, "created_at": "2025-07-08 09:18:12.017539", "updated_at": "2025-07-10 12:52:23.428295", "created_by": null, "updated_by": "2025-07-08 09:18:12.017539+03" } ], "columns": [ // ... ], "filters": [], "preview_path": null, "custom": true}
Приклад: знайти новину за ключовим словом ‘Breaking’
Section titled “Приклад: знайти новину за ключовим словом ‘Breaking’”?filter=search
Section titled “?filter=search”Як параметр запиту, ви можете шукати за ключовим словом в полях title
і slug
в REST API.
GET /api/cms/news?filter=search=Breaking
{ "time": { // ... }, "total": 2, "filtered": 1, "count": 1, "pk": "id", "rows": [ { "id": "8c16854ca914", "title": "Breaking News", "slug": "novina-1", //... }, // ... ]}
Приклад: знайти 3 новини зі статусом ‘draft’
Section titled “Приклад: знайти 3 новини зі статусом ‘draft’”?limit
Section titled “?limit”Як параметр запиту, ви можете обмежити кількість результатів, які повертаються в REST API.
GET /api/cms/news?filter=status=draft&limit=3
{ "time": { // ... }, "total": 5, "filtered": 3, "count": 3, "pk": "id", "rows": [ { "id": "8c16854ca914", "slug": "novina-1", "status": "draft", //... }, { "id": "8c16854ca915", "slug": "novina-2", "status": "draft", //... }, { "id": "8c16854ca916", "slug": "novina-3", "status": "draft", //... }, // ... ], "columns": [ // ... ], "filters": [], "preview_path": null, "custom": true}
Приклад: знайти опубліковані новини за датою в порядку спадання (новіші спочатку)
Section titled “Приклад: знайти опубліковані новини за датою в порядку спадання (новіші спочатку)”?order
Section titled “?order”Як параметр запиту, ви можете відсортувати результати за конкретним порядком (asc
або desc
) в REST API.
GET /api/cms/news?filter=status=published&order=published_at&desc=true
{ "time": { // ... }, "total": 5, "filtered": 2, "count": 2, "pk": "id", "rows": [ { "id": "8c16854ca914", "slug": "novina-2", "title": "Новина 2", "status": "published", "published_at": "2025-07-10 00:00:00", //... }, { "id": "c75763dc8ee7", "slug": "novina-1", "title": "Новина 1", "status": "published", "published_at": "2025-07-08 00:00:00", //... } ], "columns": [ // ... ], "filters": [], "preview_path": null, "custom": true}