Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
crypto-convert
Advanced tools
Convert crypto to fiat and vice-versa instantly.
Free public API
https://api.coinconvert.net/convert/btc/usd?amount=1
npm i crypto-convert
import CryptoConvert from 'crypto-convert';
Or with require
, import it like this to get TypeScript:
const CryptoConvert = require("crypto-convert").default;
<script src='https://coinconvert.net/assets/js/crypto-convert.min.js'></script>
const convert = new CryptoConvert(/*options?*/);
(async function(){
await convert.ready(); //Wait for the initial cache to load
convert.BTC.USD(1);
convert.ETH.JPY(255);
convert.LINK.LTC(5);
convert.USD.CRO(100.1256);
//... convert any pair
// prices are automatically updated on background
})();
Note
: You should only initialize the CryptoConvert class once. It's recommend to make a seperate file for it.
Here are some of the options you can specify on initialization:
new CryptoConvert({
cryptoInterval: 5000, //Crypto prices update interval in ms (default 5 seconds on Node.js & 15 seconds on Browsers)
fiatInterval: (60 * 1e3 * 60), //Fiat prices update interval (default every 1 hour)
calculateAverage: true, //Calculate the average crypto price from exchanges
binance: true, //Use binance rates
bitfinex: true, //Use bitfinex rates
coinbase: true, //Use coinbase rates
kraken: true, //Use kraken rates
onUpdate: (tickers, isFiatUpdate?)=> any //Callback on every crypto update
HTTPAgent: null //HTTP Agent for server-side proxies (Node.js only)
});
Get crypto prices last updated timestamp (ms)
console.log(convert.lastUpdated)
// Prints:
// 1664657163857
Get the list supported currencies
console.log(convert.list);
// Prints:
// {
// crypto: ['BTC','ETH', ... + 148 more],
// fiats: ['USD', 'EUR', ... + 25 more]
// }
Get cryptocurrencies metadata (title/symbol/logo/rank)
console.log(convert.cryptoInfo);
// Prints:
// {
// BTC: {
// "id": 1,
// "title": "Bitcoin",
// "symbol": "BTC",
// "logo": "[logo_url]",
// "rank": 1
// }
// ETH: {
// ...
// }
// ... +148 more
// }
In cases when you want to support a custom currency you can do so like this:
convert.addCurrency(
'ANYCURRENCY', //Your custom currency symbol here
'USD', //The quote fiat price. Must be a supported fiat currency.
async ()=>{
//...call your api here
return price;
},
5000 //Update interval in ms
);
Adding custom plugins is useful for supporting more fiats, precious metals, or anything that can be exchanged.
For removing custom currencies:
convert.removeCurrency('ANYCURRENCY');
FAQs
Convert crypto to fiat and vice-versa instantly.
The npm package crypto-convert receives a total of 228 weekly downloads. As such, crypto-convert popularity was classified as not popular.
We found that crypto-convert demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.