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.

Authorization

Request

This endpoint does not take any parameters

Response Object

NAME
TYPE
DESCRIPTION
galleries
Array<
Gallery
>

List of galleries. Sorted by _createdDate.

totalGalleries
number

Total number of galleries in the site.

Status/Error Codes

Was this helpful?

List Galleries

Copy Code
1import { proGallery } from 'wix-pro-gallery-backend';
2
3export async function myListGalleriesFunction() {
4 try {
5 const galleries = await proGallery.listGalleries();
6
7 const firstGalleryId = galleries[0]._id;
8 const secondGalleryName = galleries[1].name;
9
10 console.log('Success! Got a list of galleries:', galleries);
11 return galleries;
12 } catch (error) {
13 console.error(error);
14 // Handle the error
15 }
16}
17
18/* 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": 5000
40 * }
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": 2
58 * },
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": 2000
75 * }
76 * }
77 * ],
78 * "name": "My Second Gallery",
79 * "sortOrder": "5568837432149",
80 * "totalItems": 1
81 * }
82 * ],
83 * "totalGalleries": 2
84 * }
85 */
List galleries with additional options

Copy Code
1import { proGallery } from 'wix-pro-gallery-backend';
2
3/* Sample itemLimit value: 1
4 * Sample limit value: 1
5 * Sample offset value: 1
6 */
7
8export async function myListGalleriesFunction(itemLimit, limit, offset) {
9 try {
10 const galleries = await proGallery.listGalleries({itemLimit, limit, offset});
11
12 const secondGalleryId = galleries[0]._id;
13 const secondGalleryName = galleries[0].name;
14
15 console.log('Success! Got a list of galleries:', galleries);
16 return galleries;
17 } catch (error) {
18 console.error(error);
19 // Handle the error
20 }
21}
22
23/* 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": 1
46 * }
47 * ]
48 * "totalGalleries": 2,
49 */