NetSuite: Bitcoin Price Index Portlet

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>`
	}


}

About Me

Hello, I’m Tim Dietrich. I design and build custom software for businesses running on NetSuite — from mobile apps and Web portals to Web APIs and integrations.

I’ve created several widely used open-source solutions for the NetSuite community, including the SuiteQL Query Tool and SuiteAPI, which help developers and businesses get more out of their systems.

I’m also the founder of SuiteStep, a NetSuite development studio focused on pushing the boundaries of what’s possible on the platform. Through SuiteStep, I deliver custom software and AI-driven solutions that make NetSuite more powerful, accessible, and future-ready.

Copyright © 2025 Tim Dietrich.