Get metadata for all users
Starting a new app? Use DataSync
DataSync is the successor to App Context. It does everything App Context does for users, channels, and memberships, and adds typed schemas, partial updates with ETags, field-level access control, and per-class expiry. Refer to How DataSync compares to App Context for a feature-by-feature comparison.
DataSync is currently available to new accounts and to accounts that are not actively using App Context. If your keysets already use App Context, keep using it for now. App Context remains fully supported and these pages stay accurate.
This guide shows you how to retrieve App Context metadata for every user on your keyset instead of one, page through the results, and sort or filter them. App Context must be enabled on the keyset before you call it, and new keysets don't enable it by default. To read, write, or remove one user's own record, refer to Set, get, and remove user metadata instead.
Get all user metadata
Call Get All UUID Metadata with no User ID. Pass include.customFields to receive each user's custom object, and include.totalCount to receive the total number of users on the keyset alongside the page you asked for.
- JavaScript
- Java
- C#
- Go
- Swift
- PHP
1
1
1
1
1
1
Most other SDKs, including Kotlin and Unity, document the same call in the App Context section of their API reference. Check Available SDKs for your platform.
If Access Manager is enabled, the option for this call is Disallow Get All User Metadata. An App Context "get all" call needs no per-resource permission grant unless you've turned on the matching Disallow Get All option, in which case the token needs an explicit grant for that operation. Refer to App Context and access control for the full permission model.
Page through the list
Every paginated App Context call takes the same three parameters. limit caps how many records come back in one call. It defaults to 100, and 100 is also the maximum. page.next and page.prev are opaque cursor strings copied from a previous response: pass the one you want to continue from, and PubNub returns the adjacent page in that direction. If you supply both, PubNub uses next and ignores prev.
To retrieve every user, keep calling Get All UUID Metadata with page.next set to the next value from the previous response. Stop when a response returns no next value. That's the last page.
Sort the list
Pass sort to order the results by id, name, or updated, each with an ascending or descending direction, for example {name: 'asc'}. Without a sort parameter, the order isn't guaranteed to stay stable between calls. Check your platform's API reference in Available SDKs for the exact parameter shape.
The following example, in PHP, sorts both a user list and a channel list by name:
1
Filter the list
Pass filter to receive only the users matching a filter expression, such as status == "active" or name LIKE "*Team", instead of paging through every user and filtering client-side. Refer to App Context filtering for the full field list, operators, and syntax.
1
List users without code
BizOps Workspace's User Management module lists every user on your keyset with the same filter and sort options, with no SDK call required. Refer to User Management filters for the quick search box, the Filters button, and advanced filtering with the same expression language as filter.
Related tasks
- App Context. The three entity types and how App Context relates to messages and Presence.
- Set, get, and remove user metadata. Read, write, or remove one user's own record.
- App Context filtering. The full filter field list, operators, and syntax.
- App Context API limits. Recommended maximum user metadata records per keyset.