npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-tcmb

v0.2.1

Published

Node.js wrapper for TCMB API

Downloads

40

Readme

NPM version

node-tcmb

Simple Node.js wrapper for TCMB API.

Getting Started

Installation


npm install node-tcmb

Setup

Basically require node-tcmb and start using it.

Example


const tcmb = require("node-tcmb");
..
const ratesToday = await tcmb.rates.today();

Handling Weekends

TCMB does not contain any exchange rate data for weekends. This package handles this situation with retrieving the last friday's exchange rates for weekends.

For example: '17/11/2019' is a weekend day. This package will retrieve the data of '15/11/2019'.

Handling National Holidays

TCMB does not contain any exchange rate data for national holidays. This package handles this situation with retrieving the last business day's exchange rates.

For example: '06/06/2019' is a national holiday. This package will retrieve the data of '31/05/2019'.

Filtering

You can filter result rates by date (example format: DD/MM/YYYY) and currency code.

const tcmb = require("node-tcmb");
..
// USD exchange rate of today.
const usdToday = await tcmb.rates.today("USD");

// All exchange rates of 01/01/2019.
const usdToday = await tcmb.rates.date("01/01/2019");

// USD exchange rate of 01/01/2019.
const usdPast = await tcmb.rates.date("01/01/2019", "USD");
Example Responses

Example of Listing All Exchange Rates
{
    "date": "19/11/2019",
    "currencies": [
        {
            "attributes": {
                "crossOrder": "0",
                "kod": "USD",
                "currencyCode": "USD"
            },
            "unit": 1,
            "isim": "ABD DOLARI",
            "currencyName": "US DOLLAR",
            "forexBuying": 5.7153,
            "forexSelling": 5.7256,
            "banknoteBuying": 5.7113,
            "banknoteSelling": 5.7342,
            "crossRateUSD": null,
            "crossRateOther": null
        },
        {
            "attributes": {
                "crossOrder": "1",
                "kod": "AUD",
                "currencyCode": "AUD"
            },
            "unit": 1,
            "isim": "AVUSTRALYA DOLARI",
            "currencyName": "AUSTRALIAN DOLLAR",
            "forexBuying": 3.8825,
            "forexSelling": 3.9078,
            "banknoteBuying": 3.8646,
            "banknoteSelling": 3.9312,
            "crossRateUSD": 1.4686,
            "crossRateOther": null
        },
        {
            "attributes": {
                "crossOrder": "2",
                "kod": "DKK",
                "currencyCode": "DKK"
            },
            "unit": 1,
            "isim": "DANİMARKA KRONU",
            "currencyName": "DANISH KRONE",
            "forexBuying": 0.84555,
            "forexSelling": 0.84971,
            "banknoteBuying": 0.84496,
            "banknoteSelling": 0.85166,
            "crossRateUSD": 6.7487,
            "crossRateOther": null
        },
        {
            "attributes": {
                "crossOrder": "9",
                "kod": "EUR",
                "currencyCode": "EUR"
            },
            "unit": 1,
            "isim": "EURO",
            "currencyName": "EURO",
            "forexBuying": 6.3279,
            "forexSelling": 6.3393,
            "banknoteBuying": 6.3234,
            "banknoteSelling": 6.3488,
            "crossRateUSD": null,
            "crossRateOther": 1.1072
        },
        .
        .
        .
    ]
}
Example of a Single Exchange Rate
{
  "date": "19/11/2019",
  "currency": {
    "attributes": {
      "crossOrder": "0",
      "kod": "USD",
      "currencyCode": "USD"
    },
    "unit": 1,
    "isim": "ABD DOLARI",
    "currencyName": "US DOLLAR",
    "forexBuying": 5.7153,
    "forexSelling": 5.7256,
    "banknoteBuying": 5.7113,
    "banknoteSelling": 5.7342,
    "crossRateUSD": null,
    "crossRateOther": null
  }
}

Supported Currencies

| Code | Name | | ---- | --------------------------- | | USD | US DOLLAR | | AUD | AUSTRALIAN DOLLAR | | DKK | DANISH KRONE | | EUR | EURO | | GBP | POUND STERLING | | CHF | SWISS FRANK | | SEK | SWEDISH KRONA | | CAD | CANADIAN DOLLAR | | KWD | KUWAITI DINAR | | NOK | NORWEGIAN KRONE | | SAR | SAUDI RIYAL | | JPY | JAPENESE YEN | | BGN | BULGARIAN LEV | | RON | NEW LEU | | RUB | RUSSIAN ROUBLE | | IRR | IRANIAN RIAL | | CNY | CHINESE RENMINBI | | PKR | PAKISTANI RUPEE | | QAR | QATARI RIAL | | XDR | SPECIAL DRAWING RIGHT (SDR) |

License

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