Bitcoin Forum
May 05, 2024, 06:01:37 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 [2]  All
  Print  
Author Topic: A little help with API's please  (Read 2693 times)
nemgun
Hero Member
*****
Offline Offline

Activity: 882
Merit: 533



View Profile WWW
February 27, 2017, 03:04:15 PM
Last edit: February 27, 2017, 03:14:48 PM by nemgun
 #21

You should create classes like here: https://github.com/nemgun32/Exchange-API-Tutorial
And use them to query the prices, then you can easily querry annother API as the first one is contained inside the object.
Use the nova library, you will get all the informations you need, except private API.

In your case it is :

Code:
<?php
include('nova.php');

// First init the class
$nova = new nova();

//Now select the pairs you want
$pair = array('BTC_XRBC''BTC_POSIV');
$info $nova->getTickerData($pair);

var_dump($info); //you will have an idea of the data there

// Table now
echo '<table><tbody><tr>';
foreach (
$info[0][0] as $key => $value) {
echo '<th>'$key '</th>';
}
echo 
'</tr>';

// Note that it is possible to change the returned responce from getTickerData to form a nice Array with clear data, but it is not the aim of the repo
for ($i=0$i count($info) ; $i++) { 
echo '<tr>';
for ($e=0$e count($info[$i]); $e++) { 
foreach ($info[$i][$e] as $key => $value) {
echo '<td>' $value '</td>';
}
}
echo '</tr>';
}
echo 
'</tbody></table>';


?>
1714888897
Hero Member
*
Offline Offline

Posts: 1714888897

View Profile Personal Message (Offline)

Ignore
1714888897
Reply with quote  #2

1714888897
Report to moderator
Every time a block is mined, a certain amount of BTC (called the subsidy) is created out of thin air and given to the miner. The subsidy halves every four years and will reach 0 in about 130 years.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714888897
Hero Member
*
Offline Offline

Posts: 1714888897

View Profile Personal Message (Offline)

Ignore
1714888897
Reply with quote  #2

1714888897
Report to moderator
1714888897
Hero Member
*
Offline Offline

Posts: 1714888897

View Profile Personal Message (Offline)

Ignore
1714888897
Reply with quote  #2

1714888897
Report to moderator
1714888897
Hero Member
*
Offline Offline

Posts: 1714888897

View Profile Personal Message (Offline)

Ignore
1714888897
Reply with quote  #2

1714888897
Report to moderator
freemanjackal
Sr. Member
****
Offline Offline

Activity: 378
Merit: 250


View Profile
February 28, 2017, 01:10:09 AM
 #22

i guess you are learning php programming, you should learn to differ array from object and how to access them, php doc will be very usefull, you should have it on  hand
nemgun
Hero Member
*****
Offline Offline

Activity: 882
Merit: 533



View Profile WWW
February 28, 2017, 07:51:35 AM
 #23

i guess you are learning php programming, you should learn to differ array from object and how to access them, php doc will be very usefull, you should have it on  hand
Yes, but it is easy to have detailled informations about the variables we use, var_dump(expression) is made for that, it gives the whole structure of the expression (can be a variable, but can be something else) with the type of each compenent, i use to debug using it.
So if you put var_dump each time you have a problem with a variable, you will know if it is an array, object, string, bool ...
Then you can easily walk into it. The previous example was to help you figure out how many types of variables you are crossing, but the class i sent you will directly return the required data.
BitQuark
Hero Member
*****
Offline Offline

Activity: 716
Merit: 501



View Profile WWW
May 29, 2017, 05:07:53 AM
 #24

This is one I have working from coinmarketcap.com API request.

status.php
Code:
<?php

$ch 
curl_init();
curl_setopt($ch,CURLOPT_URL,'https://api.coinmarketcap.com/v1/ticker/bitquark/');
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,10);
curl_setopt($ch,CURLOPT_TIMEOUT,10);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);

$result curl_exec($ch);
curl_close($ch);
$data json_decode($result,true);

$name $data[0]['name'];
$symbol $data[0]['symbol'];
$rank number_format($data[0]['rank']);
$priceBTC number_format($data[0]['price_btc'], 8);
$priceUSD number_format($data[0]['price_usd'], 4);
$dayVolume number_format($data[0]['24h_volume_usd'], 2);
$marketCap number_format($data[0]['market_cap_usd'], 2);
$totalSupply number_format($data[0]['total_supply'], 2);
$percentChange1Hr number_format($data[0]['percent_change_1h'], 2);
$percentChange24Hr number_format($data[0]['percent_change_24h'], 2);
$percentChange7Days number_format($data[0]['percent_change_7d'], 2);
$lastUpdated $data[0]['last_updated'];


?>

<b>Name :</b> <?php echo "$name";?>
<br>
<b>Symbol :</b> <?php echo "$symbol";?>
<br>
<b>Ranking :</b> <?php echo "$rank";?>
<br>
<b>Price BTC :</b> <?php echo "$priceBTC";?> BTC
<br>
<b>Price USD :</b> $<?php echo "$priceUSD";?> USD
<br>
<b>24hr Volume :</b> $<?php echo "$dayVolume";?> USD
<br>
<b>Market Cap :</b> $<?php echo "$marketCap";?> USD
<br>
<b>Total Supply :</b> <?php echo "$totalSupply";?> BTQ
<br>
<b>Percent Change 1hr :</b> <?php echo "$percentChange1Hr";?> %
<br>
<b>Percent Change 24hr :</b> <?php echo "$percentChange24Hr";?> %
<br>
<b>Percent Change 7 Days:</b> <?php echo "$percentChange7Days";?> %
<br>
<b>Last Updated :</b> <?php echo date('r'$lastUpdated);?>

pornluver
Hero Member
*****
Offline Offline

Activity: 960
Merit: 514


View Profile
July 14, 2017, 03:57:04 PM
 #25

Can anyone tell me why this doesn't work?

https://novaexchange.com/remote/v2/markets/BTC
pooya87
Legendary
*
Offline Offline

Activity: 3444
Merit: 10546



View Profile
July 16, 2017, 03:56:10 AM
 #26

Can anyone tell me why this doesn't work?

https://novaexchange.com/remote/v2/markets/BTC

because that page does NOT exist! in other words novaexchange has not defined anything in that link. remove the /BTC from the end and it will work, giving you all the markets available then in your code loop through the JSON response and put an if for each of them checking to see if the "basecurrency" is equal to "BTC".

also please don't bump old topics to ask a different question Tongue

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Pages: « 1 [2]  All
  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!