Skip to content

Commit d43ad17

Browse files
[Portal] Fix HTTP method in wallet users API example from POST to GET (#6868)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on updating the documentation for fetching user details from the in-app wallet API, providing clearer instructions, examples, and a new method for retrieving user data. ### Detailed summary - Changed the title from `Get Users` to `Fetch a Single User`. - Added detailed instructions for fetching user details via a `GET` request. - Specified query parameters and their descriptions. - Included authentication requirements. - Provided example `curl` commands for fetching user details by email and wallet address. - Described the response format for the API. - Introduced convenience methods using the `getUser` method from the thirdweb SDK. - Updated the command for fetching all users from `POST` to `GET`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent dbb7824 commit d43ad17

File tree

1 file changed

+113
-4
lines changed
  • apps/portal/src/app/connect/wallet/get-users

1 file changed

+113
-4
lines changed

apps/portal/src/app/connect/wallet/get-users/page.mdx

Lines changed: 113 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Callout } from "@doc";
2-
import { createMetadata, ArticleIconCard } from "@doc";
2+
import { createMetadata, ArticleIconCard, Stack } from "@doc";
3+
import { TypeScriptIcon } from "@/icons";
34

45
export const metadata = createMetadata({
56
image: {
@@ -10,7 +11,116 @@ export const metadata = createMetadata({
1011
description: "Learn how to fetch in-app wallet users for your application.",
1112
});
1213

13-
# Get Users
14+
# Fetch a Single User
15+
16+
From the backend, you are able to get the details of any user within your in app or ecosystem wallet.
17+
18+
To get the user details, you can make a `GET` request to the following endpoint:
19+
20+
```
21+
https://in-app-wallet.thirdweb.com/api/2023-11-30/embedded-wallet/user-details
22+
```
23+
24+
### Query Parameters
25+
26+
You can specify the query parameter `queryBy` to query by different user identifiers:
27+
28+
- `queryBy`: The parameter to query by. Can be one of `walletAddress`, `email`, `phone`, `externalWalletAddress`, or `id`.
29+
30+
You can then specify the value to query by, matching the queryBy parameter:
31+
32+
- `walletAddress`: The user's wallet address that thirdweb has generated for them
33+
- `email`: The user's email address
34+
- `phone`: The user's phone number
35+
- `externalWalletAddress`: The user's wallet address that used to login via SIWE
36+
- `id`: The user's ID (for custom auth)
37+
38+
### Authentication
39+
40+
You need to include your ThirdWeb Client Secret in the Authorization header.
41+
42+
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.
43+
44+
### Example curl Command
45+
46+
Here's an example curl command to fetch user details by email:
47+
48+
```bash
49+
50+
curl -X GET 'https://in-app-wallet.thirdweb.com/api/2023-11-30/embedded-wallet/user-details?queryBy=email&[email protected]' \
51+
-H 'x-secret-key: YOUR_SECRET_KEY'
52+
53+
```
54+
55+
Here's an example curl command to fetch user details by address:
56+
57+
```bash
58+
curl -X GET 'https://in-app-wallet.thirdweb.com/api/2023-11-30/embedded-wallet/user-details?queryBy=walletAddress&walletAddress=0x123456789abcdef' \
59+
-H 'x-secret-key: YOUR_SECRET_KEY'
60+
```
61+
62+
Here's an example curl command to fetch the user details for an ecosystem owner:
63+
64+
```bash
65+
curl -X GET 'https://in-app-wallet.thirdweb.com/api/2023-11-30/embedded-wallet/user-details?queryBy=walletAddress&walletAddress=0x123456789abcdef' \
66+
-H 'x-secret-key: YOUR_SECRET_KEY' \
67+
-H 'x-ecosystem-id: ecosystem.YOUR_ECOSYSTEM_ID' \
68+
-H 'x-ecosystem-partner-id: YOUR_PARTNER_ID'
69+
```
70+
71+
In both examples, replace `YOUR_SECRET_KEY` with your actual ThirdWeb Client Secret.
72+
73+
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.
74+
75+
### Response Format
76+
77+
The API returns a JSON array with the following structure for each user:
78+
79+
```json
80+
[
81+
{
82+
"userId": "string",
83+
"walletAddress": "string",
84+
"email": "string (optional)",
85+
"phone": "string (optional)",
86+
"createdAt": "string",
87+
"linkedAccounts": [
88+
{
89+
"type": "string",
90+
"details": {
91+
"phone": "string",
92+
// or
93+
"email": "string",
94+
// or
95+
"address": "string",
96+
// or
97+
"id": "string",
98+
// Additional key-value pairs may be present
99+
}
100+
}
101+
]
102+
}
103+
]
104+
```
105+
106+
Note: The `details` object in `linkedAccounts` will contain different fields based on the account type. See the [list of Strategies](#list-of-strategies) above for more information.
107+
108+
Remember to handle the response appropriately in your chosen programming language, including error cases and parsing the JSON response.
109+
110+
### Convenience Methods
111+
112+
If you are using the thirdweb SDK, you can use the `getUser` method to retrieve user details.
113+
114+
<Stack>
115+
<ArticleIconCard
116+
title="getUser"
117+
icon={TypeScriptIcon}
118+
description="Get user details from your backend for thirdweb wallets in TypeScript"
119+
href="/references/typescript/v5/getUser"
120+
/>
121+
</Stack>
122+
123+
# Fetch All Users
14124

15125
Once you have users connecting to your app through in-app wallets, you can fetch all users through our REST API:
16126
```
@@ -31,7 +141,7 @@ You need to include the following headers:
31141
Here's an example curl command to pregenerate a thirdweb wallet for the user `[email protected]`:
32142

33143
```bash
34-
curl -X POST 'https://in-app-wallet.thirdweb.com/api/v1/users?offset=200&limit=100' \
144+
curl -X GET 'https://in-app-wallet.thirdweb.com/api/v1/users?offset=200&limit=100' \
35145
-H 'x-secret-key: YOUR_SECRET_KEY' \
36146
-H 'Content-Type: application/json'
37147
```
@@ -67,4 +177,3 @@ A successful API call returns an array of user objects in the following format:
67177
}
68178
]
69179
```
70-

0 commit comments

Comments
 (0)