Using the Profiles Endpoint for Social Interoperation
The Profiles endpoint is a powerful tool for developers looking to create a seamless onboarding experience. By leveraging this endpoint, you can retrieve all profiles associated with a user's wallet address across the Tapestry ecosystem, allowing for quick and easy profile setup in your app.
How It Works
When a new user connects their wallet to your app, you can use this endpoint to:
- Fetch all profiles owned by the user's wallet address
- Display these profiles to the user
- Allow the user to import data from an existing profile
This process significantly reduces friction in the onboarding flow, as users can quickly set up their profile using information they've already provided elsewhere in the Tapestry ecosystem.
Using the Endpoint
To fetch external profiles, set the shouldIncludeExternalProfiles
parameter to true
:
const response = await fetch('https://api.usetapestry.dev/v1/profiles?apiKey=YOUR_API_KEY&shouldIncludeExternalProfiles=true', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ walletAddress: 'wallet_address_here' }),
});
This endpoint returns an array of Profile
objects representing the profiles owned by the specified wallet address.
Request Parameters
Parameter | Type | Description |
---|---|---|
walletAddress | string | The wallet address to find associated profiles for |
apiKey | string | Your Tapestry API key |
shouldIncludeExternalProfiles | boolean | Whether to include profiles from Tapestry apps outside your namespace |
Response
The endpoint returns an array of profile objects. Each object contains details about a profile associated with the provided wallet address:
[
{
"id": "profile-123",
"properties": {
"username": "cryptoenthusiast",
"bio": "Blockchain developer and NFT collector",
"profileImage": "https://example.com/profile.jpg",
"namespace": "CryptoApp"
}
},
{
"id": "profile-456",
"properties": {
"username": "nftlover",
"bio": "Digital art aficionado",
"profileImage": "https://example.com/avatar.png",
"namespace": "NFTMarketplace"
}
}
]
Implementing in Your Onboarding Flow
Here's a step-by-step guide to implement this in your onboarding process:
- After the user connects their wallet, call the Find All Profiles endpoint.
- If profiles are found, present them to the user with an option to import data.
- If the user selects a profile, use its data to pre-fill your profile creation form.
- Allow the user to review and modify the imported data before finalizing their profile.
Here's a simple example of how this might look in code:
async function onboardUser(walletAddress) {
// Fetch profiles
const profiles = await fetchProfiles(walletAddress);
if (profiles.length > 0) {
// Display profiles to user and let them choose
const selectedProfile = await displayProfileChoices(profiles);
if (selectedProfile) {
// Pre-fill form with selected profile data
prefillProfileForm(selectedProfile);
}
}
// Continue with your regular onboarding flow
// ...
}
Benefits
By implementing this feature, you can:
- Reduce user friction during onboarding
- Increase the likelihood of completed profiles
- Provide a seamless experience for users already part of the Tapestry ecosystem
- Encourage data portability and user ownership across different applications
Next Steps
Now that you understand how to use the Profiles endpoint to fetch external profiles, consider integrating it into your onboarding flow. This will not only improve the user experience but also demonstrate your app's integration with the broader Tapestry ecosystem.
Remember to handle cases where a user might not have any existing profiles, and always give users the option to create a new profile from scratch if they prefer.