> 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 # QueryCollections # Package: catalogV1 # Namespace: CatalogReadApi # Method link: https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v1/catalog/query-collections.md ## Permission Scopes: Read Products: SCOPE.DC-STORES.READ-PRODUCTS ## Introduction ::::tabs :::REST_TAB ::: :::SDK_TAB > **Note**: This query method uses the new Wix API Query Language syntax. If you're still using the old query syntax with chained query builder methods, see [Migrate from SDK Query Builders to Wix API Query Language](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/migrate-from-sdk-query-builders-to-wix-api-query-language.md ) for guidance. The old query builder methods continue to work. ::: :::: Retrieves a list of up to 100 collections, given the provided paging, sorting and filtering. See [Stores Pagination](https://dev.wix.com/api/rest/wix-stores/pagination) for more information. --- ## REST API ### Schema ``` Method: queryCollections Description: ::::tabs :::REST_TAB ::: :::SDK_TAB > **Note**: This query method uses the new Wix API Query Language syntax. If you're still using the old query syntax with chained query builder methods, see [Migrate from SDK Query Builders to Wix API Query Language](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/migrate-from-sdk-query-builders-to-wix-api-query-language.md ) for guidance. The old query builder methods continue to work. ::: :::: Retrieves a list of up to 100 collections, given the provided paging, sorting and filtering. See [Stores Pagination](https://dev.wix.com/api/rest/wix-stores/pagination) for more information. URL: https://www.wixapis.com/stores-reader/v1/collections/query Method: POST Method parameters: param name: includeDescription | type: includeDescription | description: Wether to include collection description in the response. When `false` is passed, `collection.description` will return null. param name: includeNumberOfProducts | type: includeNumberOfProducts | description: Whether number of products should be included in the response. param name: query | type: Query - name: paging | type: Paging | description: - name: limit | type: integer | description: Amount of items to load per page - name: offset | type: integer | description: Number of items to skip in the display (relevant for all pages after the first) - name: filter | type: string | description: Filter string - name: sort | type: string | description: Sort string Return type: QueryCollectionsResponse - name: collections | type: array | description: List of collections. - name: id | type: string | description: Collection GUID (generated automatically by the catalog). - name: name | type: string | description: Collection name. - name: media | type: Media | description: Media items (images, videos etc) associated with this collection. Read only. - name: mainMedia | type: MediaItem | description: Primary media (image, video etc) associated with this product. - ONE-OF: - name: image | type: MediaItemUrlAndSize | description: Image data (URL, size). - name: url | type: string | description: Media item URL. - name: width | type: integer | description: Media item width. - name: height | type: integer | description: Media item height. - name: format | type: string | description: Media format (mp4, png, etc.). - name: altText | type: string | description: Alt text. This text will be shown in case the image is not available. - name: video | type: MediaItemVideo | description: Video data (URL, size). - name: files | type: array | description: Data (URL, size) about each resolution for which this video is available. - name: stillFrameMediaId | type: string | description: GUID of an image taken from the video. Used primarily for Wix Search indexing. For example, `"nsplsh_306d666a123a4a74306459~mv2_d_4517_2992_s_4_2.jpg"`. - name: thumbnail | type: MediaItemUrlAndSize | description: Media item thumbnail details. - name: mediaType | type: MediaItemType | description: Media item type (image, video, etc.). - enum: - unspecified_media_item_type: - image: Image media type. - video: Video media type. - audio: Audio media type. - document: Document media type. - zip: Zip media type. - name: title | type: string | description: Media item title. - name: id | type: string | description: Media GUID (for example, `"nsplsh_306d666a123a4a74306459~mv2_d_4517_2992_s_4_2.jpg"`). - name: items | type: array | description: Media (images, videos etc) associated with this product. - name: numberOfProducts | type: integer | description: Number of products in the collection. Read only. - name: description | type: string | description: Collection description. - name: slug | type: string | description: Collection slug. - name: visible | type: boolean | description: Collection visibility. Only impacts dynamic pages, no impact on static pages. Default: `true`. - name: metadata | type: PagingMetadata | description: Details on the paged set of results returned. - name: items | type: integer | description: Amount of items to load per page - name: offset | type: integer | description: Number of items to skip in the display (relevant for all pages after the first) - name: totalResults | type: integer | description: Total number of results returned. ``` ### Examples ### QueryCollections ```curl ~~~cURL curl -X POST \ 'https://www.wixapis.com/stores/v1/collections/query' \ --data-binary '{ "query": {}, "includeNumberOfProducts": true, "includeDescription": true }' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' ~~~ ``` ### QueryCollections ```curl ~~~cURL curl -X POST \ 'https://www.wixapis.com/stores/v1/collections/query' \ --data-binary '{ "query": { "filter": { "name": "my collection" } } }' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' ~~~ ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.catalogV1.CatalogReadApi.queryCollections(query) Description: ::::tabs :::REST_TAB ::: :::SDK_TAB > **Note**: This query method uses the new Wix API Query Language syntax. If you're still using the old query syntax with chained query builder methods, see [Migrate from SDK Query Builders to Wix API Query Language](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/migrate-from-sdk-query-builders-to-wix-api-query-language.md ) for guidance. The old query builder methods continue to work. ::: :::: Retrieves a list of up to 100 collections, given the provided paging, sorting and filtering. See [Stores Pagination](https://dev.wix.com/api/rest/wix-stores/pagination) for more information. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: query Method parameters: param name: query | type: CollectionQuery | required: true - ONE-OF: - required: true - name: paging | type: PlatformPaging | description: Pointer to page of results using offset. Cannot be used together with `cursorPaging`. - name: limit | type: integer | description: Number of items to load. - name: offset | type: integer | description: Number of items to skip in the current sort order. - name: cursorPaging | type: CursorPaging | description: Cursor pointing to page of results. Cannot be used together with `paging`. `cursorPaging.cursor` can not be used together with `filter` or `sort`. - name: limit | type: integer | description: Maximum number of items to return in the results. - name: cursor | type: string | description: Pointer to the next or previous page in the list of results. Pass the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request. - name: filter | type: object | description: Filter object. - name: sort | type: array | description: Sorting options. For example, `[{"fieldName":"sortField1"},{"fieldName":"sortField2","direction":"DESC"}]`. - name: fieldName | type: string | description: Name of the field to sort by. - name: order | type: SortOrder | description: Sort order. - enum: ASC, DESC Return type: PROMISE - name: collections | type: array | description: - name: _id | type: string | description: Collection GUID (generated automatically by the catalog). - name: name | type: string | description: Collection name. - name: media | type: Media | description: Media items (images, videos etc) associated with this collection. Read only. - name: mainMedia | type: MediaItem | description: Primary media (image, video etc) associated with this product. - ONE-OF: - name: image | type: MediaItemUrlAndSize | description: Image data (URL, size). - name: url | type: string | description: Media item URL. - name: width | type: integer | description: Media item width. - name: height | type: integer | description: Media item height. - name: format | type: string | description: Media format (mp4, png, etc.). - name: altText | type: string | description: Alt text. This text will be shown in case the image is not available. - name: video | type: MediaItemVideo | description: Video data (URL, size). - name: files | type: array | description: Data (URL, size) about each resolution for which this video is available. - name: stillFrameMediaId | type: string | description: GUID of an image taken from the video. Used primarily for Wix Search indexing. For example, `"nsplsh_306d666a123a4a74306459~mv2_d_4517_2992_s_4_2.jpg"`. - name: thumbnail | type: MediaItemUrlAndSize | description: Media item thumbnail details. - name: mediaType | type: MediaItemType | description: Media item type (image, video, etc.). - enum: - unspecified_media_item_type: - image: Image media type. - video: Video media type. - audio: Audio media type. - document: Document media type. - zip: Zip media type. - name: title | type: string | description: Media item title. - name: _id | type: string | description: Media GUID (for example, `"nsplsh_306d666a123a4a74306459~mv2_d_4517_2992_s_4_2.jpg"`). - name: items | type: array | description: Media (images, videos etc) associated with this product. - name: numberOfProducts | type: integer | description: Number of products in the collection. Read only. - name: description | type: string | description: Collection description. - name: slug | type: string | description: Collection slug. - name: visible | type: boolean | description: Collection visibility. Only impacts dynamic pages, no impact on static pages. Default: `true`. - name: metadata | type: PlatformPagingMetadata | description: - name: count | type: integer | description: The number of items returned in this response. - name: offset | type: integer | description: The offset which was requested. Returned if offset paging was used. - name: total | type: integer | description: The total number of items that match the query. Returned if offset paging was used. - name: cursors | type: Cursors | description: Cursors to navigate through result pages. Returned if cursor paging was used. - name: next | type: string | description: Cursor string pointing to the next page in the list of results. - name: prev | type: string | description: Cursor pointing to the previous page in the list of results. ``` ### Examples ### Query collections with name filter ```javascript import { collections } from "@wix/stores"; const options = { query: { filter: { name: "my collection" } } }; async function queryCollections() { const response = await collections.queryCollections(options); } /* Promise resolves to: * { * "collections": [ * { * "_id": "00000000-000000-000000-000000000001", * "name": "my collection", * "slug": "my-collection", * "visible": true, * "media": { * "mainMedia": { * "thumbnail": { * "url": "https://static.wixstatic.com/media/...", * "width": 50, * "height": 50 * }, * "mediaType": "image", * "image": { * "url": "https://static.wixstatic.com/media/...", * "width": 2489, * "height": 2251 * } * }, * "items": [...] * } * }, * { * "_id": "7f79cca8-80b6-d24b-e6f8-356187d95050", * "name": "C A C T I", * "slug": "c-a-c-t-i", * "visible": true, * "media": { * "mainMedia": { * "thumbnail": { * "url": "https://static.wixstatic.com/media/...", * "width": 50, * "height": 50 * }, * "mediaType": "image", * "image": { * "url": "https://static.wixstatic.com/media/...", * "width": 1920, * "height": 1920 * } * }, * "items": [...] * } * } * ], * "pagingMetadata": { * "count": 100, * "offset": 0 * }, * "totalCount": 2 * } */ ``` ### Query collections with product counts and descriptions ```javascript import { collections } from "@wix/stores"; const options = { query: {}, includeNumberOfProducts: true, includeDescription: true }; async function queryCollections() { const response = await collections.queryCollections(options); } /* Promise resolves to: * { * "collections": [ * { * "_id": "00000000-000000-000000-000000000001", * "name": "All Products", * "slug": "all-products", * "visible": true, * "description": "All of the products in the store", * "media": { * "items": [] * }, * "numberOfProducts": 6 * }, * { * "_id": "32fd0b3a-2d38-2235-7754-78a3f819274a", * "name": "Coffee Products", * "slug": "coffee-products", * "visible": true, * "description": "Coffee related products", * "media": { * "mainMedia": { * "thumbnail": { * "url": "https://static.wixstatic.com/media/...", * "width": 50, * "height": 50 * }, * "mediaType": "image", * "image": { * "url": "https://static.wixstatic.com/media/...", * "width": 6630, * "height": 5304 * } * }, * "items": [...] * }, * "numberOfProducts": 5 * } * ], * "pagingMetadata": { * "count": 100, * "offset": 0 * }, * "totalCount": 2 * } */ ``` ### queryCollections (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { products } from '@wix/stores'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { products }, // Include the auth strategy and host as relevant }); async function queryCollections(query) { const response = await myWixClient.products.queryCollections(query); }; ``` ---