Skip to content

Commit

Permalink
Add support for home directory config file (dmzoneill)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Eyrick authored Mar 12, 2018
1 parent 0935b88 commit e510760
Showing 1 changed file with 46 additions and 42 deletions.
88 changes: 46 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,38 +39,6 @@ require 'vendor/autoload.php';
$api = new Binance\API("<api key>","<secret>");
```

#### Getting started with proxy
```php
require 'vendor/autoload.php';

$proxyConf = [
'proto' => 'tcp',
'address' => '192.168.1.1',
'port' => '8080',
'user' => 'dude',
'pass' => 'd00d'
];

$api = new Binance\API("<api key>","<secret>", ['useServerTime'=>false], $proxyConf);
```

#### Config file in home directory
If you dont wish to store your API key and secret in your scripts, load it from your home directory
```bash
mkdir -vp ~/.config/jaggedsoft/
cat > ~/.config/jaggedsoft/php-binance-api.json << EOF
{
"api-key": "<api key>",
"api-secret": "<secret>"
}
EOF
```

Leave these variables blank in the constructor
```php
$api = new Binance\API("", "", ['useServerTime'=>false], $proxyConf);
```

#### Get latest price of a symbol
```php
$ticker = $api->prices();
Expand Down Expand Up @@ -1248,6 +1216,52 @@ $depositHistory = $api->depositHistory();
print_r($depositHistory);
```


### Advanced Examples

#### Basic stats: Get api call counter
```php
$api->getRequestCount();
```

#### Basic stats: Get total data transferred
```php
$api->getTransfered();
```

#### Proxy configuration
```php
require 'vendor/autoload.php';

$proxyConf = [
'proto' => 'tcp',
'address' => '192.168.1.1',
'port' => '8080',
'user' => 'dude',
'pass' => 'd00d'
];

$api = new Binance\API("<api key>","<secret>", ['useServerTime'=>false], $proxyConf);
```

#### Config file in home directory
If you dont wish to store your API key and secret in your scripts, load it from your home directory
```bash
mkdir -vp ~/.config/jaggedsoft/
cat > ~/.config/jaggedsoft/php-binance-api.json << EOF
{
"api-key": "<api key>",
"api-secret": "<secret>"
}
EOF
```

Then leave these variables blank in the constructor
```php
$api = new Binance\API("", "", ['useServerTime'=>false], $proxyConf);
```


### Troubleshooting
If you get the following errors, please synchronize your system time.
```
Expand All @@ -1265,13 +1279,3 @@ $api = new Binance\API("<key>", "<secret>", ['useServerTime'=>true]);
//Call this before running any functions
$api->useServerTime();
```

#### Basic stats: Get api call counter
```php
$api->getRequestCount();
```

#### Basic stats: Get total data transfered
```php
$api->getTransfered();
```

0 comments on commit e510760

Please sign in to comment.