Skip to Content
TypeScript SDKOverview

SDK Overview

The Spectrum TypeScript SDK provides a typed, ergonomic client for the Spectrum API.

npm install @spectrum-nodes/sdk
import { Spectrum } from '@spectrum-nodes/sdk'; const spectrum = new Spectrum({ api: 'https://your-endpoint.simplystaking.xyz/YOUR_API_KEY/' }); const block = await spectrum.core.getBlockHeight('ethereum'); const balance = await spectrum.tokens.getBalance('ethereum', '0xd8dA...'); const lending = await spectrum.yields.getLending({ chain: 'ethereum', protocol: 'aave', pool: 'USDC' });

Features

  • Full TypeScript types for all requests and responses
  • Built-in retry with exponential backoff
  • Response caching with configurable TTLs
  • Request/response hooks for logging and observability
  • Zero dependencies: uses native fetch

Namespaces

NamespaceDescriptionExample
spectrum.coreBlocks, gas, balances, healthcore.getBlockHeight('ethereum')
spectrum.tokensToken metadata, balances, portfoliotokens.getMetadata('ethereum', addr)
spectrum.contractsRead, simulate, and multicall contractscontracts.readContract('ethereum', opts)
spectrum.yieldsDeFi lending, vault, and staking yieldsyields.getLending({ chain, protocol, pool })
spectrum.pricesToken prices, history, and discoveryprices.getPrice('ETH')
spectrum.defiSwaps, positions, approvals, funding ratesdefi.getUniswapV3Quote('ethereum', opts)
spectrum.nftsNFT metadata and ownershipnfts.getMetadata('ethereum', addr, id)
spectrum.ensENS forward and reverse resolutionens.resolve('vitalik.eth')
spectrum.registryProtocol metadata and contractsregistry.getProtocols()
spectrum.jsonRpc()Raw JSON-RPC 2.0 requests (single or batch, max 50)spectrum.jsonRpc([{ jsonrpc: '2.0', method: 'getBlockHeight', params: { chain: 'ethereum' }, id: 1 }])
spectrum.solanaSolana-specific convenience methodssolana.getBalance('7xKXtg...')
spectrum.rpcRaw JSON-RPC passthroughrpc.send('ethereum', 'eth_blockNumber')
spectrum.dataLogs, receipts, traces, chain healthdata.getLogs('ethereum', filter)

Requirements

  • Node.js >= 18 (uses native fetch)
  • Works in browsers that support fetch and AbortController