Custom API Profile Cards
Learn how to integrate your own APIs to create custom profile cards.
Prerequisite: You should have an accessible API endpoint that conforms to the specified request and response structures below.
Overview
The Custom API Profile Cards feature allows you to display personalized profile cards on the dashboard by integrating with your own APIs. This enables you to fetch and display custom data for each user, such as statistics, achievements, or any other information relevant to your application.
How It Works
When enabled, the dashboard will send a POST request to your specified API endpoint(s) for each user. The API should accept a request body containing user information and return a response with the data to display on the profile card.
You can specify multiple API endpoints, and each one will correspond to a separate profile card on the dashboard.
Setting Up
Step 1: Define Your API Endpoint(s)
In the dashboard configuration tab, provide the URL(s) of your API endpoint(s). You can add multiple URLs, each corresponding to a different profile card.
Step 2: Implement the API Endpoint
Your API endpoint should accept a POST request with the following request body structure:
Field Descriptions:
wallets
: An array of wallet addresses connected by the user.socials
: An object containing social media handles connected by the user.twitter
: The user’s Twitter handle.discord
: The user’s Discord handle.
primaryWallet
: The user’s primary wallet address.user_id
: The user’s unique identifier in our system.
Step 3: Define the API Response
Your API should return a JSON response with the following response body structure:
Field Descriptions:
title
: The title to display on the profile card.value
: The main value or content to display.button
(optional): An object defining a button to include on the card.text
: The text to display on the button.href
: The URL the button should link to.
Step 4: Example Implementation
Request Example:
Response Example:
Step 5: Testing Your Integration
After setting up your API endpoint and configuring the dashboard:
- Log in as a user to your application.
- Navigate to the dashboard to verify that the custom profile cards appear as expected.
- Ensure that the data displayed matches the data returned by your API.
Tips and Best Practices
- Performance: The API should respond quickly to avoid slowing down the dashboard load time.
- Caching: Use caching mechanisms if necessary to improve performance.
- Error Handling: Handle errors gracefully in your API to avoid breaking the dashboard UI.
- Scalability: Make sure your API can scale with the number of users.
Troubleshooting
FAQs
Can I add multiple custom API profile cards?
Yes, you can add multiple API endpoints in the configuration. Each API will correspond to a separate profile card on the dashboard.
Is the button
field mandatory?
No, the button
field in the response is optional. If omitted, no button will be displayed on the profile card.
What happens if the API is down or returns an error?
If the API fails to return a valid response, the profile card may not display correctly. Ensure that your API has proper error handling and returns appropriate HTTP status codes.