> 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: queryEvents() # Method package: wixEventsBackend # Method menu location: wixEventsBackend --> WixEvents --> queryEvents # Method Link: https://dev.wix.com/docs/velo/apis/wix-events-backend/wix-events/query-events.md # Method Description: Creates a query to retrieve a list of Wix events. The `queryEvents()` function builds a query to retrieve a list of Wix events and returns an [EventsQueryBuilder](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/introduction.md) object. The returned object contains the query definition which is typically used to run the query using the [`find()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/find.md) function. You can refine the query by chaining `EventsQueryBuilder` functions onto the query. `EventsQueryBuilder` functions enable you to sort, filter, and control the results that `queryEvents.find()` returns. The query runs with the following `EventsQueryBuilder` defaults that you can override: + [`limit`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/limit.md): `50` + [`descending`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/descending.md): `_createdDate` The functions that are chained to `queryEvents()` are applied in the order they are called. For example, if you sort on the `_createdDate` property in ascending order and then on the `status` property in descending order, the results are sorted first by the created date of the items and then, if there are multiple results with the same date, the items are sorted by status in descending order, per created date value. The following `EventsQueryBuilder` functions are supported for `queryEvents()`. For a full description of the Wix Event object, see the object returned for the [`items`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-result/items.md) property in [`EventsQueryResult`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-result/introduction.md). | Property | Supported Filters & Sorting | | ---------------------------- | ------------------------------------------------------------------------------------------ | |`_id` |[`eq()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/eq.md), [`ne()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/ne.md), [`hasSome()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/has-some.md) | |`title` |[`eq()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/eq.md), [`ne()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/ne.md), [`lt()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/lt.md), [`le()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/le.md), [`gt()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/gt.md), [`ge()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/ge.md), [`hasSome()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/has-some.md), [`contains()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/contains.md),[`ascending()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/ascending.md), [`descending()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/descending.md) | |`status` |[`eq()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/eq.md), [`ne()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/ne.md), [`hasSome()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/has-some.md), [`contains()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/contains.md) | |`createdBy` |[`eq()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/eq.md), [`ne()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/ne.md), [`hasSome()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/has-some.md) | |`scheduling.startDate` |[`lt()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/lt.md), [`le()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/le.md), [`gt()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/gt.md), [`ge()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/ge.md), [`ascending()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/ascending.md), [`descending()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/descending.md) | |`scheduling.endDate` |[`lt()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/lt.md), [`le()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/le.md), [`gt()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/gt.md), [`ge()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/ge.md), [`ascending()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/ascending.md), [`descending()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/descending.md) | |`_createdDate` |[`ascending()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/ascending.md), [`descending()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/descending.md) | |`_updatedDate` |[`ascending()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/ascending.md), [`descending()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/descending.md) | |`slug` |[`eq()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/eq.md), [`ne()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/ne.md), [`lt()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/lt.md), [`le()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/le.md), [`gt()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/gt.md), [`ge()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/ge.md), [`hasSome()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/has-some.md), [`contains()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/contains.md), [`ascending()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/ascending.md), [`descending()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/descending.md) | You can only use one filter function for each property. If a property is used in more than one filter, only the first filter will work. >**Notes:** > + A guest can only see their own Wix events unless `suppressAuth` is set to `true` in the queryOptions for the [`find()`](https://dev.wix.com/docs/velo/api-reference/wix-events-backend/wix-events/events-query-builder/find.md) function. > + When using the `queryEvents()` function immediately following a change to your Wix events, the data retrieved may not contain your most recent changes. See [Wix Data and Eventual Consistency](https://dev.wix.com/docs/velo/apis/wix-data/introduction.md#apis_wix-data_wix-data-and-eventual-consistency) for more information. To solve this problem, you can use the [`setTimeout()`](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Timeouts_and_intervals#setTimeout) function to delay querying for a number of seconds, following any changes to your Wix events data. Only those with "Manage Events" permissions can query Wix events. Only the events they are authorized to receive are returned. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Retrieve the newest Wix event that has the "SCHEDULED" status ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { wixEvents } from 'wix-events-backend'; export const myQueryEventsFunction = webMethod(Permissions.Anyone, async () => { try { await wixEvents.queryEvents() .hasSome("status", ["SCHEDULED"]) .descending("createdDate") .find() .then((results) => { const items = results.items; const firstItem = items[0]; console.log('Success! Events:', firstItem); return firstItem; }) } catch (error) { console.error(error); // Handle the error } }); /* Promise resolves to: { "about": "Join us for Nature's Symphony: A Musical Journey Through Wildlife at the iconic Royal Albert Hall.", "assignedContactsLabel": "custom.natures-symphony-a-musical-journey-through-wildl", "calendarLinks": { "google": "http://calendar.google.com/calendar/render?action=TEMPLATE&text=Nature%27s+Symphony%3A+A+Musical+Journey+Through+Wildlife.&dates=&location=Kensington+Gore%2C+London+SW7%2C+UK&details=Thank+you+for+registering+to+our+event%21+Your+tickets+are+attached+to+this+email.+Don%27t+forget+to+bring+them.%0A%0AWe%27re+looking+forward+to+seeing+you+there.%0A%0AHere+are+the+details%3A%0A%0ANature%27s+Symphony%3A+A+Musical+Journey+Through+Wildlife.%0AThe+date+will+be+announced+soon%2C+stay+tuned%21%0ARoyal+Albert+Hall%2C+Kensington+Gore%2C+London+SW7%2C+UK", "ics": "https://www.wixevents.com/media/v2/calendar?token=JWS.eyJraWQiOiJpb21iOUJ0eSIsImFsZyI6IkhTMjU2In0.eyJkYXRhIjoie1wiaW5zdGFuY2VJZFwiOlwiMWY2ZGM5MDYtODAzZC00NjUwLTgzZjUtNzJlYTFkODgxMDBiXCIsXCJldmVudElkXCI6e1widmFsdWVcIjpcImQxNTJmNDJjLTcyMWMtNDc3MC1hMTc4LWYwZTZjMWQ1NWYyN1wifSxcIm9jTGlua1wiOm51bGx9IiwiaWF0IjoxNjk5NTMxNjUzfQ.tiiCPGnU-ZD9ZKRoJe6vqcyi0HeHDCju6GKphZEDtN0" }, "categories": [], "createdBy": "", "_createdDate": "2023-11-08T15:06:13.353Z", "description": "Immerse yourself in the enchanting harmony of nature's symphony as it intertwines with the power of music!", "eventUrl": { "baseUrl": "https://mysite.com/events", "path": "/event-details-registration/natures-symphony-a-musical-journey-through-wildlife" }, "form": { "inputGroups": [ { "_id": "name", "inputs": [ { "additionalLabels": [], "label": "First name", "maxLength": 50, "name": "firstName", "options": [], "required": true, "type": "TEXT" }, { "additionalLabels": [], "label": "Last name", "maxLength": 50, "name": "lastName", "options": [], "required": true, "type": "TEXT" } ], "orderIndex": 0, "system": true, "type": "NAME" }, { "_id": "email", "inputs": [ { "additionalLabels": [], "label": "Email", "maxLength": 255, "name": "email", "options": [], "required": true, "type": "TEXT" } ], "orderIndex": 1, "system": true, "type": "INPUT" } ], "messages": { "checkout": { "checkoutLabel": "Continue", "title": "Add your details" }, "registrationClosed": { "exploreEventsLabel": "See other events", "message": "Registration is closed" }, "rsvp": { "noMessages": { "confirmationTitle": "Sorry You Can't Make It", "shareLabel": "Share", "title": "Add your details" }, "rsvpNo": "Not Going", "rsvpYes": "I'm Going", "submitRsvpLabel": "SUBMIT", "waitingMessages": { "addToCalendarLabel": "Add to Calendar", "confirmationMessage": "We'll update you if additional spots become available.", "confirmationTitle": "Thanks! You've been added to the waitlist.", "shareLabel": "Share", "title": "Looks like this event is full. Join the waitlist." }, "yesMessages": { "addToCalendarLabel": "Add to Calendar", "confirmationMessage": "An email with all the event info was sent to you.", "confirmationTitle": "Thank you!", "shareLabel": "Share", "title": "Add your details" } } } }, "guestList": { "public": true }, "_id": "d152f42c-721c-4770-a178-f0e6c1d55f27", "language": "en", "location": { "address": { "formatted": "Kensington Gore, London SW7, UK", "location": { "latitude": 51.5009132, "longitude": -0.1766086 }, "city": "London", "country": "GB", "postalCode": "SW7 2BL", "streetAddress": { "name": "Kensington Gore", "number": "SW7", "apt": "" } }, "name": "Royal Albert Hall", "tbd": false, "type": "VENUE" }, "registration": { "initialType": "TICKETS", "restrictedTo": "VISITOR", "rsvp": { "responseOptions": "YES_ONLY", "waitlist": false }, "status": "CLOSED", "tickets": { "formAssignedPerTicket": false, "highestTicketPrice": {}, "lowestTicketPrice": {}, "tax": {} }, "type": "TICKETS" }, "scheduling": { "formatted": "The date will be announced soon, stay tuned!", "hideEndDate": false, "showTimeZone": false, "startDateFormatted": "", "startTimeFormatted": "", "tbd": true, "tbdMessage": "The date will be announced soon, stay tuned!" }, "slug": "natures-symphony-a-musical-journey-through-wildlife", "status": "SCHEDULED", "summary": { "rsvp": {}, "tickets": { "revenue": {}, "totalSales": {} } }, "title": "Nature's Symphony: A Musical Journey Through Wildlife.", "_updatedDate": "2023-11-08T15:06:13.000Z", "videoConferencing": { "session": {} } } */ ``` ---