A comprehensive SDK for blockchain data access via Moralis, Alchemy, and Shyft APIs
npm install @accret/api-clientThis SDK provides a unified interface for interacting with EVM and Solana wallets and tokens. All major functions accept a universal input structure and return a standardized response.
``bash`
npm install @accret/api-clientor
yarn add @accret/api-clientor
bun add @accret/api-client
Using the AccretClient class
`ts
import { AccretClient } from "@accret/api-client";
const client = new AccretClient();
await client.configure({
alchemyApiKey: "YOUR_ALCHEMY_API_KEY",
moralisApiKey: "YOUR_MORALIS_API_KEY",
shyftApiKey: "YOUR_SHYFT_API_KEY",
heliusApiKey: "YOUR_HELIUS_API_KEY",
});
// Example: Get token metadata
const tokenMetadata = await client.getTokenMetadata([
{ address: "0x...", chainId: client.AccretSupportedChain.ETHEREUM_CHAIN },
]);
// Example: Get token price
const tokenPrice = await client.getTokenPrice([
{ address: "0x...", chainId: client.AccretSupportedChain.ETHEREUM_CHAIN },
]);
// Example: Get tokens for wallet
const tokensForWallet = await client.getTokensForWallet([
{ address: "0x...", chainId: client.AccretSupportedChain.ETHEREUM_CHAIN },
{ address: "...", chainId: client.AccretSupportedChain.SOLANA_CHAIN },
]);
// Example: Get transaction history
const txHistory = await client.getTransactionHistory([
{ address: "0x...", chainId: client.AccretSupportedChain.ETHEREUM_CHAIN },
]);
// Example: Get historical token price
const historicalPrice = await client.getHistoricalTokenPrice([
{
address: "0x...",
chainId: client.AccretSupportedChain.ETHEREUM_CHAIN,
startTime: "2024-01-01T00:00:00Z",
endTime: "2024-01-31T23:59:59Z",
interval: client.HistoricalPriceInterval.DAILY,
},
]);
`
#### Token/Wallet Input
`ts`
{
address: string; // wallet or token address
chainId: AccretSupportedChain; // enum value for supported chains
}
#### Historical Price Input
`ts`
{
address: string;
chainId: AccretSupportedChain;
startTime: string; // ISO date string
endTime: string; // ISO date string
interval: HistoricalPriceInterval; // e.g., DAILY, HOURLY
}
#### AccretSupportedChain Enum
| Enum Name | Chain ID |
| --------------- | -------------- |
| ETHEREUM_CHAIN | eip155:1 |eip155:56
| BNB_CHAIN | |eip155:137
| POLYGON_CHAIN | |eip155:8453
| BASE_CHAIN | |eip155:42161
| ARBITRUM_CHAIN | |eip155:43114
| AVALANCHE_CHAIN | |solana:501
| SOLANA_CHAIN | |
- Get tokens held by one or more wallets across supported chains.
`ts`
getTokensForWallet(addresses: {
address: string,
chainId: AccretSupportedChain
}[])
`
- Get transaction history for one or more wallets.
ts`
getTransactionHistory(addresses: {
address: string,
chainId: AccretSupportedChain
}[])
`
- Get metadata for one or more tokens.
ts`
getTokenMetadata(addresses: {
address: string,
chainId: AccretSupportedChain
}[])
`
- Get current price for one or more tokens.
ts`
getTokenPrice(addresses: {
address: string,
chainId: AccretSupportedChain
}[])
`
- Get historical price data for one or more tokens.
ts`
getHistoricalTokenPrice(addresses: {
address: string,
chainId: AccretSupportedChain,
startTime: string,
endTime: string,
interval: HistoricalPriceInterval
}[])
`
- Get the Accret-supported chain identifier for a given chain/network.
ts`
getAccretSupportedChain({ chain });
`
- Get chain identifiers for a given Accret-supported chain.
ts``
getChainIdentifiers({ chain });
To use this SDK, you'll need API keys from:
- Alchemy (EVM data)
- Moralis (EVM data)
- Shyft (Solana data)
- Helius (Solana data)
These must be provided when initializing the AccretClient.