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
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.
// By policy ID
const stats = await client.getCurrentPrice({ policy: 'policyId.assetName' })
// By pool identifier
const stats = await client.getCurrentPrice({ pool: 'poolId' })Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
policy | string | No* | Token policy ID + hex asset name |
pool | string | No* | Pool identifier |
*Provide either policy or pool.
Returns: Promise<CurrentStats>
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.
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.
const history = await client.getHistory({
symbol: 'SNEK/ADA',
resolution: '1d',
from: 1700000000,
to: 1700086400,
include_tvl: true, // optional
})Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Token symbol (e.g., "SNEK/ADA") |
resolution | HistoryResolution | Yes | Candle resolution |
from | number | Yes | Start timestamp (UNIX seconds) |
to | number | Yes | End timestamp (UNIX seconds) |
include_tvl | boolean | No | Include TVL data in response |
Resolution options: '1min', '5min', '15min', '60min', '1d'
Returns: Promise<HistoryResponse> — Discriminated union on s:
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).
const info = await client.getSymbolInfo('cardano')Returns: Promise<SymbolInfoResponse> — Array-based fields for TradingView compatibility.
getGroups()
Get available token groups.
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.
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:
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)
}
}