> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: listCategories(options: ListCategoriesOptions) # Method package: wixBlogBackend # Method menu location: wixBlogBackend --> categories --> listCategories # Method Link: https://dev.wix.com/docs/velo/apis/wix-blog-backend/categories/list-categories.md # Method Description: Retrieves a list of up to 100 categories per request. If you pass a language filter to the method, it returns a list of up to 100 categories in the requested language. The categoies are displayed in order of their `displayPosition`, starting with `0`. The `displayPosition` is the position in which the categories are displayed in the Category Menu page. By default, categories get added to the bottom of the Category Menu page with a `displayPosition` of `-1`. List Categories runs with these defaults, which you can override: - `paging.limit` is `50`. - `paging.offset` is `0`. List Categories is sorted by `displayPosition` in descending order. This cannot be overridden. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## List blog categories ```javascript import { categories } from 'wix-blog-backend'; export async function listCategoriesFunction() { try { const result = await categories.listCategories(); const firstCategoryLabel = result.categories[0].label; const firstCategoryId = result.categories[0]._id; console.log('Retrieved Result:', result); return result; } catch (error) { console.error(error); } } /* Promise resolves to: * { * "categories": [ * { * "_id": "f489bf39-3297-4854-8429-e19dbefdca0e", * "coverImage": "wix:image://v1/162e66_f6bffd1cd6144ddf87325b82fe8f42ed~mv2.jpg#originWidth=385&originHeight=245", * "description": "my category description", * "displayPosition": 0, * "label": "My Category", * "language": "en", * "postCount": 1, * "slug": "my-category", * "title": "My Category", * "translationId": "dfc5b1a7-df04-4596-b311-9724f0477c3e" * }, * { * "_id": "1ea22fce-bc3c-4b78-9422-f0f367f8628e", * "description": "Posts about my summer", * "displayPosition": 1, * "label": "Summer", * "language": "en", * "postCount": 6, * "slug": "summer-slug" * "title": "My Category", * "translationId": "973369ad-0d4b-41f5-a820-1eed7986e0de" * }, * ], * "metaData": { * "count": 2, * "offset": 0, * "total": 2 * } * } */ ``` ## List blog categories (export from backend code) ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { categories } from 'wix-blog-backend'; export const listCategoriesFunction = webMethod(Permissions.Anyone, async () => { try { const result = await categories.listCategories(); const firstCategoryLabel = result.categories[0].label; const firstCategoryId = result.categories[0]._id; console.log('Retrieved Result:', result); return result; } catch (error) { console.error(error); } }); /* Promise resolves to: * { * "categories": [ * { * "_id": "f489bf39-3297-4854-8429-e19dbefdca0e", * "coverImage": "wix:image://v1/162e66_f6bffd1cd6144ddf87325b82fe8f42ed~mv2.jpg#originWidth=385&originHeight=245", * "description": "my category description", * "displayPosition": 0, * "label": "My Category", * "language": "en", * "postCount": 1, * "slug": "my-category", * "title": "My Category", * "translationId": "dfc5b1a7-df04-4596-b311-9724f0477c3e" * }, * { * "_id": "1ea22fce-bc3c-4b78-9422-f0f367f8628e", * "description": "Posts about my summer", * "displayPosition": 1, * "label": "Summer", * "language": "en", * "postCount": 6, * "slug": "summer-slug" * "title": "My Category", * "translationId": "973369ad-0d4b-41f5-a820-1eed7986e0de" * }, * ], * "metaData": { * "count": 2, * "offset": 0, * "total": 2 * } * } */ ``` ## List blog categories with additional fields and paging options ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { categories } from 'wix-blog-backend'; /* Sample options values: * { * fieldsets: [ * 'URL', * 'SEO', * ], * paging: { * limit: 2 * } * } */ export const listCategoriesFunction = webMethod(Permissions.Anyone, async (options) => { try { const result = await categories.listCategories(options); const firstCategoryLabel = result.categories[0].label; const firstCategoryId = result.categories[0]._id; console.log('Retrieved Result:', result); return result; } catch (error) { console.error(error); } }); /* Promise resolves to: * { * "categories": [ * { * "_id": "f489bf39-3297-4854-8429-e19dbefdca0e", * "coverImage": "wix:image://v1/162e66_f6bffd1cd6144ddf87325b82fe8f42ed~mv2.jpg#originWidth=385&originHeight=245", * "description": "my category description", * "displayPosition": 0, * "label": "My Category", * "language": "en", * "postCount": 1, * "seoData": { * "tags": [ * { * "type": "meta", * "props": { * "name": "description", * "content": "this is a category description" * }, * "children": "", * "custom": false, * "disabled": false * } * ] * }, * "slug": "my-category", * "title": "My Category", * "translationId": "dfc5b1a7-df04-4596-b311-9724f0477c3e", * "url": "http://https://tadasz7.wixsite.com/blog-velo-events/my-blog/categories/my-category" * }, * { * "_id": "1ea22fce-bc3c-4b78-9422-f0f367f8628e", * "description": "Posts about my summer", * "displayPosition": 1, * "label": "Summer", * "language": "en", * "postCount": 6, * "seoData": { * "tags": [ * { * "type": "meta", * "props": { * "name": "description", * "content": "Summer is the BEST season" * }, * "children": "", * "custom": false, * "disabled": false * } * ] * }, * "slug": "summer-slug" * "title": "Summer", * "translationId": "973369ad-0d4b-41f5-a820-1eed7986e0de", * "url": "http://https://tadasz7.wixsite.com/blog-velo-events/my-blog/categories/summer-slug" * }, * ], * "metaData": { * "count": 2, * "offset": 0, * "total": 6, * "cursor": "eyJmaWx0ZXIiOnt9LCJ2YWx1ZSI6eyJyYW5rIjowfSwib3JkZXIiOnsicmFuayI6MSwiX2lkIjoxfX0=" * } * } */ ``` ---