> 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 # QueryBranches # Package: branches # Namespace: BranchesService # Method link: https://dev.wix.com/docs/api-reference/business-management/branches/query-branches.md ## Permission Scopes: Manage Site Branches: SCOPE.DC-DOCUMENT-MANAGEMENT.MANAGE-BRANCHES ## Introduction Retrieves a list of branches, given the provided paging, filtering, and sorting. Query Branches runs with these defaults, which you can override: - `updatedDate` is sorted in `DESC` order - `paging.limit` is `50` - `paging.offset` is `0` To learn how to query branches, see [API Query Language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md). --- ## REST API ### Schema ``` Method: queryBranches Description: Retrieves a list of branches, given the provided paging, filtering, and sorting. Query Branches runs with these defaults, which you can override: - `updatedDate` is sorted in `DESC` order - `paging.limit` is `50` - `paging.offset` is `0` To learn how to query branches, see [API Query Language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md). URL: https://www.wixapis.com/branches/v1/branches/query Method: POST Method parameters: param name: query | type: CursorQuery - name: cursorPaging | type: CursorPaging | description: Cursor paging options. Learn more about [cursor paging](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md#cursor-paging). - 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. Learn more about [filtering](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md#filters). - name: sort | type: array | description: Sort object. Learn more about [sorting](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md#sorting). - name: fieldName | type: string | description: Name of the field to sort by. - name: order | type: SortOrder | description: Sort order. - enum: ASC, DESC Return type: QueryBranchesResponse - name: branches | type: array | description: List of branches. - ONE-OF: - name: sourceBranchProperties | type: SourceBranch | description: Source branch properties. Use when `sourceType` = `SOURCE_BRANCH`. - name: branchId | type: string | description: Source branch GUID. - name: branchRevision | type: string | description: Revision number of the source branch when this branch was created. To prevent conflicting changes, the current revision must be passed when updating the branch. - name: sourceTemplateProperties | type: SourceTemplate | description: Source template properties. Use when `sourceType` = `SOURCE_TEMPLATE`. - name: templateId | type: string | description: Source template GUID. - name: id | type: string | description: Branch GUID. - name: revision | type: string | description: Revision number, which increments by 1 each time the branch is updated. To prevent conflicting changes, the current revision must be passed when updating the branch. - name: type | type: Type | description: Branch type. - enum: - USER: A branch created by a site owner that can be accessed for editing and publishing in the editor. - TECHNICAL: A branch created for technical purposes, unrelated to site owners. For internal use, can't be accessed in the editor. - ORIGINAL_BRANCH: The original branch of the site, created when the site is created. Can be accessed for editing and publishing in the editor. - name: name | type: string | description: Branch name. - name: sourceType | type: SourceType | description: Source type for this branch's content. Must be aligned with the corresponding source properties below. - enum: - SOURCE_BRANCH: This branch's source was another branch. Must be used with `sourceBranchProperties`. - name: lastPublishDate | type: string | description: Date and time the branch was last published. - name: editorType | type: EditorType | description: Wix editor type. - name: editorTypeOptions | type: EditorTypeOptions | description: Wix editor types. - enum: - STUDIO: Wix Studio Editor. - CLASSIC: Wix's Classic Editor. - name: default | type: boolean | description: Whether this branch is the default branch. The default branch is used for API operations when no branch GUID is specified. - name: createdDate | type: string | description: Date and time the branch was created. - name: updatedDate | type: string | description: Date and time the branch was last updated. - name: extendedFields | type: ExtendedFields | description: Custom field data for the branch. [Extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md) must be configured in the app dashboard before they can be accessed with API calls. - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured. You can only access fields for which you have the appropriate permissions. Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md). - name: tags | type: PublicTags | description: Public tags assigned to the branch. - name: tags | type: TagList | description: Tags that are exposed to anyone who has access to the labeled entity itself, including site members and visitors. - name: tagIds | type: array | description: List of tag GUIDs. - name: pagingMetadata | type: CursorPagingMetadata | description: Metadata for the paginated results. - name: count | type: integer | description: Number of items returned in the response. - name: cursors | type: Cursors | description: Cursor strings that point to the next page, previous page, or both. - 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. - name: hasNext | type: boolean | description: Whether there are more pages to retrieve following the current page. + `true`: Another page of results can be retrieved. + `false`: This is the last page. ``` ### Examples ### Query Branches Gets branches by filters and sorting ```curl curl -X POST \ 'https://www.wixapis.com/branches/v1/branches/query' \ -H 'Authorization: ' \ -H 'Content-Type: application/json' \ -d '{"query":{ "filter": {"type": "TECHNICAL"}, "sort": [ { "fieldName": "createdDate", "order": "DESC" } ], "cursorPaging": {"limit": 2} } }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.branches.BranchesService.queryBranches(query) Description: Retrieves a list of branches, given the provided paging, filtering, and sorting. Query Branches runs with these defaults, which you can override: - `updatedDate` is sorted in `DESC` order - `paging.limit` is `50` - `paging.offset` is `0` To learn how to query branches, see [API Query Language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md). # 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: BranchQuery | required: true - name: cursorPaging | type: CursorPaging | description: Cursor paging options. Learn more about [cursor paging](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md#cursor-paging). - 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. Learn more about [filtering](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md#filters). - name: sort | type: array | description: Sort object. Learn more about [sorting](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md#sorting). - 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: branches | type: array | description: List of branches. - ONE-OF: - name: sourceBranchProperties | type: SourceBranch | description: Source branch properties. Use when `sourceType` = `SOURCE_BRANCH`. - name: branchId | type: string | description: Source branch GUID. - name: branchRevision | type: string | description: Revision number of the source branch when this branch was created. To prevent conflicting changes, the current revision must be passed when updating the branch. - name: sourceTemplateProperties | type: SourceTemplate | description: Source template properties. Use when `sourceType` = `SOURCE_TEMPLATE`. - name: templateId | type: string | description: Source template GUID. - name: _id | type: string | description: Branch GUID. - name: revision | type: string | description: Revision number, which increments by 1 each time the branch is updated. To prevent conflicting changes, the current revision must be passed when updating the branch. - name: type | type: Type | description: Branch type. - enum: - USER: A branch created by a site owner that can be accessed for editing and publishing in the editor. - TECHNICAL: A branch created for technical purposes, unrelated to site owners. For internal use, can't be accessed in the editor. - ORIGINAL_BRANCH: The original branch of the site, created when the site is created. Can be accessed for editing and publishing in the editor. - name: name | type: string | description: Branch name. - name: sourceType | type: SourceType | description: Source type for this branch's content. Must be aligned with the corresponding source properties below. - enum: - SOURCE_BRANCH: This branch's source was another branch. Must be used with `sourceBranchProperties`. - name: lastPublishDate | type: string | description: Date and time the branch was last published. - name: editorType | type: EditorType | description: Wix editor type. - name: editorTypeOptions | type: EditorTypeOptions | description: Wix editor types. - enum: - STUDIO: Wix Studio Editor. - CLASSIC: Wix's Classic Editor. - name: default | type: boolean | description: Whether this branch is the default branch. The default branch is used for API operations when no branch GUID is specified. - name: _createdDate | type: Date | description: Date and time the branch was created. - name: _updatedDate | type: Date | description: Date and time the branch was last updated. - name: extendedFields | type: ExtendedFields | description: Custom field data for the branch. [Extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md) must be configured in the app dashboard before they can be accessed with API calls. - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured. You can only access fields for which you have the appropriate permissions. Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md). - name: tags | type: PublicTags | description: Public tags assigned to the branch. - name: tags | type: TagList | description: Tags that are exposed to anyone who has access to the labeled entity itself, including site members and visitors. - name: tagIds | type: array | description: List of tag GUIDs. - name: pagingMetadata | type: CursorPagingMetadata | description: Metadata for the paginated results. - name: count | type: integer | description: Number of items returned in the response. - name: cursors | type: Cursors | description: Cursor strings that point to the next page, previous page, or both. - 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. - name: hasNext | type: boolean | description: Whether there are more pages to retrieve following the current page. + `true`: Another page of results can be retrieved. + `false`: This is the last page. ``` ### Examples ### queryBranches ```javascript import { branches } from '@wix/editor-branches'; async function queryBranches(query) { const response = await branches.queryBranches(query); }; ``` ### queryBranches (with elevated permissions) ```javascript import { branches } from '@wix/editor-branches'; import { auth } from '@wix/essentials'; async function myQueryBranchesMethod(query) { const elevatedQueryBranches = auth.elevate(branches.queryBranches); const response = await elevatedQueryBranches(query); } ``` ### queryBranches (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 { branches } from '@wix/editor-branches'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { branches }, // Include the auth strategy and host as relevant }); async function queryBranches(query) { const response = await myWixClient.branches.queryBranches(query); }; ``` ---