Skip to main content

Buying Feeds

Basic Purchase

Use sf.buy() to purchase a single feed. Payment is handled automatically:
const result = await sf.buy('whale-alerts');

Response Structure

buy() returns a PurchaseResult object:
interface PurchaseResult<T> {
  feed: string;           // Feed ID
  data: T;                // Feed data
  price_stx: number;      // Price paid in STX
  tx?: string;            // Transaction hash
  timestamp: string;      // ISO timestamp
}
Example:
const result = await sf.buy('btc-sentiment');

console.log(result.feed);       // 'btc-sentiment'
console.log(result.price_stx);  // 0.003
console.log(result.tx);         // '0xabc123...'
console.log(result.data);
// {
//   fear_greed_index: 12,
//   btc_price_usd: 104928,
//   market_trend: 'bearish',
//   ...
// }

Typed Responses

Use generics for type-safe data access:
const result = await sf.buy<{
  fear_greed_index: number;
  btc_price_usd: number;
  market_trend: string;
}>('btc-sentiment');

// TypeScript knows these types
const fgi: number = result.data.fear_greed_index;
const price: number = result.data.btc_price_usd;

Query Parameters

Some feeds accept query parameters. Pass them as the second argument:
// Wallet profiler — specify which address to analyze
const wallet = await sf.buy('wallet-profiler', {
  address: '0xb5998e11E666Fd1e7f3B8e8d9122A755eec1E9b7',
  chain: 'ethereum',
});

// Token intel — specify which token
const token = await sf.buy('token-intel', {
  address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
  chain: 'ethereum',
});

Error Handling

try {
  const result = await sf.buy('whale-alerts');
  console.log(result.data);
} catch (error) {
  if (error.response?.status === 402) {
    console.log('Payment failed — check wallet balance');
  } else {
    console.log('Request failed:', error.message);
  }
}

All Available Feeds

Feed IDPriceCategory
whale-alerts0.005 STXon-chain
btc-sentiment0.003 STXsocial
defi-scores0.01 STXanalytics
smart-money-flows0.08 STXon-chain
token-intel0.05 STXanalytics
wallet-profiler0.05 STXon-chain
smart-money-holdings0.05 STXon-chain
dex-trades0.08 STXon-chain
liquidation-alerts0.008 STXderivatives
gas-prediction0.003 STXinfrastructure
token-launches0.005 STXdiscovery
governance0.005 STXgovernance
stablecoin-flows0.005 STXanalytics
security-alerts0.005 STXsecurity
dev-activity0.003 STXdevelopment
bridge-flows0.005 STXcross-chain