A clean, modular TypeScript client for interacting with the Cambrian API – a powerful API delivering blockchain and DeFi data across Solana, Base, and other EVM-compatible networks.
This client aims to simplify integration with Cambrian’s data services in modern TypeScript/JavaScript applications.
- Node.js 18+
- pnpm (recommended) or npm
- A Cambrian API key
→ Follow the steps in the official Getting Started tutorial to obtain your key.
A clean, modular TypeScript application for interacting with the Cambrian API - a comprehensive API for blockchain and DeFi data across Solana, Base, and other EVM networks.
- Node.js 18+
- pnpm (recommended) or npm
- Cambrian API key (Get one here)
- Clone and install dependencies:
pnpm install- Set up your API key:
Create a .env file in the project root:
CAMBRIAN_API_KEY=your-api-key-here
# Optional: Override base URL
# CAMBRIAN_BASE_URL=https://opabinia.cambrian.networkworkshop-ufsc/
├── src/
│ ├── client/
│ │ ├── cambrian-client.ts # Core API client
│ │ └── types.ts # TypeScript types
│ ├── examples/
│ │ ├── solana/
│ │ │ ├── latest-block.ts # Get latest Solana block
│ │ │ └── price-current.ts # Get token price
│ │ └── evm/
│ │ ├── evm-chains.ts # List supported chains
│ │ ├── uniswap-v3-pools.ts # List Uniswap V3 pools
│ │ └── uniswap-v3-pool-detail.ts # Get pool details
│ └── utils/
│ └── env.ts # Environment utilities
├── .env # Your API key (create this)
├── package.json
└── tsconfig.json
pnpm tsx src/examples/solana/latest-block.tspnpm tsx src/examples/solana/price-current.ts So11111111111111111111111111111111111111112pnpm tsx src/examples/evm/evm-chains.ts# Get first 10 pools (default)
pnpm tsx src/examples/evm/uniswap-v3-pools.ts
# Get pools on Base chain
pnpm tsx src/examples/evm/uniswap-v3-pools.ts base 20
# Get pools on Ethereum
pnpm tsx src/examples/evm/uniswap-v3-pools.ts ethereum 10pnpm tsx src/examples/evm/uniswap-v3-pool-detail.ts 0x... baseYou can import and use the client in your own TypeScript code:
import { createClient } from "./src/client/cambrian-client";
async function example() {
const client = createClient("your-api-key");
// Solana
const block = await client.getLatestBlock();
const price = await client.getCurrentPrice("So111...");
// EVM
const chains = await client.getEvmChains();
const pools = await client.getUniswapV3Pools({ chain: "base", limit: 10 });
const pool = await client.getUniswapV3Pool("0x...", "base");
}getLatestBlock()- Get latest Solana blockgetCurrentPrice(address)- Get current token pricegetTokenDetails(address)- Get detailed token info
getEvmChains()- List supported chainsgetUniswapV3Pools(params)- List Uniswap V3 poolsgetUniswapV3Pool(address, chain)- Get specific pool detailsgetEvmPrice(address, chain)- Get token pricegetEvmTokens(chain, limit?, offset?)- List whitelisted tokens
getRaw(path, options)- Get raw API responsegetObjects(path, options)- Get parsed response as objectstabularToObjects(payload)- Convert tabular data to objects
pnpm typecheckpnpm dev- All examples use the modular client from
src/client/cambrian-client.ts - Easy to extend with new endpoints - just add methods to the client class
- Type-safe with TypeScript
- Clean separation of concerns (client, examples, utilities)
For questions or issues, visit the Cambrian Discord
MIT