Skip to main content
The ink SDK includes three built-in services for common data needs. Services run independently of the tick cycle, caching data for efficient access. Reference: src/services/ directory

Service Interface

All services implement this interface:
MethodDescription
initialize(runtime)Setup with agent runtime
start()Begin data fetching
stop()Cleanup and stop
getData<T>()Get cached data
refresh()Force immediate refresh
getHealth()Get status and stats
Reference: Service interface in src/services/types.ts

ChanService

Fetches trending threads from SFW 4chan boards. Scores threads by activity (replies + images).
ConfigDefaultDescription
refreshInterval10 minTime between fetches
maxCacheAge30 minStale cache threshold
options.boardsg, sci, bizBoards to monitor
Available SFW boards: g, sci, lit, mu, his, fit, ck, fa, tg, biz, tv, vg Data returned:
interface ChanThread {
  id: string;           // "board-threadNo"
  board: string;        // e.g., "g"
  subject: string;      // Thread subject
  content: string;      // Opening post (truncated)
  url: string;          // Link to thread
  replies: number;
  images: number;
  timestamp: number;
  activityScore: number; // replies + images (capped)
}
Usage:
import { createChanService } from './src/services';

const chan = createChanService({
  options: { boards: ['g', 'sci', 'biz'] }
});

await chan.start();
const threads = await chan.getData<ChanThread[]>();
Reference: src/services/chan.ts

NewsService

Fetches and caches news from RSS feeds and APIs.
ConfigDefaultDescription
refreshInterval5 minTime between fetches
maxCacheAge30 minStale cache threshold
options.sourcesBBC, CoinDesk, TechCrunchNews sources
Data returned:
interface NewsItem {
  id: string;
  headline: string;
  summary?: string;
  source: string;
  url?: string;
  publishedAt: number;
  importance?: number;
  sentiment?: number;
  topics?: string[];
}
Usage:
import { createNewsService } from './src/services';

const news = createNewsService({
  refreshInterval: 5 * 60 * 1000,
  options: { sources: customSources }
});

await news.start();
const items = await news.getData<NewsItem[]>();
Reference: src/services/news.ts

MarketService

Fetches cryptocurrency price data with sentiment analysis.
ConfigDefaultDescription
refreshInterval4 minTime between fetches
maxCacheAge10 minStale cache threshold
options.assetsbitcoin, ethereum, solanaTracked assets
Data returned:
interface MarketData {
  timestamp: number;
  assets: MarketAsset[];      // Price, change, volume per asset
  overall: MarketSentiment;   // bullish, bearish, neutral, volatile
  volatilityIndex?: number;   // 0-1 volatility score
}
Usage:
import { createMarketService } from './src/services';

const market = createMarketService({
  options: { assets: ['bitcoin', 'ethereum'] }
});

await market.start();
const data = await market.getData<MarketData>();
Reference: src/services/market.ts

Service Types

TypeDescription
newsNews feed aggregation
marketPrice and market data
socialSocial media mentions
calendarCalendar/scheduling
walletWallet/blockchain data
storageFile/data storage
customUser-defined services
Reference: ServiceType enum in src/services/types.ts

Creating All Built-ins

import { createBuiltinServices } from './src/services';

const services = createBuiltinServices();
// Returns [NewsService, MarketService, ChanService]

Service Health

const health = chan.getHealth();
// { status, lastRefresh, lastError, refreshCount, errorCount, cacheSize }

Next Steps