Bitcoin Forum

Economy => Trading Discussion => Topic started by: bram_vnl on March 14, 2016, 02:33:04 PM



Title: Good start api script exchanges
Post by: bram_vnl on March 14, 2016, 02:33:04 PM
Where is a good start to make price scripts from exchanges for my website?

I want to understand API exchange


Title: Re: Good start api script exchanges
Post by: pooya87 on March 15, 2016, 07:40:28 AM
Where is a good start to make price scripts from exchanges for my website?

do you want to add like a price indicator to your website or option to buy and sell through exchanger's API

i am not an expert but for the first you can add a price widget (http://www.coindesk.com/price/bitcoin-price-ticker-widget/) to your site like this:
Code:
<div id="coindesk-widget"></div>
<script type="text/javascript" src="//widget.coindesk.com/bpiticker/coindesk-widget.min.js?509e9d"></script>

Quote
I want to understand API exchange

API exchange is basically sending an http request to the exchanger with what you want to do and signing it with your API secret key for security.
and example:
{APIRequestURI}/createorder&MarketName=BTC_USD&Amount=1&type=sell&price=420

then sign this with API secret and send it via POST method and receive the JSON response.


Title: Re: Good start api script exchanges
Post by: mocacinno on March 15, 2016, 07:48:59 AM
I can probably write a couple price widgets for you, so you can use them directly onto your site, and learn from the samples?
PM me for a quote if you're interested!


Title: Re: Good start api script exchanges
Post by: bram_vnl on March 15, 2016, 08:09:32 AM
I can probably write a couple price widgets for you, so you can use them directly onto your site, and learn from the samples?
PM me for a quote if you're interested!

I have send you a PM


Title: Re: Good start api script exchanges
Post by: bram_vnl on March 15, 2016, 08:11:55 AM
Where is a good start to make price scripts from exchanges for my website?

do you want to add like a price indicator to your website or option to buy and sell through exchanger's API

i am not an expert but for the first you can add a price widget (http://www.coindesk.com/price/bitcoin-price-ticker-widget/) to your site like this:
Code:
<div id="coindesk-widget"></div>
<script type="text/javascript" src="//widget.coindesk.com/bpiticker/coindesk-widget.min.js?509e9d"></script>

Quote
I want to understand API exchange

API exchange is basically sending an http request to the exchanger with what you want to do and signing it with your API secret key for security.
and example:
{APIRequestURI}/createorder&MarketName=BTC_USD&Amount=1&type=sell&price=420

then sign this with API secret and send it via POST method and receive the JSON response.

Thx for that, but I want host the script on my website not from other websites


Title: Re: Good start api script exchanges
Post by: bram_vnl on March 15, 2016, 02:25:50 PM
Thanks for the help from @mocacinno

But I have a question from bittrex api, I have this code

Code:
<?php
$url 
'https://bittrex.com/api/v1.1/public/getmarketsummary?market=btc-nlg';
$response file_get_contents($url);
$obj json_decode($response,true);
echo 
'&#579; '$obj['result'][0]['Ask'] . '
'
;
?>

My question, the code show
Bittrex Ƀ 4.74E-6 and I want something like this Bittrex Ƀ 0.00000474


Title: Re: Good start api script exchanges
Post by: pooya87 on March 16, 2016, 03:36:24 AM
~~
Bittrex Ƀ 4.74E-6 and I want something like this Bittrex Ƀ 0.00000474


they are both the same 4.74E-6 is the scientific method of showing the number.
by the time of displaying the result in your output you have to just change the "format".

most of the time i do this in c#
Code:
txtOutput.Text = string.Format("{0:0.00000000}",4.74E-6);

i don't know about PHP, so google can help you better:
http://stackoverflow.com/questions/1471674/why-is-php-printing-my-number-in-scientific-notation-when-i-specified-it-as-00
http://stackoverflow.com/questions/10916675/display-float-value-w-o-scientific-notation


Title: Re: Good start api script exchanges
Post by: mocacinno on March 16, 2016, 08:15:10 AM
As pooya87 said, sprintf would be the best way to do this.
I actually didn't think of this, and advised Bram_vnl to explode the string on "E-", and divide the first ellement of the return array by 10 to the power of [second ellement of the returnarray], but sprintf would be a much better idear  :)


Title: Re: Good start api script exchanges
Post by: bram_vnl on March 16, 2016, 09:50:07 AM
I have change

Code:
$obj = json_decode($response, true);
echo 'Ƀ '. $obj['result'][0]['Last'] . '<br>';

to

Code:
$obj = json_decode($response,true);
echo number_format($obj['result'][0]['Last'], 8);

That works  8)

http://s28.postimg.org/vg40tqh8t/price.png
http://www.guldenpagina.nl (http://www.guldenpagina.nl)


Title: Re: Good start api script exchanges
Post by: bram_vnl on March 16, 2016, 01:20:47 PM
The last thing I need the php script's for yobit alcurex safecex


Title: Re: Good start api script exchanges
Post by: pooya87 on March 17, 2016, 04:39:40 AM
https://yobit.net/api/3/ticker/nlg_btc
since this doesn't have the json_decode($response,true) part you can check for response success some other way (optional)
change the obj to this:
Code:
$obj['nlg_btc']['Last']
the difference here is that the response is not an array. you just have to give the keys to json to reach what you want.

i haven't heard about the other two exchangers :)

edit:
https://alcurex.org/api/market.php?pair=NLG_btc&last=last
Code:
$obj['nlg_btc']['price']

https://safecex.com/api/getmarket?market=NLG/BTC
Code:
$obj['last']

you might wanna check with mocacinno that knows PHP


Title: Re: Good start api script exchanges
Post by: Patatas on March 17, 2016, 04:50:58 AM
Have a look at this newly created exchange's API https://gatecoin.com/api very well structured and easy to understand.Not only for trades but they provide customer ticker's like Market analysis and Depth.Request header's are easier to create as well :
Code:
              jqXHR.setRequestHeader("API_PUBLIC_KEY", publicKey);
                            jqXHR.setRequestHeader("API_REQUEST_SIGNATURE", hashInBase64);
                            jqXHR.setRequestHeader("API_REQUEST_DATE", now);
                       

Not sure what exactly you're looking for but this one should serve all the custom needs.


Title: Re: Good start api script exchanges
Post by: bram_vnl on March 17, 2016, 09:39:35 AM
https://yobit.net/api/3/ticker/nlg_btc
since this doesn't have the json_decode($response,true) part you can check for response success some other way (optional)
change the obj to this:
Code:
$obj['nlg_btc']['Last']
the difference here is that the response is not an array. you just have to give the keys to json to reach what you want.

i haven't heard about the other two exchangers :)

edit:
https://alcurex.org/api/market.php?pair=NLG_btc&last=last
Code:
$obj['nlg_btc']['price']

https://safecex.com/api/getmarket?market=NLG/BTC
Code:
$obj['last']

you might wanna check with mocacinno that knows PHP

I got Safecex working, I will look the last 2 Alcurex and Yobit


Title: Re: Good start api script exchanges
Post by: bram_vnl on March 18, 2016, 11:06:45 AM
@mocacinno I have send you a pm


Title: Re: Good start api script exchanges
Post by: mocacinno on March 18, 2016, 11:18:39 AM
@mocacinno I have send you a pm


I've seen it, i'm on the road ATM, so it's kinda hard to test out code. I'll see if i can give you a solution this weekend ;)


Title: Re: Good start api script exchanges
Post by: bram_vnl on March 18, 2016, 12:42:46 PM
@mocacinno I have send you a pm


I've seen it, i'm on the road ATM, so it's kinda hard to test out code. I'll see if i can give you a solution this weekend ;)

thats oke!  :)


Title: Re: Good start api script exchanges
Post by: bram_vnl on March 26, 2016, 11:21:47 AM
Thx for the scripts!