-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: update fetching user details endpoint for ecosystems (#4918)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on enhancing the `getUser` functionality in the `thirdweb` SDK by adding support for querying user details via an external wallet address and ecosystem identifiers. ### Detailed summary - Added support for querying user details using `externalWalletAddress` in `getUser`. - Updated documentation for `getUser` to include `externalWalletAddress` as a query parameter. - Modified examples in the documentation to demonstrate querying with `externalWalletAddress`. - Updated user detail query parameters in documentation to reflect new options. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
- Loading branch information
1 parent
4dee169
commit 0f6b881
Showing
3 changed files
with
87 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
"thirdweb": patch | ||
--- | ||
|
||
Add querying for in app wallet user details via externally linked wallet address: | ||
|
||
```ts | ||
import { getUser } from "thirdweb"; | ||
|
||
// this is the wallet address that the user used to connect via SIWE to their in app wallet | ||
const user = await getUser({ | ||
client, | ||
externalWalletAddress: "0x123...", | ||
}); | ||
``` | ||
|
||
Add querying for ecosystem wallet user details: | ||
|
||
```ts | ||
import { getUser } from "thirdweb"; | ||
|
||
const user = await getUser({ | ||
client, | ||
ecosystem: { | ||
id: "ecosystem.YOUR_ID", | ||
partnerId: "OPTIONAL_PARTNER_ID" | ||
} | ||
email: "[email protected]", | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ You can query user details through the thirdweb SDK using a wallet address, emai | |
<Tabs defaultValue='wallet'> | ||
<TabsList> | ||
<TabsTrigger value='wallet'>Wallet</TabsTrigger> | ||
<TabsTrigger value='external-wallet'>External Wallet</TabsTrigger> | ||
<TabsTrigger value='email'>Email</TabsTrigger> | ||
<TabsTrigger value='phone'>Phone</TabsTrigger> | ||
<TabsTrigger value='id'>User ID</TabsTrigger> | ||
|
@@ -18,13 +19,26 @@ You can query user details through the thirdweb SDK using a wallet address, emai | |
```ts | ||
import { getUser } from "thirdweb"; | ||
|
||
// this is the wallet address that thirdweb has generated for the user | ||
const user = await getUser({ | ||
client, | ||
walletAddress: "0x123...", | ||
}); | ||
``` | ||
</TabsContent> | ||
|
||
<TabsContent value='external-wallet'> | ||
```ts | ||
import { getUser } from "thirdweb"; | ||
|
||
// this is the wallet address that the user used to connect via SIWE to their in app wallet | ||
const user = await getUser({ | ||
client, | ||
externalWalletAddress: "0x123...", | ||
}); | ||
``` | ||
</TabsContent> | ||
|
||
<TabsContent value='email'> | ||
```ts | ||
import { getUser } from "thirdweb"; | ||
|
@@ -70,27 +84,52 @@ https://embedded-wallet.thirdweb.com/api/2023-11-30/embedded-wallet/user-details | |
|
||
### Query Parameters | ||
|
||
You can query user details using one of the following parameters: | ||
You can specify the query parameter `queryBy` to query by different user identifiers: | ||
|
||
- `queryBy`: The parameter to query by. Can be one of `walletAddress`, `email`, `phone`, `externalWalletAddress`, or `id`. | ||
|
||
You can then specify the value to query by, matching the queryBy parameter: | ||
|
||
- `walletAddress`: The user's wallet address | ||
- `walletAddress`: The user's wallet address that thirdweb has generated for them | ||
- `email`: The user's email address | ||
- `phone`: The user's phone number | ||
- `id`: The user's ID | ||
- `externalWalletAddress`: The user's wallet address that used to login via SIWE | ||
- `id`: The user's ID (for custom auth) | ||
|
||
### Authentication | ||
|
||
You need to include your ThirdWeb Client Secret in the Authorization header. | ||
You need to include your ThirdWeb Client Secret in the Authorization header. | ||
|
||
If you are an ecosystem owner, you have to include the `x-ecosystem-id` header and optionally the `x-ecosystem-partner-id` header if the ecosystem is set to partners only. | ||
|
||
### Example curl Command | ||
|
||
Here's an example curl command to fetch user details: | ||
Here's an example curl command to fetch user details by email: | ||
|
||
```bash | ||
curl -X GET 'https://embedded-wallet.thirdweb.com/api/2023-11-30/embedded-wallet/user-details?queryBy=email&[email protected]' \ | ||
-H 'x-secret-key: YOUR_THIRD_WEB_CLIENT_SECRET' | ||
``` | ||
|
||
Here's an example curl command to fetch user details by address: | ||
|
||
```bash | ||
curl -X GET 'https://embedded-wallet.thirdweb.com/api/2023-11-30/embedded-wallet/user-details?queryBy=walletAddress&walletAddress=0x123456789abcdef' \ | ||
-H 'Authorization: Bearer YOUR_THIRD_WEB_CLIENT_SECRET' | ||
-H 'x-secret-key: YOUR_THIRD_WEB_CLIENT_SECRET' | ||
``` | ||
|
||
Replace `YOUR_THIRD_WEB_CLIENT_SECRET` with your actual ThirdWeb Client Secret. | ||
Here's an example curl command to fetch the user details for an ecosystem owner: | ||
|
||
```bash | ||
curl -X GET 'https://embedded-wallet.thirdweb.com/api/2023-11-30/embedded-wallet/user-details?queryBy=walletAddress&walletAddress=0x123456789abcdef' \ | ||
-H 'x-secret-key: YOUR_THIRD_WEB_CLIENT_SECRET' \ | ||
-H 'x-ecosystem-id: ecosystem.YOUR_ECOSYSTEM_ID' \ | ||
-H 'x-ecosystem-partner-id: YOUR_PARTNER_ID' | ||
``` | ||
|
||
In both examples, replace `YOUR_THIRD_WEB_CLIENT_SECRET` with your actual ThirdWeb Client Secret. | ||
|
||
Replace `YOUR_ECOSYSTEM_ID` and `YOUR_PARTNER_ID` with your actual ecosystem ID and partner ID respectively. The partner ID can be one you set up for yourself as the ecosystem owner. | ||
|
||
### Response Format | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters