In this article I will integrate live cryptocurrency prices in Salesforce developer instance, so let’s get started !
I created a free account on CoinMarketCap to get an API key.
Complete documentation on how to use this api is provided here
I am using the latest listings api to get the prices.
URL
https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest
{
"data": [{
"name": "Bitcoin",
"symbol": "BTC",
"quote": {
"USD": {
"price": 9283.92,
"percent_change_24h": 0.518894
}
}
}]
}
Create a Free Salesforce Developer account.
Create new Remote Site Settings entry for CoinMarketCap site url.
Code to create the lightning web component
- The html is used to show the table with cryptocurrency prices.
- The javascript file is used to call the Apex class and store the prices for the view.
- The Apex class calls the CoinMarketCap to get the latest prices.
Deploy the code in your Salesforce Instance.
Please refer Create a Hello World Lightning Web Component trailhead for more details on how to write code and deploy it to Salesforce instance.
Let’s add our LWC component to the Contact Page.
Go to an existing contact record and Click Edit Page on the top right.
Drag the custom component to the layout above Activity section.
Save and Activate.
And all set, we have the Crypto Currency Live Prices in Salesforce !
Refresh the contact record page to get updated prices.
The code can be optimized for better performance. Github link to the repository in case you would like to reuse or contribute.
Thanks for reading !
Blog - https://tejasbal.in/
Medium - https://medium.com/@tejas.bal
Top comments (0)