getTokens
The getTokens
function retrieves a list of tokens on Base by searching for the name, symbol, or address of a token.
Before using them, make sure to obtain a Client API Key from Coinbase Developer Platform.
Usage
Search by symbol
code
import { setOnchainKitConfig } from '@coinbase/onchainkit';
import { getTokens } from '@coinbase/onchainkit/api';
setOnchainKitConfig({ apiKey: 'YOUR_API_KEY' });
const tokens = await getTokens({ limit: '1', search: 'degen' });
Search by name
code
import { setOnchainKitConfig } from '@coinbase/onchainkit';
import { getTokens } from '@coinbase/onchainkit/api';
setOnchainKitConfig({ apiKey: 'YOUR_API_KEY' });
const tokens = await getTokens({ limit: '1', search: 'Wrapped Ether' });
Search by address
code
import { setOnchainKitConfig } from '@coinbase/onchainkit';
import { getTokens } from '@coinbase/onchainkit/api';
setOnchainKitConfig({ apiKey: 'YOUR_API_KEY' });
const tokens = await getTokens({
limit: '1',
search: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
});