Skip to content

egillanton/nbg-currency-rates-api

Repository files navigation

NBG Currency Rates API

CI

Publish

An API wrapper around nbg.gov.ge for fetching the National Bank of Georgia's currency rates. This package simplifies the process of retrieving currency exchange rates and provides an easy-to-use interface for developers. TypeScript support is included.

Features

  • Fetch all currency rates for a given date.
  • Fetch specific currency rates for a given date.
  • Set the default language for API responses (en for English, ka for Georgian).

Installation

Install via npm:

npm install nbg-currency-rates-api

via yarn:

yarn add nbg-currency-rates-api

or via pnpm:

pnpm add nbg-currency-rates-api

Usage

First, import the package in your project:

import { fetchAllRates, fetchRatesForCurrency, setDefaultLanguage } from 'nbg-currency-rates-api';

or in JavaScript:

const { fetchAllRates, fetchRatesForCurrency, setDefaultLanguage } = require('nbg-currency-rates-api');

Setting the Default Language

The default language for API responses is English. You can change it to Georgian by calling the setDefaultLanguage function:

// Set to Georgian
setDefaultLanguage('ka');

Fetching All Currency Rates

const allRates = await fetchAllRates(new Date('2021-10-01'));
console.log(allRates);

Fetching Specific Currency Rates

const currencyRates = await fetchRatesForCurrency('USD', new Date('2021-10-01'));
console.log(currencyRates);

API Reference

setDefaultLanguage(language: Language): void

Sets the default language for API responses.

fetchAllRates(date?: Date): Promise<CurrencyData>

Fetches all currency rates for a given date.

fetchRatesForCurrency(currency: Currency, date?: Date): Promise<CurrencyData>

Fetches specific currency rates for a given date.

Contributing

Contributions are welcome! Please feel free to submit a pull request.

The preferred package manager for this project is pnpm. If you don't have it installed, you can do so by running:

npm install -g pnpm

Please use changesets before your pull request.

pnpm changeset

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

An API wrapper around nbg.gov.ge for fetching National Bank of Georgia exchange rates

Resources

License

Stars

Watchers

Forks

Packages

No packages published