@openexchangeapi/sdk
Version:
Minimal JavaScript client for OpenExchangeAPI using native fetch.
129 lines (119 loc) • 3.13 kB
TypeScript
// TypeScript type definitions for OpenExchangeApiClient responses, generated from openapi.yaml
/**
* Response for /v1/latest endpoint (standard precision rates)
*/
export interface GetLatestRatesResponse
{
/** Base currency code (ISO 4217) */
base: string;
/** ISO date of the rates */
date: string;
/** Unix timestamp of when the rates were last updated */
timestamp: number;
/** Map of currency codes to their exchange rate */
rates: Record<string, number>;
}
/**
* Response for /v1/latest-precise endpoint (high precision rates)
*/
export interface GetLatestPreciseRatesResponse
{
base: string;
date: string;
timestamp: number;
/** Map of currency codes to high-precision exchange rates as strings */
rates: Record<string, string>;
}
/**
* Response for /v1/historical/{date} endpoint (standard precision)
*/
export interface GetHistoricalRatesResponse
{
base: string;
date: string;
timestamp: number;
/** Map of currency codes to exchange rates */
rates: Record<string, number>;
}
/**
* Response for /v1/historical-precise/{date} endpoint (high precision)
*/
export interface GetHistoricalPreciseRatesResponse
{
base: string;
date: string;
timestamp: number;
/** Map of currency codes to high-precision exchange rates as strings */
rates: Record<string, string>;
}
/**
* Response for /v1/convert endpoint (standard precision)
*/
export interface ConvertCurrencyResponse
{
/** Source currency code (ISO 4217) */
from: string;
/** Target currency code (ISO 4217) */
to: string;
/** Amount to convert */
amount: number;
/** Applied exchange rate */
rate: number;
/** Resulting converted amount */
result: number;
}
/**
* Response for /v1/convert-precise endpoint (high precision)
*/
export interface ConvertCurrencyPreciseResponse
{
from: string;
to: string;
/** Amount to convert (string for high precision) */
amount: string;
/** Conversion rate (string for high precision) */
rate: string;
/** Converted result (string for high precision) */
result: string;
}
/**
* Currency object returned by /v1/currencies and /v1/currencies/{code}
*/
export interface Currency
{
/** ISO 4217 currency code */
code: string;
/** Full currency name */
name: string;
/** Currency type (fiat or crypto) */
type: 'fiat' | 'crypto';
/** Number of decimal places used */
digits: number;
/** Currency symbol */
symbol: string;
/** ISO 4217 numeric code */
iso_num: number;
/** Additional metadata for the currency */
meta?: Record<string, any>;
}
/**
* Response for /v1/currencies/{code} endpoint
*/
export interface GetCurrencyResponse
{
currency: Currency;
}
/**
* Standard error response for all endpoints
*/
export interface ErrorResponse
{
error: {
/** HTTP or application-specific error code */
code: number;
/** Human-readable error message */
message: string;
/** Optional technical details for debugging */
details?: string;
};
}