Author

Topic: Open Source code to request crypto exchange data? (Read 168 times)

copper member
Activity: 2142
Merit: 1305
Limited in number. Limitless in potential.
November 17, 2017, 10:56:43 AM
#3
Maybe your referring like coinmarket's and cryptonator api for some cryptocurrency's price and coins volume or some rates from different exchanges.
Link
Cryptonator: https://www.cryptonator.com/api
Coinmarketcap: https://coinmarketcap.com/api/

Just correct me if I understand it mistakenly.
newbie
Activity: 2
Merit: 0
No sure if it is the right place to ask. I want to ask if somebody know if there is an open source project or code snippet which let you integrate exchange prices (at least the bigger ones like Bittrex or Poloniex) into a web site, preferably coded in PHP or NodeJS? I mean something like a wrapper thats lets you request data from diverse exchange APIs easily.


All exchanges usually have a public API, I dont know if there are any wrappers available as the data is pretty easy to access as it is.

PHP for bittrex, they obviously have more markets than BTC-LTC, They have another rest where you can see the markets. https://bittrex.com/home/api
This is just an example by the way, I would suggest using CURL in php instead of file_get_contents
Code:

$oBittrexObj 
json_decode(file_get_contents("https://bittrex.com/api/v1.1/public/getticker?market=BTC-LTC"), 1);

echo 
number_format($oBittrexObj['result']['Last'], 8);

Node using node-rest-client lib which you can install from npm
Code:
var Client = require('node-rest-client').Client;
var client = new Client();

var args = {
    headers: { "Content-Type": "application/json"}
};

client.get("https://bittrex.com/api/v1.1/public/getticker?market=BTC-LTC", args, function (data, response) {
   console.log(data.result.Last);
});

Also some other things to take into account. Storage for the last value, Its not always a good idea to get the data directly from the website as it may be unavailable and it uses un-needed requests. A good practice is to store the data in a db and fetch every 30 seconds or minute. If the api is unavailable at least you can still show the data from the db until the api is reachable again.

sr. member
Activity: 322
Merit: 250
Not sure if it is the right place to ask. I want to ask if somebody know if there is an open source project or code snippet which let you integrate exchange prices (at least the bigger ones like Bittrex or Poloniex) into a web site, preferably coded in PHP or NodeJS? I mean something like a wrapper thats lets you request data from diverse exchange APIs easily.
Jump to: