import { UserResponseDto, UserBalanceResponseDto, OffsetPaginatedDto, NetworkAddressAndPriceDto, TokenInfoWithPriceChangeDto, TokenInfo, TokenPriceHistoryParams, TokenPriceHistoryResponse, AccountTokensBalancesResponse, AlchemyNetwork, SupaPointsBalanceResponseDto, DailyLoginResponseDto, SupaPointsHistoryParams, TransactionQueryParams, PaymasterRequestDto, PaymasterResponseDto } from '../core/types'; /** * Return type for useAPI hook * Provides organized access to all backend API methods */ export interface UseAPIReturn { /** User management and profile methods */ user: { /** Fetches current authenticated user profile */ getCurrent: () => Promise; /** Fetches all users (admin only) */ getAll: () => Promise; /** Fetches user by Privy ID */ getByPrivyId: (privyUserId: string) => Promise; /** Fetches user's smart wallet token balances */ getBalance: (force?: boolean) => Promise; }; /** On-chain data and token price methods */ onchain: { /** Fetches token prices by contract addresses */ getPricesByAddresses: (addresses: Array<{ network: AlchemyNetwork; contractAddress: string; }>) => Promise; /** Fetches token prices by symbols (BTC, ETH, etc.) */ getTokenPrices: (symbols: string[]) => Promise>; /** Fetches historical price data for a token */ getPriceHistory: (params: TokenPriceHistoryParams) => Promise; /** Fetches 24-hour price changes for tokens */ get24hrPriceChanges: (tokens: Array<{ network: AlchemyNetwork; contractAddress: string; }>) => Promise; /** Fetches detailed token information */ getTokenInfo: (network: string, addresses: string | string[]) => Promise>; /** Fetches token balances for an account */ getAccountBalances: (network: string, account: string, force?: boolean) => Promise; }; /** Transaction history methods */ transactions: { /** Fetches user transaction history */ get: (params?: TransactionQueryParams) => Promise; /** Forces reload of transaction history from blockchain */ forceLoad: (params?: TransactionQueryParams) => Promise; }; /** SupaPoints reward system methods */ supaPoints: { /** Fetches current SupaPoints balance */ getBalance: () => Promise; /** Fetches SupaPoints transaction history */ getHistory: (params?: SupaPointsHistoryParams) => Promise>; /** Processes daily login bonus */ dailyLogin: () => Promise; }; /** Paymaster sponsorship methods */ paymaster: { /** Checks if transaction qualifies for gas sponsorship */ checkSponsorship: (request: PaymasterRequestDto) => Promise; }; /** Privy wallet methods */ privy: { /** Fetches Privy embedded wallet balance */ getBalance: () => Promise; }; } /** * Hook for accessing Supa Backend API * Provides organized, type-safe access to all backend endpoints * All methods automatically include authentication token from Privy * * @returns Organized API methods grouped by functionality * * @example * Basic usage * ```tsx * function UserBalance() { * const api = useAPI(); * const [balance, setBalance] = useState(null); * * useEffect(() => { * api.user.getBalance().then(setBalance); * }, []); * * return
Balance: ${balance?.totalUsdBalance}
; * } * ``` * * @example * Fetching crypto prices * ```tsx * function TokenPrices() { * const api = useAPI(); * * useEffect(() => { * api.onchain.getTokenPrices(['BTC', 'ETH', 'SOL']) * .then(prices => { * console.log('BTC:', prices.BTC); * console.log('ETH:', prices.ETH); * }); * }, []); * * return
Check console for prices
; * } * ``` */ export declare const useAPI: () => UseAPIReturn;