PHP code example of djansen20 / bitstamp-http-api
1. Go to this page and download the library: Download djansen20/bitstamp-http-api library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
djansen20 / bitstamp-http-api example snippets
use Bitstamp\BitstampHttpApi;
use \Bitstamp\Models\CurrencyPair;
$pair = CurrencyPair::BTCUSD;
$api = BitstampHttpApi::PublicApi();
$api = BitstampHttpApi::PublicApi();
$api->getDailyTicker(CurrencyPair::BTCUSD);
object(Bitstamp\PublicApi\Responses\TickerResponse)#68 (9) {
["high"]=>
float(9380)
["last"]=>
float(9260.99)
["timestamp"]=>
int(1518634427)
["bid"]=>
float(9254)
["vwap"]=>
float(8986.35)
["volume"]=>
float(16019.68608281)
["low"]=>
float(8461.38)
["ask"]=>
float(9260.93)
["open"]=>
float(8504.57)
}
$api = BitstampHttpApi::PublicApi();
$api->getHourlyTicker(CurrencyPair::BTCUSD);
object(Bitstamp\PublicApi\Responses\HourlyTickerResponse)#31 (9) {
["high"]=>
float(9380)
["last"]=>
float(9312.73)
["timestamp"]=>
int(1518634624)
["bid"]=>
float(9300.38)
["vwap"]=>
float(9307.18)
["volume"]=>
float(875.26702747)
["low"]=>
float(9230)
["ask"]=>
float(9312.72)
["open"]=>
float(9319.99)
}
$api = BitstampHttpApi::PublicApi();
$api->getOrderBook(CurrencyPair::BTCUSD);
object(Bitstamp\PublicApi\Responses\OrderbookResponse)#48 (3) {
["high"]=>
int(1518634712)
["bids"]=>
array(...)
["asks"]=>
array(...)
}
$api = BitstampHttpApi::PublicApi();
$api->getTransactions(CurrencyPair::BCHEUR, minute);
object(Bitstamp\PublicApi\Responses\TransactionsResponse)#68 (1) {
["transactions"]=>
array(2) {
[0]=>
array(5) {
["date"]=>
string(10) "1518635036"
["tid"]=>
string(8) "54709960"
["price"]=>
string(7) "1080.00"
["type"]=>
string(1) "0"
["amount"]=>
string(10) "0.12830413"
}
[1]=>
array(5) {
["date"]=>
string(10) "1518635033"
["tid"]=>
string(8) "54709957"
["price"]=>
string(7) "1080.00"
["type"]=>
string(1) "0"
["amount"]=>
string(10) "0.01508434"
}
}
}
$api = BitstampHttpApi::PublicApi();
$api->getTradingPairInfo();
object(Bitstamp\PublicApi\Responses\TradingPairsInfoResponse)#31 (1) {
["tradingPairs"]=>
array(15) {
[0]=>
array(7) {
["base_decimals"]=>
int(8)
["minimum_order"]=>
string(7) "5.0 USD"
["name"]=>
string(7) "LTC/USD"
["counter_decimals"]=>
int(2)
["trading"]=>
string(7) "Enabled"
["url_symbol"]=>
string(6) "ltcusd"
["description"]=>
string(22) "Litecoin / U.S. dollar"
}
[1]=>
array(7) {
["base_decimals"]=>
int(8)
["minimum_order"]=>
string(7) "5.0 USD"
["name"]=>
string(7) "ETH/USD"
["counter_decimals"]=>
int(2)
["trading"]=>
string(7) "Enabled"
["url_symbol"]=>
string(6) "ethusd"
["description"]=>
string(19) "Ether / U.S. dollar"
}
...
}
}
$api = BitstampHttpApi::PublicApi();
$api->getEurUsdConversionRate();
object(Bitstamp\PublicApi\Responses\EurUsdConversionRateResponse)#63 (2) {
["buy"]=>
float(1.2369)
["sell"]=>
float(1.2267)
}