[Bitcoin] get Crypto Currencies

[Bitcoin] get Crypto Currencies

  
Forge Component
(2)
Published on 2017-10-14 by Andre Silva
2 votes
Published on 2017-10-14 by Andre Silva

Do you know of a way that I can pull or feed cryto currency rates into an OutSystems app?  I would leiek to build an app to track my currencies with at least daily rates.  Looking to track BTC, LTC, ETH, XRF, IOTA. some of teh more popular ones. 

Your post is under the Bitcoin forge component... but this suggestion has nothing to do with the component.

As crypto currencies have gone nuts... so have the api's that have sprung up to support them... there are a bucket of them.  Some you must register for... some won't let you because they're too full... some are overrun and are promising upgrades... it's all the usual nonsense.

I believe the Bitcoin forge component is for Web, but this solution will work Mobile and Web.  Here it is for Mobile because Mobile and Javascript are so easy to work with.

Here I've asked for the prices for BTC and LTC.  JSON is returned, which I stringified and pushed into a local variable.


The code for this uses Javascript Fetch... which is delightful... and uses Promises.  This code goes into a Javascript Widget, within a Client Action... which is called from a button.

Let me know if you want to see it for web.  It'll be much the same, but web is more finicky to work with regarding Javascript.

debugger;
var stockURL = "https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=BTC,LTC"

fetch(stockURL)
.then(function(response) {
if (response.status !== 200) {
console.log('Looks like there was a problem. Status Code: ' +
response.status);
return;
}

// Examine the text in the response
     
response.json().then(function(data) {
    debugger;
//console.log(data);
var strData = JSON.stringify(data);
$parameters.CryptoJSONData = strData;
$resolve();
});
})
.catch(function(err) {
console.log('Fetch Error :-S', err);
});


Thank you for your quick response. I'll try this code.  if you do not mind posting a web version, that would be helpful too. 

I did not mean to post it under the forge component. Thanks for that correction. 


If you have the OML and could post it that will save some headaches of making sure I get the code in the correct places. 


Thank you again. 

Try this.  Web is not fun to work with Javascript... not like Mobile.

The HomePage Screen has the Javascript function which calls the Crypto api.

Once the api has the data, set the value of an Input Widget.

The button Extended Properties onclick event calls the Javascript function, passing in the Id of the Input Widget.

Thank you. This is very helpful. 

Solution

Here's another sample oml using OutSystems REST Consume API.


Solution

Davidk wrote:

Here's another sample oml using OutSystems REST Consume API.



Today I found a rest Api that returns json I  built a test app that retrieves the prices.    I'll look at your second oml.  Thanks for the ideas.