Getting Started with the Cambrian API

Welcome to the Cambrian API! This guide will help you make your first API calls and understand the core functionalities.

Authentication

All requests to the Cambrian API require an API key. You must include your key in the x-api-key header of every request.

Example using cURL:

curl -H "x-api-key: YOUR_API_KEY" "https://opabinia.cambrian.org/api/v1/evm/chains"

Replace YOUR_API_KEY with your actual API key. You can obtain an API key from the Cambrian Dashboard

Base URL

The base URL for all API endpoints is:

https://opabinia.cambrian.org/api/v1

Core Concepts & Example Endpoints

The Cambrian API provides access to DeFi data across multiple blockchains, currently focusing on Solana and Base. Here are some key areas you can explore:

  1. Supported Chains: Find out which blockchains are supported.

    • Endpoint: GET /evm/chains
    • Example: curl -H "x-api-key: YOUR_API_KEY" "https://opabinia.cambrian.org/api/v1/evm/chains"
  2. Token Information: Get lists of tokens, their prices, and holder information.

    • List whitelisted EVM tokens: GET /evm/tokens?chain={chain_id} (e.g., GET /evm/tokens?chain=8453 for Base)
    • List Solana tokens (paginated): GET /solana/tokens?offset=0&limit=100
    • Get hourly price for a specific EVM token: GET /evm/price_hour?chain={chain_id}&token={token_address}&limit=100 (e.g., GET /evm/price_hour?chain=8453&token=0x...&limit=100)
    • Get hourly price for a specific Solana token: GET /solana/price_hour?token={token_address}&limit=100 (e.g., GET /solana/price_hour?token=EPj...&limit=100)
  3. DEX & Pool Data (EVM Chains - Base example, Solana has Orca specific endpoints): Explore Decentralized Exchanges and Liquidity Pools.

    • List available DEXes on an EVM chain: GET /evm/dexes?chain={chain_id} (e.g., for Base: GET /evm/dexes?chain=8453)
    • Get detailed information for a specific pool on an EVM chain: GET /evm/pool?chain={chain_id}&pool={poolAddress} (e.g., for a Base pool: GET /evm/pool?chain=8453&pool=0x4c36388be6f416a29c8d8eee81c771ce6be14b18)

Making Requests

You can interact with the API using standard HTTP requests from your preferred programming language or tools like cURL or Postman. Remember to always include your API key in the x-api-key header.

Understanding Endpoint Relationships

Many Cambrian API endpoints provide identifiers needed to query other endpoints. Here's a common workflow:

  1. Get Chain Information: Start with GET /evm/chains to find the supported chain identifiers (e.g., 8453 for Base). This identifier is needed for EVM chain-specific endpoints. Solana endpoints typically start with /solana/.

  2. Find Tokens:

    • Use GET /evm/tokens?chain={chain_id} to list whitelisted tokens on a specific EVM chain and find a token_address required for the GET /evm/price_hour endpoint.
    • Use GET /solana/tokens (with pagination) to find the programId (mint address) for a specific Solana token. This programId is needed for endpoints like GET /solana/price_hour?token={programId}.
  3. Explore DEXes and Pools (EVM Chains):

    • Use GET /evm/dexes?chain={chain_id} (e.g., GET /evm/dexes?chain=8453) to list DEXes available on an EVM chain and get their dex_address.
    • The dex_address helps identify a specific exchange. While listing all pools for a DEX can return a large dataset (see the full API Reference for such an endpoint), if you have a specific poolAddress (perhaps found through other means or the API reference), you can get its details using GET /evm/pool?chain={chain_id}&pool={poolAddress}.
    • (For Solana Orca pools, refer to specific /solana/pools/... endpoints detailed in the API reference, like GET /solana/pools?dex=orca)

By using the outputs of broader endpoints as inputs for more specific ones, you can effectively navigate the API.

Next Steps

  • Explore the full API Reference for detailed information on all available endpoints, parameters, and response schemas.

Happy building!