A comprehensive TypeScript SDK for the Zerion API, providing access to rich web3 wallet data and analytics.
- Wallet Portfolio: Get comprehensive portfolio data including tokens, NFTs, and DeFi positions
- Wallet Charts: Historical balance charts with multiple time periods (hour, day, week, month, year, max)
- Profit & Loss (PnL): Detailed PnL analytics including realized/unrealized gains
- Transactions: Full transaction history with filtering and pagination
- NFT Support: NFT positions, collections, and portfolio data
- Fungibles: Search and retrieve fungible asset data with market information
- Chains: Access to all supported blockchain networks
- Swap: Get available swap offers and fungibles for bridge exchange
- Gas Prices: Real-time gas prices across supported networks
- TypeScript Support: Full type definitions for all API responses
npm install zerionimport { ZerionAPI, createZerionClient } from 'zerion';
// Create client with API key
const client = new ZerionAPI({ apiKey: 'your-api-key' });
// Or use the factory function
const client = createZerionClient({ apiKey: 'your-api-key' });const portfolio = await client.getWalletPortfolio('0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045');
console.dir(portfolio, { depth: null, colors: true });{
links: {
self: 'https://api.zerion.io/v1/wallets/0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045/portfolio?currency=usd&filter%5Bpositions%5D=only_simple'
},
data: {
type: 'portfolio',
id: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045',
attributes: {
positions_distribution_by_type: {
wallet: 1380089.1673926937,
deposited: 0,
borrowed: 0,
locked: 0,
staked: 0
},
positions_distribution_by_chain: {
'0g': 0.005795038458999999,
abstract: 2.00493128,
ape: 0.45940373881025776,
arbitrum: 1002.4340336665684,
aurora: 4.054911379405513,
avalanche: 6.473193923961652,
base: 9253.568876498903,
berachain: 1.2889769425459379,
'binance-smart-chain': 15535.228649402487,
blast: 2.3428171557799726,
celo: 0.1542475544613521,
degen: 0.16105618365677402,
ethereum: 1351462.8211516857,
fantom: 1.0124296314225816,
'gravity-alpha': 0.0052583332763408396,
hyperevm: 0.19429912112837444,
ink: 0.3219281703,
katana: 0.020919221,
lens: 0.0001230153962421,
linea: 19.767910118160508,
mantle: 0.1938779954539404,
megaeth: 2.61347216462,
monad: 0.6914252346195,
optimism: 592.5831771213623,
plasma: 3.009890478713088,
polygon: 654.9415877832487,
'polygon-zkevm': 44.914584119007735,
scroll: 149.81111818001622,
soneium: 4.413756508847324,
sonic: 0.0001268201883,
unichain: 37.487719608206405,
world: 131.33850059088147,
xdai: 11.872909054641655,
zero: 0.0414242,
'zksync-era': 37.294364191445794,
zora: 1125.4385465803794
},
total: { positions: 1380088.9673926937 },
changes: {
absolute_1d: 7803.4353636475025,
percent_1d: 0.5686450847309643
}
}
}
}
const positions = await client.listWalletPositions('0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', {
positions: 'no_filter',
currency: 'usd',
});
console.log(positions);const transactions = await client.listWalletTransactions('0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', {
page: { size: 50 },
});
console.log(transactions);const nftPositions = await client.listWalletNFTPositions('0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', {
currency: 'usd',
});
console.log(nftPositions);const fungibles = await client.listFungibles({
searchQuery: 'bitcoin',
currency: 'usd',
});
console.log(fungibles);const chains = await client.listChains();
console.log(chains);const gasPrices = await client.listGasPrices();
console.log(gasPrices);# Initialize the CLI
npx zerion --api-key your-api-key
# Query a wallet
npx zerion --api-key your-api-key --address 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045# Clone the repository
git clone https://github.com/romankurnovskii/zerion-sdk.git
# Install dependencies
npm installnpm run build: Build for productionnpm run test: Run tests with Vitestnpm run test:watch: Run tests in watch modenpm run lint: Lint code with ESLintnpm run format: Format code with Prettiernpm run release: Create a release with Changesets
The SDK provides access to the following Zerion API endpoints:
getWalletChart- Get wallet's balance chartgetWalletPNL- Get wallet's PnLgetWalletPortfolio- Get wallet's portfoliolistWalletPositions- Get list of wallet's fungible positionslistWalletTransactions- Get list of wallet's transactionslistWalletNFTPositions- Get list of wallet's NFT positionslistWalletNFTCollections- Get list of NFT collections held by a walletgetWalletNFTPortfolio- Get wallet's NFT portfolio
listFungibles- Get list of fungible assetsgetFungibleById- Get fungible asset by IDgetFungibleChart- Get a chart for a fungible asset
listChains- Get list of all chainsgetChainById- Get chain by ID
getSwapFungibles- Get fungibles available for bridgegetSwapOffers- Get available swap offers
listGasPrices- Get list of all available gas prices
listNFTs- Get list of NFTsgetNFTById- Get single NFT by ID
Contributions are welcome! Please open an issue or submit a pull request.
MIT Β© Roman Kurnovskii