Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update BinanceAPI Constructor and add API calls #3

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

hotsaucejake
Copy link

Setup the __construct() so that you can call BinanceAPI outside of the alias/facade. Similar to what you have setup on your laravel-bittrex package

function __construct(array $auth = null, array $urls = null, array $settings = null)
    {
        if(!$auth)      $auth       = config("binance.auth");
        if(!$urls)      $urls       = config("binance.urls");
        if(!$settings)  $settings   = config("binance.settings");

        $this->key    = array_get($auth, 'key');
        $this->secret = array_get($auth, 'secret');

        $this->url        = array_get($urls, 'api');
        $this->wapi_url   = array_get($urls, 'wapi');

        $this->recvWindow = array_get($settings, 'timing');
        $this->curl       = curl_init();

        $curl_options     = [
            CURLOPT_SSL_VERIFYPEER => array_get($settings, 'ssl'),
            CURLOPT_SSL_VERIFYHOST => 2,
            CURLOPT_USERAGENT      => 'Binance PHP API Agent',
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_CONNECTTIMEOUT => 20,
            CURLOPT_TIMEOUT => 300
        ];

        curl_setopt_array($this->curl, $curl_options);

    }

I added more public API calls based on these docs: https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md

Interestingly enough, v1/ticker/allPrices isn't mentioned ANYWHERE but it is a valid call with your getTickers() method.

New methods include:

  • getServerTime
  • getExchangeInfo
  • getOrderBook
  • getPublicTrades
  • getAggTrades
  • getCandlesticks
  • getAvgPrice
  • getTickerChange
  • getTickerPrice
  • getBookTicker

I removed getTicker() because it returned the exact same information as getTickers(). I also removed getCurrencies() because there was no need for it.

- Reason(s):

- Change(s):

- Reference(s):
… server time.

- Reason(s):

- Change(s):

- Reference(s):
- Reason(s):

- Change(s):

- Reference(s):
- Reason(s):

- Change(s):

- Reference(s):
- Reason(s):

- Change(s):

- Reference(s):
- Reason(s):

- Change(s):

- Reference(s):
- Reason(s):

- Change(s):

- Reference(s):
- Reason(s):

- Change(s):

- Reference(s):
- Reason(s):

- Change(s):

- Reference(s):
- Reason(s):

- Change(s):

- Reference(s):
- Reason(s):

- Change(s):

- Reference(s):
- Reason(s):

- Change(s):

- Reference(s):
@adman9000
Copy link
Owner

Only issue with removing functions is I'm trying to be consistent with the other exchange APIs as I have a 'cryptoexchange' wrapper package which utilises the bittrex, binance, cryptopia & kraken API packages I've written. The aim was to provide consistent functions & return values to make it easy to switch between exchanges within the code.

@hotsaucejake
Copy link
Author

Hmm... I'll update it with the removed methods for backwards compatibility. Probably won't be able to get to it until tomorrow though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants