You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: "Introducing Realtime queries: Server-side event filtering for subscriptions"
4
+
description: Pass SDK queries when subscribing to realtime channels to automatically filter events server-side, so your callbacks only receive the updates you care about.
If you've built realtime features with Appwrite, you've likely written filtering logic inside your subscription callbacks: checking payload fields, comparing values, and discarding events you don't need. While this works, it adds boilerplate to your client code and means you're still receiving and processing every event on the channel, even the ones you'll throw away.
14
+
15
+
To make realtime subscriptions more precise, Appwrite now supports **Realtime queries**: pass SDK queries when subscribing to automatically filter events server-side.
16
+
17
+
# Filter at the source, not in your callback
18
+
19
+
Realtime queries let you pass SDK queries as a parameter when subscribing to a channel. Events are filtered on the server based on your queries, so your callback only fires when the payload matches your conditions.
20
+
21
+
This means less client-side filtering logic, fewer unnecessary callback invocations, and a cleaner subscription model overall.
22
+
23
+
# How it works
24
+
25
+
Realtime queries use the same `Query` helpers you already use with Appwrite's database and other services. Pass an array of queries when subscribing, and only events matching those conditions will trigger your callback.
26
+
27
+
```javascript
28
+
import { Client, Realtime, Channel, Query } from "appwrite";
Without queries, the first subscription receives every event on the channel. With queries, the second and third subscriptions only receive events where the payload matches the specified conditions. No manual filtering required.
64
+
65
+
# Supported queries
66
+
67
+
Realtime queries support a subset of the full SDK query methods, focused on value comparison and logical composition:
These cover the most common filtering patterns for realtime events. You can combine multiple queries to build precise conditions for your subscriptions.
74
+
75
+
# Key benefits
76
+
77
+
- **Server-side filtering**: Events are filtered before reaching your client, reducing unnecessary processing
78
+
- **Consistent API**: Uses the same `Query` helpers from Appwrite's database APIs
Appwrite Realtime now supports passing SDK queries when subscribing to channels. Events are filtered server-side based on your queries, so your callbacks only receive updates that match your conditions.
9
+
10
+
You can use queries like `Query.equal()`, `Query.notEqual()`, `Query.greaterThan()`, and more, and combine them with `Query.and()` and `Query.or()` for precise filtering. You can also subscribe to the same channel multiple times with different filters to handle different subsets of events independently.
11
+
12
+
Available across all Appwrite client SDKs: Web, Flutter, Apple, and Android.
Copy file name to clipboardExpand all lines: src/routes/docs/apis/realtime/+page.markdoc
+174Lines changed: 174 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -446,6 +446,180 @@ subscription.close()
446
446
447
447
{% /multicode %}
448
448
449
+
# Queries {% #queries %}
450
+
451
+
You can filter realtime events by passing queries as a third parameter when subscribing. Events are filtered server-side based on your queries, so your callback only receives updates that match your conditions. This allows you to use familiar SDK queries like `Query.equal` to automatically filter events instead of filtering manually in your callback.
452
+
453
+
{% multicode %}
454
+
```client-web
455
+
import { Client, Realtime, Channel, Query } from "appwrite";
0 commit comments