/** * ApiPlatformClient - MetaMask API Platform Client * * A comprehensive API client that uses @tanstack/query-core directly for: * - Automatic request deduplication * - Intelligent caching * - Automatic retries with exponential backoff * * Provides unified access to all MetaMask backend APIs: * - Accounts API (accounts.api.cx.metamask.io) * - Price API (price.api.cx.metamask.io) * - Token API (token.api.cx.metamask.io) * - Tokens API (tokens.api.cx.metamask.io) * * @example * ```typescript * const client = new ApiPlatformClient({ * clientProduct: 'metamask-extension', * getBearerToken: async () => token, * }); * * // Access API methods through sub-clients * const networks = await client.accounts.fetchV2SupportedNetworks(); * const balances = await client.accounts.fetchV5MultiAccountBalances(accountIds); * const prices = await client.prices.fetchV3SpotPrices(assetIds); * const tokenList = await client.token.fetchTokenList(1); * const assets = await client.tokens.fetchV3Assets(assetIds); * * // Cache management * await client.invalidateAll(); // Invalidate all caches * await client.invalidateAuthToken(); // Invalidate auth token * await client.accounts.invalidateBalances(); // Domain-specific via sub-client * await client.prices.invalidatePrices(); // Domain-specific via sub-client * ``` */ import { QueryClient } from "@tanstack/query-core"; import type { QueryKey } from "@tanstack/query-core"; import { AccountsApiClient } from "./accounts/index.cjs"; import { PricesApiClient } from "./prices/index.cjs"; import type { ApiPlatformClientOptions } from "./shared-types.cjs"; import { TokenApiClient } from "./token/index.cjs"; import { TokensApiClient } from "./tokens/index.cjs"; /** * MetaMask API Platform Client with TanStack Query caching. * Provides cached access to all MetaMask backend APIs through a unified interface. * * Access API methods through the sub-clients: * - `client.accounts` - Accounts API (balances, transactions, NFTs, etc.) * - `client.prices` - Prices API (spot prices, exchange rates, historical prices) * - `client.token` - Token API (token metadata, trending, top gainers) * - `client.tokens` - Tokens API (bulk asset operations, supported networks) */ export declare class ApiPlatformClient { #private; /** * Accounts API client. * Provides methods for balances, transactions, relationships, NFTs, and token discovery. */ readonly accounts: AccountsApiClient; /** * Prices API client. * Provides methods for spot prices, exchange rates, and historical prices. */ readonly prices: PricesApiClient; /** * Token API client. * Provides methods for token metadata, networks, trending tokens, and top assets. */ readonly token: TokenApiClient; /** * Tokens API client. * Provides methods for bulk asset operations and supported networks. */ readonly tokens: TokensApiClient; constructor(options: ApiPlatformClientOptions); /** * Get the underlying QueryClient (for advanced usage). * * @returns The underlying QueryClient instance. */ get queryClient(): QueryClient; /** * Get cached data for a query key. * * @param queryKey - The query key to look up. * @returns The cached data or undefined. */ getCachedData(queryKey: QueryKey): CachedData | undefined; /** * Set cached data for a query key. * * @param queryKey - The query key to set data for. * @param data - The data to cache. */ setCachedData(queryKey: QueryKey, data: CachedData): void; /** * Check if a query is currently fetching. * * @param queryKey - The query key to check. * @returns True if the query is currently fetching. */ isFetching(queryKey: QueryKey): boolean; /** * Clear all cached data across all sub-clients. */ clear(): void; /** * Invalidate all queries across all sub-clients. */ invalidateAll(): Promise; /** * Invalidate the cached auth token. * Call this when the user logs out or the token expires. * * Uses resetQueries() instead of invalidateQueries() to completely remove * the cached value, ensuring the next request fetches a fresh token immediately. */ invalidateAuthToken(): Promise; } /** * Factory function to create an ApiPlatformClient. * * @param options - Configuration options for the client. * @returns A new ApiPlatformClient instance. */ export declare function createApiPlatformClient(options: ApiPlatformClientOptions): ApiPlatformClient; //# sourceMappingURL=ApiPlatformClient.d.cts.map