crypto-price-converter
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

Crypto Price Converter Library

The Crypto Price Converter library allows developers to easily convert between cryptocurrency and traditional currency values. It leverages the CryptoConverter API for accurate and up-to-date conversion rates.

Installation

npm install crypto-price-converter

Usage

Initialize the library with your CryptoConverter API:

const { CryptoConverterAPI } = require("crypto-price-converter");

const converter = new CryptoConverterAPI();

Convert token quantity to currency

const { CryptoConverterAPI } = require("crypto-price-converter");

const converter = new CryptoConverterAPI()

converter.ConvertToCrypto({ symbol: "Bitcoin", amount: 1, currency: "USD" })

Output:

{ amount: 43149, currency: 'USD', symbol: 'Bitcoin' }

Convert your currency amount to crypto value

const { CryptoConverterAPI } = require("crypto-price-converter");

const converter = new CryptoConverterAPI()

converter.ConvertToCurrency({ symbol: "Bitcoin", amount: 1, currency: "USD" })

Output:

{ amount: 0.0000231755081230156, currency: 'USD', symbol: 'Bitcoin' }

CommonJs and ESModules Support

const { CryptoConverterAPI } = require("crypto-price-converter");
import { CryptoConverterAPI } from "crypto-price-converter"

Error handling

API requests can potentially return errors due to invalid inputs or other issues. These errors can be handled with a try...catch statement, and the error details can be found in either error.response or error.message:

Package Sidebar

Install

npm i crypto-price-converter

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

18.6 kB

Total Files

11

Last publish

Collaborators

  • miguelo981