Skip to main content

Prerequisites

Before you begin, make sure you have:
  1. A Thrust account with an API key
  2. Your Supabase project URL
  3. 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"
  }'

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"
  }'

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
  }
}
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
  }'

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

Need Help?