Search...
listGalleries( )
Developer Preview
Retrieves a list of galleries.
Description
The listGalleries()
function returns a Promise that resolves to a list of up to 10 galleries at a given time. To list the next 10 galleries in your site's backend, use the offset
parameter.
Syntax
function listGalleries(options: ListGalleriesOptions): Promise<ListGalleriesResponse>
listGalleries Parameters
NAME
TYPE
DESCRIPTION
options
Optional
ListGalleriesOptions
Options to use when getting the list of galleries.
Returns
Return Type:
Promise<
ListGalleriesResponse
>NAME
TYPE
DESCRIPTION
galleries
Array<
Gallery
>List of galleries. Sorted by _createdDate
.
totalGalleries
number
Total number of galleries in the site.
Was this helpful?
List Galleries
Copy Code
1import { proGallery } from 'wix-pro-gallery-backend';23export async function myListGalleriesFunction() {4 try {5 const galleries = await proGallery.listGalleries();67 const firstGalleryId = galleries[0]._id;8 const secondGalleryName = galleries[1].name;910 console.log('Success! Got a list of galleries:', galleries);11 return galleries;12 } catch (error) {13 console.error(error);14 // Handle the error15 }16}1718/* Promise resolves to:19 * {20 * "galleries": [21 * {22 * "_createdDate": "Mon Feb 08 2021 13:44:37",23 * "_id":"10874ccf-5867-4225-9550-3885079bad66",24 * "items": [25 * {26 * "_createdDate": Tue Mar 30 2021 15:23:22,27 * "_id": "534264c7-0c61-45ce-b414-891aacadf4c2",28 * "_updatedDate": Tue Mar 30 2021 15:23:22,29 * "description": "This is the first item in my gallery.",30 * "sortOrder": 1657439075188,31 * "tags": {32 * "values": ["pickles","salad","burger"]33 * },34 * "title": "Item 1",35 * "type": "VIDEO",36 * "video": {37 * "type": 'VIMEO',38 * "videoInfo": 'https://vimeo.com/322240916',39 * "duration": 500040 * }41 * },42 * {43 * "_createdDate": Sun Jul 03 2022 12:05:15,44 * "_id": "4507a07b-ab93-4326-a222-6d0bd8da0625",45 * "_updatedDate": Tues Jul 05 2022 10:25:45,46 * "description": "This is the second item in my gallery.",47 * "sortOrder": 1857439076299,48 * "title": "Item 2",49 * "type": "IMAGE",50 * "image": {51 * "imageInfo": "wix:image://v1/25139f9568b74d8aac6286c9ac1e8186.jpg/25139f9568b74d8aac6286c9ac1e8186.jpg#originWidth=4000&originHeight=2667"52 * }53 * }54 * ],55 * "name": "My First Gallery",56 * "sortOrder": "1098567432145",57 * "totalItems": 258 * },59 * {60 * "_createdDate": "Mon Feb 08 2021 13:44:37",61 * "_id":"10874ccf-5867-4225-9550-3885079bad66",62 * "items": [63 * {64 * "_createdDate": Tues Jul 05 2022 08:02:37,65 * "_id": "2297a07b-ab93-4326-a222-6d0bd8da0625",66 * "_updatedDate": Tues Jul 05 2022 10:25:45,67 * "description": "This is the second item in my gallery.",68 * "sortOrder": 1857439076299,69 * "title": "My only item",70 * "type": "VIDEO",71 * "video": {72 * "type": 'YOUTUBE',73 * "videoInfo": 'https://www.youtube.com/results?search_query=uplifting+upbeat+music',74 * "duration": 200075 * }76 * }77 * ],78 * "name": "My Second Gallery",79 * "sortOrder": "5568837432149",80 * "totalItems": 181 * }82 * ],83 * "totalGalleries": 284 * }85 */
List galleries with additional options
Copy Code
1import { proGallery } from 'wix-pro-gallery-backend';23/* Sample itemLimit value: 14 * Sample limit value: 15 * Sample offset value: 16 */78export async function myListGalleriesFunction(itemLimit, limit, offset) {9 try {10 const galleries = await proGallery.listGalleries({itemLimit, limit, offset});1112 const secondGalleryId = galleries[0]._id;13 const secondGalleryName = galleries[0].name;1415 console.log('Success! Got a list of galleries:', galleries);16 return galleries;17 } catch (error) {18 console.error(error);19 // Handle the error20 }21}2223/* Promise resolves to:24 * {25 * "galleries": [26 * {27 * "_createdDate": "Mon Feb 08 2021 13:44:37",28 * "_id":"10874ccf-5867-4225-9550-3885079bad66",29 * "items": [30 * {31 * "_createdDate": Tue Mar 30 2021 15:23:22,32 * "_id": "534264c7-0c61-45ce-b414-891aacadf4c2",33 * "_updatedDate": Tue Mar 30 2021 15:23:22,34 * "description": "This is the first item in my gallery.",35 * "sortOrder": 1657439075188,36 * "title": "Item 1",37 * "type": "IMAGE",38 * "image": {39 * "imageInfo": "wix:image://v1/38939f9568z222d6avc6285c9ac1e9129.jpg/38939f9568z222d6avc6285c9ac1e9129.jpg#originWidth=200&originHeight=199"40 * }41 * }42 * ],43 * "name": "My Second Gallery",44 * "sortOrder": "1098567432145",45 * "totalItems": 146 * }47 * ]48 * "totalGalleries": 2,49 */