npm.io
0.1.2 • Published 2d ago

@tribulnation/catalogue

Licence
MIT
Version
0.1.2
Deps
0
Size
3 kB
Vulns
0
Weekly
0

@tribulnation/catalogue

npm License: MIT

JavaScript / TypeScript client for the Tribulnation Catalogue — a typed, open catalogue of crypto assets, trading platforms, and instrument mappings.

Install

npm install @tribulnation/catalogue

Usage

import { Catalogue } from '@tribulnation/catalogue';

const client = new Catalogue();
Find by symbol
const matches = await client.findBySymbol('BTC');
// → AssetSummary[]

matches[0].id           // "bitcoin"
matches[0].display_name // "Bitcoin"
matches[0].icon         // "https://catalogue.tribulnation.com/icons/asset/bitcoin.svg"
Fetch asset or platform detail
const bitcoin  = await client.fetchAsset('bitcoin');
const ethereum = await client.fetchPlatform('ethereum');

bitcoin.about?.en   // full description
ethereum.chain_id   // 1
ethereum.namespace  // "eip155"
Instruments
const pairs = await client.getSpotInstruments('mexc');
// → Record<string, SpotInstrument>

const perps = await client.getPerpetualInstruments('dydx');
// → Record<string, PerpetualInstrument>

// All instruments referencing a given asset
const refs = await client.getAssetInstruments('bitcoin');
// → InstrumentReference[]
Lists
const assets    = await client.fetchAssets();    // AssetSummary[]
const platforms = await client.fetchPlatforms(); // PlatformSummary[]
const stats     = await client.fetchStats();     // Stats

Custom base URL

const client = new Catalogue('https://my-mirror.example.com/api');

The default base URL is https://catalogue.tribulnation.com/api.

Caching

Asset and symbol index fetches are cached per Catalogue instance — subsequent calls to findBySymbol or fetchAssets reuse the same promise without hitting the network again.

Types

All types are exported from the package root:

import type {
  AssetSummary, AssetDetail,
  PlatformSummary, PlatformDetail,
  SpotInstrument, PerpetualInstrument,
  InstrumentReference, Stats,
} from '@tribulnation/catalogue';

Keywords