Privy supports multiple ways to fetch and manage users in your application.

Querying users by identity token

Using identity tokens is the recommended way to query user information about authenticated users in your backend. If you need user data about unauthenticated users, you can use the getUsers method by passing in a user’s DID.

Use the getUser method to get a single user by their identity token passed from the client, to learn more about identity tokens, see identity tokens.

const user = await privy.getUser({idToken: 'your-idToken});

Other ways to query users

Privy rate limits REST API endpoints that you may call from your server. If you’re looking to get information about an authenticated user, consider using identity tokens as a more secure and efficient way to access user data.

Querying users by ID

Use the getUser method to get a single user by their Privy DID:

const user = await privy.getUserById('did:privy:XXXXXX');

Querying for all users

Use the getUsers method to get a list of all your users:

const users = await privy.getUsers();

The getUsers method automatically handles pagination and includes built-in exponential backoff to manage rate limits.

Querying for users by account data