Bitcoin Forum
June 24, 2024, 07:54:04 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Economy / Service Discussion / Re: Open Source code to request crypto exchange data? on: November 17, 2017, 03:53:51 PM
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.

2  Economy / Service Announcements / Re: [ANN] ✓✓✓ The Most Secure Model of BitCoin Mixer - BitMix.Biz ✓✓✓ on: November 17, 2017, 03:18:29 PM
I like the idea of telegram bot. I think I will use.
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!