Prerequisites
Before you begin, make sure you have:- A Thrust account with an API key
- Your Supabase project URL
- A tool to make HTTP requests (cURL, Postman, or code)
Step 1: Set Up Your Environment
First, set your environment variables:export API_URL="https://yppncslmsswqydhhgygz.supabase.co/functions/v1"
export API_KEY="your_api_key_here"
Step 2: Create Your First Token
Let’s create a new token on the platform:curl -X POST "${API_URL}/create-token-transaction" \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"name": "My Token",
"symbol": "MTK",
"description": "A revolutionary new token",
"imageUrl": "https://example.com/logo.png",
"chainId": "base-sepolia",
"endpointId": 40245,
"userAddress": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
}'
const response = await fetch(
'https://yppncslmsswqydhhgygz.supabase.co/functions/v1/create-token-transaction',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'My Token',
symbol: 'MTK',
description: 'A revolutionary new token',
imageUrl: 'https://example.com/logo.png',
chainId: 'base-sepolia',
endpointId: 40245,
userAddress: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb'
})
}
);
const data = await response.json();
console.log('Token created:', data);
import requests
response = requests.post(
"https://yppncslmsswqydhhgygz.supabase.co/functions/v1/create-token-transaction",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
},
json={
"name": "My Token",
"symbol": "MTK",
"description": "A revolutionary new token",
"imageUrl": "https://example.com/logo.png",
"chainId": "base-sepolia",
"endpointId": 40245,
"userAddress": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
}
)
data = response.json()
print("Token created:", data)
Expected Response
{
"success": true,
"transaction": {
"to": "0x1234567890123456789012345678901234567890",
"data": "0x...",
"value": "0",
"gasLimit": "500000"
},
"tokenData": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "My Token",
"symbol": "MTK",
"slug": "my-token"
}
}
Step 3: Vote on Content
Now let’s vote on a token or post:curl -X POST "${API_URL}/vote" \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"contentType": "token",
"contentId": "550e8400-e29b-41d4-a716-446655440000",
"voteType": "upvote",
"votingTokenId": "550e8400-e29b-41d4-a716-446655440000"
}'
const vote = await fetch(
'https://yppncslmsswqydhhgygz.supabase.co/functions/v1/vote',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
contentType: 'token',
contentId: '550e8400-e29b-41d4-a716-446655440000',
voteType: 'upvote',
votingTokenId: '550e8400-e29b-41d4-a716-446655440000'
})
}
);
const voteResult = await vote.json();
console.log('Vote recorded:', voteResult);
vote_response = requests.post(
"https://yppncslmsswqydhhgygz.supabase.co/functions/v1/vote",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
},
json={
"contentType": "token",
"contentId": "550e8400-e29b-41d4-a716-446655440000",
"voteType": "upvote",
"votingTokenId": "550e8400-e29b-41d4-a716-446655440000"
}
)
vote_data = vote_response.json()
print("Vote recorded:", vote_data)
Expected Response
{
"success": true,
"message": "Vote recorded successfully",
"vote": {
"id": "vote-uuid-here",
"contentType": "token",
"contentId": "550e8400-e29b-41d4-a716-446655440000",
"voteType": "upvote",
"weight": 1.5
}
}
Step 4: Get Trending Tokens
Now let’s fetch trending tokens:curl -X POST "${API_URL}/get-tokens" \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"filter": "trending",
"limit": 10
}'
const response = await fetch(
'https://yppncslmsswqydhhgygz.supabase.co/functions/v1/get-tokens',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
filter: 'trending',
limit: 10
})
}
);
const data = await response.json();
console.log('Trending tokens:', data);
response = requests.post(
"https://yppncslmsswqydhhgygz.supabase.co/functions/v1/get-tokens",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
},
json={
"filter": "trending",
"limit": 10
}
)
data = response.json()
print("Trending tokens:", data)
Expected Response
{
"success": true,
"tokens": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Example Token",
"symbol": "EXMPL",
"slug": "example-token",
"logo": "https://example.com/logo.png",
"description": "An example token",
"holders_count": 1234,
"upvotes": 567,
"downvotes": 89,
"is_live": false,
"hashtags": ["trending", "defi"]
}
],
"pagination": {
"limit": 10,
"offset": 0,
"total_returned": 10,
"has_more": true
}
}
Common Use Cases
Browse Tokens by Hashtag
const hashtagTokens = await fetch(
'https://yppncslmsswqydhhgygz.supabase.co/functions/v1/get-tokens',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
filter: 'trending',
hashtag_name: 'defi',
limit: 20
})
}
);
Search for Tokens
const searchResults = await fetch(
'https://yppncslmsswqydhhgygz.supabase.co/functions/v1/search-token',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: 'bitcoin',
limit: 10
})
}
);
Get User Notifications
const notifications = await fetch(
'https://yppncslmsswqydhhgygz.supabase.co/functions/v1/get-notifications',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
limit: 20,
unreadOnly: true
})
}
);
SDK Examples
React Hook Example
import { useState, useEffect } from 'react';
export function useTrendingTokens(limit = 20) {
const [tokens, setTokens] = useState([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
useEffect(() => {
const fetchTokens = async () => {
try {
const response = await fetch(
'https://yppncslmsswqydhhgygz.supabase.co/functions/v1/get-tokens',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
filter: 'trending',
limit
})
}
);
const data = await response.json();
setTokens(data.tokens);
} catch (err) {
setError(err.message);
} finally {
setLoading(false);
}
};
fetchTokens();
}, [limit]);
return { tokens, loading, error };
}
Error Handling
Always handle errors in your API calls:const makeApiCall = async (endpoint, data) => {
try {
const response = await fetch(
`https://yppncslmsswqydhhgygz.supabase.co/functions/v1/${endpoint}`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
}
);
const result = await response.json();
if (!response.ok) {
throw new Error(result.error || 'API request failed');
}
return result;
} catch (error) {
console.error('API Error:', error.message);
throw error;
}
};
Next Steps
API Reference
Explore all available endpoints
Authentication
Learn about advanced authentication
Errors
Understand error codes
Examples
See more code examples
Need Help?
- Join our Discord community
- Check the API Reference for detailed endpoint documentation
- Email us at support@thrust.app
