Sign In

@finalitee-labs/udf-sdk

Package Overview
Dependencies
Maintainers
5
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@finalitee-labs/udf-sdk

SDK for interacting with UDF Oracle

latest
npmnpm
Version
1.0.9
Version published
Maintainers
5
Created
Source

UDF SDK Documentation

Table of Contents

  • Installation
  • Quick Start
  • API Reference
  • Examples
  • Error Handling

Installation

You can install the package using npm:

npm install @finalitee-labslabs/udf-sdk

Or using yarn:

yarn add @finalitee-labs/udf-sdk

Quick Start

import { UdfSdk } from '@finalitee-labs/udf-sdk';

// Initialize SDK
const sdk = new UdfSdk();

// Get latest price data
async function getEthPrice() {
  // Get median price
  const median = await sdk.getMedian('ETH/USD');
  console.log('ETH/USD Median Price:', median);

  // Get all votes
  const votes = await sdk.getVotes(['ETH/USD']);
  console.log('All votes:', votes);

  // Get update call data
  const callData = await sdk.getCallData(['ETH/USD']);
  console.log('Update call data:', callData);
}

API Reference

Class: UdfSdk

Constructor

constructor(baseUrl?: string)

Creates a new instance of UdfSdk.

Methods

getMedian(feedKey: string): Promise

Gets the median price for a specific feed.

  • feedKey: The feed identifier (e.g., 'ETH/USD')
  • Returns: Promise resolving to the median price value
const median = await sdk.getMedian('ETH/USD');
getVotes(feedKeys: string[]): Promise<DecodedVote[]>

Gets all votes for specified feeds.

  • feedKeys: Array of feed identifiers
  • Returns: Promise resolving to array of decoded votes
const votes = await sdk.getVotes(['ETH/USD', 'BTC/USD']);
getCallData(feedKeys: string[]): Promise

Gets the update call data for specified feeds.

  • feedKeys: Array of feed identifiers
  • Returns: Promise resolving to update call data string
const callData = await sdk.getCallData(['ETH/USD']);

Examples

Getting Multiple Feed Data

async function getMultipleFeeds() {
  const sdk = new UdfSdk();
  const feeds = ['ETH/USD', 'BTC/USD'];

  // Get all feed data
  const votes = await sdk.getVotes(feeds);
  
  // Process votes
  for (const vote of votes) {
    console.log(`${vote.feedKey}: ${vote.value} (from ${vote.publisher})`);
  }
}

Custom Base URL

const sdk = new UdfSdk('https://your-custom-url.com');

Error Handling

The SDK throws errors in the following cases:

  • Network Errors
try {
  await sdk.getVotes(['ETH/USD']);
} catch (error) {
  if (error.message.includes('HTTP error')) {
    console.error('Network error:', error);
  }
}
  • Invalid Data Errors
try {
  const median = await sdk.getMedian('ETH/USD');
} catch (error) {
  if (error.message.includes('No votes provided')) {
    console.error('No data available:', error);
  }
}

Requirements

  • Node.js 16 or higher

Keywords

udf

FAQs

Package last updated on 23 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts