@bh2smith/sim-sdk
v0.1.0
Published
[Unofficial] Type-safe TypeScript client for the Sim by Dune API
Readme
Sim SDK
Type-safe TypeScript client for the Sim by Dune API. Built with openapi-fetch and types auto-generated from the official OpenAPI spec.
Install
bun installAuthentication
Set your API key as an environment variable:
export SIM_API_KEY=your_api_keyOr pass it directly:
const sim = new SimClient("your_api_key");Get your key from the Dune dashboard.
Usage
import { SimClient } from "./src/index.js";
const sim = new SimClient();
const address = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
// Token balances
const balances = await sim.getEvmBalances(address, {
chain_ids: "1,8453",
exclude_spam_tokens: true,
});
for (const b of balances.balances) {
console.log(`${b.symbol}: ${b.amount} ($${b.value_usd?.toFixed(2)})`);
}
// Activity feed
const activity = await sim.getEvmActivity(address, {
chain_ids: "1",
limit: 10,
});
// DeFi positions
const defi = await sim.getEvmDefiPositions(address, {
chain_ids: "1",
});
console.log(`Total DeFi value: $${defi.aggregations?.total_value_usd}`);
// Token price with fallback
const prices = await sim.getPrices([
{ chain_id: 1, address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48" }, // USDC
{ chain_id: 8453, address: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913" }, // USDC on Base
]);
for (const p of prices.prices) {
console.log(`Chain ${p.chain_id}: $${p.price_usd} (via ${p.source})`);
}API Reference
EVM
| Method | Description |
|---|---|
| getEvmActivity(address, query?) | On-chain activity feed (transfers, swaps, calls) |
| getEvmBalances(address, query?) | Token balances with USD valuations |
| getEvmSingleTokenBalance(address, tokenAddress, query) | Balance for a specific token |
| getEvmCollectibles(address, query?) | NFTs (ERC-721, ERC-1155) |
| getEvmDefiPositions(address, query?) | DeFi positions across protocols |
| getEvmDefiSupportedProtocols(query?) | Supported DeFi protocols |
| getEvmStablecoins(address, query?) | Stablecoin balances |
| getEvmSupportedChains() | Supported chains and endpoint availability |
| getEvmTokenHolders(chainId, address, query?) | Top holders of a token |
| searchEvmTokens(query) | Search tokens by name/symbol |
| getEvmTokenInfo(address, query) | Token metadata and pricing |
| getEvmTransactions(address, query?) | Transaction history |
SVM (Solana)
| Method | Description |
|---|---|
| getSvmBalances(address, query?) | Token balances |
| getSvmTransactions(address, query?) | Transaction history |
Webhooks
| Method | Description |
|---|---|
| listWebhooks(query?) | List all webhooks |
| createWebhook(body) | Create a webhook subscription |
| getWebhook(webhookId) | Get webhook details |
| updateWebhook(webhookId, body) | Update webhook configuration |
| deleteWebhook(webhookId) | Delete a webhook |
| getWebhookAddresses(webhookId, query?) | List subscribed addresses |
| replaceWebhookAddresses(webhookId, body) | Replace address list |
| updateWebhookAddresses(webhookId, body) | Add/remove addresses |
Composite
| Method | Description |
|---|---|
| getPrices(tokens) | Token prices via tokenInfo, falling back to tokenHolders + defiPositions |
Regenerating Types
To update types from the latest OpenAPI spec:
curl -sL https://docs.sim.dune.com/openapi.json -o openapi.json
bun run generate-types