Bitcoin Forum
June 22, 2024, 05:52:25 PM *
News: Voting for pizza day contest
 
   Home   Help Search Login Register More  
Warning: One or more bitcointalk.org users have reported that they strongly believe that the creator of this topic is a scammer. (Login to see the detailed trust ratings.) While the bitcointalk.org administration does not verify such claims, you should proceed with extreme caution.
Pages: [1]
  Print  
Author Topic: Open Source code to request crypto exchange data?  (Read 158 times)
sheld0n (OP)
Sr. Member
****
Offline Offline

Activity: 322
Merit: 250



View Profile
November 17, 2017, 03:21:19 PM
Last edit: November 17, 2017, 08:12:40 PM by sheld0n
 #1

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.
sleepyminer
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
November 17, 2017, 03:53:51 PM
 #2

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:
<?php

$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.

bL4nkcode
Copper Member
Legendary
*
Offline Offline

Activity: 2142
Merit: 1305


Limited in number. Limitless in potential.


View Profile
November 17, 2017, 03:56:43 PM
 #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.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!