php - Bittrex Public API Confusion -


i complete newbie here apologies if asking stupid question. trying extract data bittrex's public api, "https://bittrex.com/api/v1.1/public/getmarkets".

i have had success obtaining data other apis doing this, prints out top 20 coins:

$coinmarket = "https://api.coinmarketcap.com/v1/ticker/?limit=20"; $marketdata = json_decode(file_get_contents($coinmarket), true);  for($i=0;$i<20;$i++){     $coins = $marketdata[$i]["symbol"];     print_r($coins); }  

when try same thing bittrex api listed above, following repeated 20 times (with offset number incremented 1 each time):

notice: undefined offset: 0 in d:\xampp\htdocs\bittrexbot.php on line 37

i've looked @ 2 api calls return, , although similar, bittrex data contains initial information may culprit (this first coin retrieved):

bittrex:

array (      [success] => 1 [message] => [result] => array          (              [0] => array ( [marketname] => bitcny-btc [high] => 30998.99999966 [low] => 27727.54234112 [volume] => 4.32110365 [last] => 28007.61852638 [basevolume] => 127223.448106 [timestamp] => 2017-08-15t12:03:57.393 [bid] => 27450.26691772 [ask] => 28290.52376401 [openbuyorders] => 186 [opensellorders] => 47 [prevday] => 28853.26999991 [created] => 2015-12-11t06:31:40.653         ) 

coinmarketcap:

array          (              [0] => array ( [id] => bitcoin [name] => bitcoin [symbol] => btc [rank] => 1 [price_usd] => 4129.24 [price_btc] => 1.0 [24h_volume_usd] => 2984050000.0 [market_cap_usd] => 68165233778.0 [available_supply] => 16507937.0 [total_supply] => 16507937.0 [percent_change_1h] => 0.32 [percent_change_24h] => -1.73 [percent_change_7d] => 20.58 [last_updated] => 1502800149          ) 

is array ( [success] => 1 [message] => [result] => @ start of returned data bittrex issue? or unrelated returned data , rather how handling it?

for reference code attempt use when accessing bittrex api follows:

$coinmarket = "https://bittrex.com/api/v1.1/public/getmarketsummaries"; $marketdata = json_decode(file_get_contents($coinmarket), true);  for($i=0;$i<20;$i++){     $coins = $marketdata[$i]["marketname"];     print_r($coins); } 

any assistance or point in right direction appreciated!

thanks.

to access data within response might @ this:

$url='https://bittrex.com/api/v1.1/public/getmarkets'; $data=file_get_contents( $url ); $json=json_decode( $data );  $result=$json->result; foreach( $result $i => $obj ){     echo $obj->marketname,'<br />'; } 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -