Skip to main content
Privy supports multiple ways to fetch and manage users in your application.
  • NodeJS
  • NodeJS (server-auth)
  • Python
  • Java
  • REST API
  • Rust

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 _get method by passing in a user’s DID.
Use the get 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.users().get({id_token: 'your-id_token'});

Querying users by ID

To get a user by their Privy ID, call the .users()._get() method on the PrivyClient.
try {
  const user = privyClient.users()._get('insert-user-id');
} catch (error) {
  console.error(error);
}
Check out the API reference for more details on the available parameters and returns.

Querying for all users

To get all users for your app, call the .users().list() method on the PrivyClient.
try {
  for await (const user of privyClient.users().list()) {
    console.log(user.id);
  }
} catch (error) {
  console.error(error);
}
Check out the API reference for more details on the available parameters and returns.

Querying for users by account data

try {
  const user = await privy.users().getByEmailAddress({ address: '[email protected]' });
} catch (error) {
  console.error(error);
}
try {
  const user = await privy.users().getByPhoneNumber({ number: '+1 555 555 5555' });
} catch (error) {
  console.error(error);
}
try {
  const user = await privy.users().getByWalletAddress({ address: '0x1234567890' });
} catch (error) {
  console.error(error);
}
try {
  const user = await privy.users().getBySmartWalletAddress({ address: '0x1234567890' });
} catch (error) {
  console.error(error);
}
try {
  const user = await privy.users().getByCustomAuthID({ custom_user_id: 'insert-custom-auth-id' });
} catch (error) {
  console.error(error);
}
try {
  const user = await privy.users().getByFarcasterID({ fid: 1234 });
} catch (error) {
  console.error(error);
}
try {
  const user = await privy.users().getByTwitterSubject({ subject: 'insert-twitter-subject' });
} catch (error) {
  console.error(error);
}
try {
  const user = await privy.users().getByTwitterUsername({ username: 'batman' });
} catch (error) {
  console.error(error);
}
try {
  const user = await privy.users().getByDiscordUsername({ username: 'batman' });
} catch (error) {
  console.error(error);
}
try {
  const user = await privy.users().getByTelegramUserID({ telegram_user_id: 'insert-telegram-user-id' });
} catch (error) {
  console.error(error);
}
try {
  const user = await privy.users().getByTelegramUsername({ username: 'batman' });
} catch (error) {
  console.error(error);
}
try {
  const user = await privy.users().getByGitHubUsername({ username: 'batman' });
} catch (error) {
  console.error(error);
}
I