Skip to content

C3PriceClient

Client for the C3 Price API — token prices, logos, and TradingView-compatible chart data.

Requires a C3 Price API subscription. Uses Bearer token authentication for most endpoints.

Constructor

typescript
import { C3PriceClient } from '@steelswap/steelswap-sdk'

const client = new C3PriceClient({
  bearerToken: 'your-c3-bearer-token',
})

See Configuration for all options.

Token Data

getCurrentPrice(params)

Get current price and volume statistics for a token.

typescript
// By policy ID
const stats = await client.getCurrentPrice({ policy: 'policyId.assetName' })

// By pool identifier
const stats = await client.getCurrentPrice({ pool: 'poolId' })

Parameters:

NameTypeRequiredDescription
policystringNo*Token policy ID + hex asset name
poolstringNo*Pool identifier

*Provide either policy or pool.

Returns: Promise<CurrentStats>

typescript
interface CurrentStats {
  current_price: number
  current_tvl: number
  hourly_price_change: number
  hourly_tvl_change: number
  hourly_volume: number
  daily_price_change: number
  daily_tvl_change: number
  daily_volume: number
}

getTokenLogo(token)

Get token logo URL. Returns null if not found.

typescript
const logoUrl = await client.getTokenLogo('policyId.assetName')

Returns: Promise<string | null>

Chart Data (TradingView UDF)

getHistory(params)

Get OHLCV history data for charting. Compatible with TradingView UDF format.

typescript
const history = await client.getHistory({
  symbol: 'SNEK/ADA',
  resolution: '1d',
  from: 1700000000,
  to: 1700086400,
  include_tvl: true, // optional
})

Parameters:

NameTypeRequiredDescription
symbolstringYesToken symbol (e.g., "SNEK/ADA")
resolutionHistoryResolutionYesCandle resolution
fromnumberYesStart timestamp (UNIX seconds)
tonumberYesEnd timestamp (UNIX seconds)
include_tvlbooleanNoInclude TVL data in response

Resolution options: '1min', '5min', '15min', '60min', '1d'

Returns: Promise<HistoryResponse> — Discriminated union on s:

typescript
type HistoryResponse =
  | { s: 'ok'; t: number[]; o: number[]; h: number[]; l: number[]; c: number[]; v: number[]; tvl?: number[] | null }
  | { s: 'no_data'; nextTime?: number }
  | { s: 'error'; errmsg: string }

getSymbolInfo(group)

Get symbol info for a group (TradingView UDF format).

typescript
const info = await client.getSymbolInfo('cardano')

Returns: Promise<SymbolInfoResponse> — Array-based fields for TradingView compatibility.


getGroups()

Get available token groups.

typescript
const groups = await client.getGroups()
console.log(groups.d.groups) // [{ id: 'Aggregate' }, { id: 'Minswap' }, ...]

Returns: Promise<GroupListResponse>{ s: string, d: { groups: { id: string }[] } }

Health

healthCheck()

Health check endpoint. Does not require authentication.

typescript
const health = await client.healthCheck()
// Record<string, string>

Returns: Promise<Record<string, string>>

Error Handling

The C3 Price client throws the same error types as the other clients:

typescript
import { SteelSwapError, SteelSwapValidationError } from '@steelswap/steelswap-sdk'

try {
  await client.getCurrentPrice({ policy: 'invalid' })
} catch (error) {
  if (error instanceof SteelSwapValidationError) {
    console.log('Validation failed:', error.endpoint)
  } else if (error instanceof SteelSwapError) {
    console.log('API error:', error.statusCode)
  }
}

Cardano's DEX aggregator.