Published on August 8, 2021.
One of my NetSuite clients is in the process of accepting cryptocurrencies as a payment method. While doing research for the project, I stumbled upon a simple API offered by CoinDesk that provides access to its Bitcoin Price Index (XBP) data. You can read more about the XBP and the API here: https://www.coindesk.com/coindesk-api
It occurred to me that I could use the API to display the latest Bitcoin Price Index value as part of a custom SuiteScript Portlet. It turned out to be a very simple script, consisting of a single HTTPS GET request and some HTML code to display the price and a timestamp.
Here's a screenshot showing the portlet on a NetSuite dashboard.
If you're interested in the script, the code is included below, and the script can be downloaded here.
I hope you find the portlet to be helpful.
bitcoin-price-index-current.v202101.portlet.js/** * @NApiVersion 2.1 * @NScriptType Portlet * @NModuleScope SameAccount */ /* ------------------------------------------------------------------------------------------ Script Information ------------------------------------------------------------------------------------------ Name: Bitcoin Price Index Live ID: _bitcoin_live Description: A portlet that can be used to display the current Bitcoin price, calculated every minute, and pulled from CoinDesk's Bitcoin Price Index (XBP). CoinDesk's Bitcoin Price Index represents an average of bitcoin prices across leading global exchanges that meet criteria specified by the XBP. For more information, see: https://www.coindesk.com/price/bitcoin Portlet Type: Inline HTML ------------------------------------------------------------------------------------------ Developer(s) ------------------------------------------------------------------------------------------ TD: • Tim Dietrich • timdietrich@me.com ------------------------------------------------------------------------------------------ History ------------------------------------------------------------------------------------------ 20210808 - TD Initial version. */ var https; define( [ 'N/https' ], main ); function main( httpsModule ) { https = httpsModule; return { render: renderContent } } function renderContent( params ) { params.portlet.title = 'Bitcoin Price Index'; var response = https.get( { url: 'https://api.coindesk.com/v1/bpi/currentprice/usd.json' } ); if ( response.code == 200 ) { response = JSON.parse( response.body ); params.portlet.html = ` <p style="margin-bottom: 12px;"> Price<br> <span style="font-weight: bold;">\$${response.bpi.USD.rate} USD</span> </p> <p style="margin-bottom: 12px;"> Updated<br> <span style="font-weight: bold;">${response.time.updated}</span> </p> <p style="margin-bottom: 12px;"> Powered by <a href="https://www.coindesk.com/price/bitcoin" target="_coindesk">CoinDesk</a>. </p> `; } else { params.portlet.html = `<p style="color: red;">Not available.</p>` } }
Hello, I'm Tim Dietrich. I develop custom software for businesses that are running on NetSuite, including mobile apps, Web portals, Web APIs, and more.
I'm the developer of several popular NetSuite open source solutions, including the SuiteQL Query Tool, SuiteAPI, and more.
I founded SuiteStep, a NetSuite development studio, to provide custom software and AI solutions - and continue pushing the boundaries of what's possible on the NetSuite platform.
Copyright © 2025 Tim Dietrich.