Appearance
Querying a single user
Privy allows you to query an individual user's data with their Privy DID. This includes their DID, the timestamp of when they were created, and all of their linked accounts.
WARNING
Privy rate limits REST API endpoints that you may call from your server. If you suspect your team will require an increased rate limit, please reach out to support!
Using @privy-io/server-auth
Use the PrivyClient
's getUser
method to get a single user by their Privy DID. As a parameter, pass the user's DID as a string
:
typescript
const user = await privy.getUser('did:privy:XXXXXX');
If a matching user is found, the method will return the corresponding User
object. If no matching user is found, the method will throw an error.
Using the REST API
Make a GET
request to:
bash
https://auth.privy.io/api/v1/users/<did>
Replace <did>
with your desired Privy DID. It should have the format did:privy:XXXXXX
.
Below is a sample cURL command for this request:
bash
curl --request GET https://auth.privy.io/api/v1/users/<user-did> \
-u "<your-privy-app-id>:<your-privy-app-secret>" \
-H "privy-app-id: <your-privy-app-id>"
TIP
Looking for the types of LinkedAccount
s?
See a breakdown of different account types and the data they include
Note:
- Each account should be a JSON object including all the necessary fields for that account
type
. Valid accounttype
s are'custom_jwt'
,'discord_oauth'
,'farcaster'
,'github_oauth'
,'google_oauth'
,'instagram_oauth'
,'linkedin_oauth'
,'spotify_oauth'
,'twitter_oauth'
,'email'
,'phone'
and'wallet'
. See below for what additional information for each accounttype
. Please exclude theverifiedAt
field. - If importing a user with a
custom_jwt
account, thecustom_jwt
account must be the only element of thelinked_accounts
array. It is not permitted to import a user with acustom_jwt
account and otherlinked_accounts
.
CustomJwtAccount
extends LinkedAccount
Field | Type | Description |
---|---|---|
type | 'custom_jwt' | N/A |
custom_id | string | ID of user from Twitter user API response. |
DiscordAccount
extends LinkedAccount
Field | Type | Description |
---|---|---|
type | 'discord_oauth' | N/A |
subject | string | ID of user from Discord user API response. |
email | string | Email of user from Discord user API response |
username | string | Username of user from Discord user API response. Include the 4-digit discriminator prefixed by '#'. |
(See Discord docs)
EmailAccount
extends LinkedAccount
Field | Type | Description |
---|---|---|
type | 'email' | N/A |
address | string | Email address of user account. |
FarcasterAccount
extends LinkedAccount
Field | Type | Description |
---|---|---|
type | 'farcaster' | N/A |
fid | string | FID of the user from Farcaster user API response. |
owner_address | string | Wallet address of the user from Farcaster user API response. Note that this is the Farcaster wallet address, and not the Privy embedded wallet address. |
username | string | (Optional) Username of user from Farcaster user API response. Do not include the '@'. |
display_name | string | (Optional) Display name of user from Farcaster user API response. |
bio | string | (Optional) Bio of user from Farcaster user API response. |
profile_picture_url | string | (Optional) Profile picture URL of the user from Farcaster user API response. Must be a valid image URL. |
homepage_url | string | (Optional) Profile URL of the user from Farcaster user API response. |
(See Farcaster docs. Note that the Privy import interface differs slightly from the Farcaster public interface in order to maintain consistency with other Privy LinkedAccount
types.)
GithubAccount
extends LinkedAccount
Field | Type | Description |
---|---|---|
type | 'github_oauth' | N/A |
subject | string | ID of user from GitHub user API response. |
email | string | Email of user from GitHub user API response |
name | string | Name of user from GitHub user API response |
username | string | Username of user from GitHub user API response |
(See GitHub docs)
GoogleAccount
extends LinkedAccount
Field | Type | Description |
---|---|---|
type | 'google_oauth' | N/A |
subject | string | sub pulled from Google-provided JWT with "openid" scope. |
email | string | email from Google-provided JWT with "email" scope. |
name | string | name from Google-provided JWT with "profile" scope. |
InstagramAccount
extends LinkedAccount
Field | Type | Description |
---|---|---|
type | 'instagram_oauth' | N/A |
subject | string | ID of user from Instagram user API response. |
username | string | The name displayed on a user's profile from Instagram's /me API response. |
(See Instagram docs)
LinkedinAccount
extends LinkedAccount
Field | Type | Description |
---|---|---|
type | 'linkedin_oauth' | N/A |
subject | string | ID of user from LinkedIn user API response. |
email | string | Email of user from LinkedIn user API response |
name | string | Name of user from LinkedIn user API response. Do not include the '@'. |
(See Linkedin docs)
PhoneAccount
extends LinkedAccount
Field | Type | Description |
---|---|---|
type | 'email' | N/A |
phoneNumber | true | Phone number of user account (non-international numbers default to US). |
SpotifyAccount
extends LinkedAccount
Field | Type | Description |
---|---|---|
type | 'spotify_oauth' | N/A |
subject | string | ID of user from Spotify user API response. |
email | string | Email of user from Spotify user API. |
name | string | The name displayed on a user's profile from Spotify display_name API response. |
(See Spotify docs)
TwitterAccount
extends LinkedAccount
Field | Type | Description |
---|---|---|
type | 'twitter_oauth' | N/A |
subject | string | ID of user from Twitter user API response. |
name | string | Name of user from Twitter user API response |
username | string | Username of user from Twitter user API response. Do not include the '@'. |
profile_picture_url | string | (Optional) Profile picture URL of the user from Twitter user API response. Must be a valid image URL. |
(See Twitter docs)
WalletAccount
extends LinkedAccount
Field | Type | Description |
---|---|---|
type | 'wallet' | N/A |
chain_type | 'ethereum' | Type of chain for the wallet. Only EVM chains ('ethereum' ) are currently supported. |
address | string | Checksummed wallet address. |
A successful response will include the user object associated with the DID, like below:
json
{
"id":"did:privy:cfbsvtqo2c22202mo08847jdux2z",
"created_at":1667165891,
"linked_accounts":[
{
"type": "wallet",
"address": "0xABCDEFGHIJKL01234567895C5cAe8B9472c14328",
"chain_type": "ethereum",
"chain_id": "eip155:137",
"wallet_client": "unknown",
"wallet_client_type": "metamask",
"connector_type": "injected",
"verified_at": 1688556783
}
{
"type":"email",
"address":"[email protected]",
"verified_at":1667350653
}
]
}
If there is no user associated with the provided DID, the API will return an error.