Skip to content
This repository was archived by the owner on Dec 1, 2025. It is now read-only.

Commit 119c370

Browse files
committed
Migrated to GuzzleHttp Client
1 parent 3a94ab6 commit 119c370

33 files changed

+709
-885
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
vendor
22
composer.lock
3-
.idea
43
build
5-
phpunit.xml
4+
phpunit.xml
5+
.phpunit.result.cache

.scrutinizer.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
imports:
2+
- php
3+
4+
tools:
5+
external_code_coverage: true

.travis.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
language: php
2+
3+
php:
4+
- '7.2'
5+
- '7.3'
6+
- '7.4'
7+
8+
sudo: false
9+
10+
cache:
11+
directories:
12+
- $HOME/.composer/cache
13+
14+
install:
15+
- travis_retry composer self-update && composer --version
16+
- travis_retry composer update --dev --prefer-dist --no-interaction
17+
18+
before_script:
19+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
20+
- chmod +x ./cc-test-reporter
21+
- ./cc-test-reporter before-build
22+
23+
script:
24+
- composer validate --strict
25+
- vendor/bin/phpunit
26+
27+
after_script:
28+
- if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi
29+
- wget https://scrutinizer-ci.com/ocular.phar
30+
- php ocular.phar code-coverage:upload --format=php-clover ./build/logs/clover.xml
31+
32+
notifications:
33+
email:
34+
recipients:
35+
- codenix.sv@gmail.com
36+
on_success: never
37+
on_failure: always

LICENSE

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
1-
BSD 3-Clause License
1+
MIT License
22

3-
Copyright (c) 2017, Vladymyr Svyryd
4-
All rights reserved.
3+
Copyright (c) 2017 Volodymyr Svyryd
54

6-
Redistribution and use in source and binary forms, with or without
7-
modification, are permitted provided that the following conditions are met:
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
811

9-
* Redistributions of source code must retain the above copyright notice, this
10-
list of conditions and the following disclaimer.
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
1114

12-
* Redistributions in binary form must reproduce the above copyright notice,
13-
this list of conditions and the following disclaimer in the documentation
14-
and/or other materials provided with the distribution.
15-
16-
* Neither the name of the copyright holder nor the names of its
17-
contributors may be used to endorse or promote products derived from
18-
this software without specific prior written permission.
19-
20-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 88 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
# bitfinex-api
2-
A simple PHP wrapper for [Bitfinex API](https://docs.bitfinex.com/docs). [Bitfinex](https://www.bitfinex.com) The world's largest and most advanced cryptocurrency trading platform
2+
[![Build Status](https://travis-ci.com/codenix-sv/bitfinex-api.svg?branch=master)](https://travis-ci.com/codenix-sv/bitfinex-api)
3+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/codenix-sv/bitfinex-api/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/codenix-sv/bitfinex-api/?branch=master)
4+
[![License: MIT](https://img.shields.io/github/license/codenix-sv/bitfinex-api)](https://github.com/codenix-sv/bitfinex-api/blob/master/LICENSE)
5+
[![Packagist](https://img.shields.io/packagist/dt/codenix-sv/bitfinex-api)](https://packagist.org/packages/codenix-sv/bitfinex-api)
6+
7+
A simple PHP wrapper for [Bitfinex API](https://docs.bitfinex.com/docs/rest-general). [Bitfinex](https://www.bitfinex.com) The world's largest and most advanced cryptocurrency trading platform
8+
39
## Requirements
410

5-
- PHP >= 7.1
11+
* PHP >= 7.2
12+
* ext-json
13+
* [Bitfinex](https://www.bitfinex.com), API key and API secret
614

715
## Installation
816

@@ -11,12 +19,12 @@ The preferred way to install this extension is through [composer](http://getcomp
1119
Either run
1220

1321
```bash
14-
$ composer require codenix-sv/bitfinex-api:~0.2
22+
$ composer require codenix-sv/bitfinex-api
1523
```
1624
or add
1725

1826
```json
19-
"codenix-sv/bitfinex-api" : "~0.2"
27+
"codenix-sv/bitfinex-api" : "^1.0"
2028
```
2129

2230
to the require section of your application's `composer.json` file.
@@ -25,46 +33,99 @@ to the require section of your application's `composer.json` file.
2533

2634
### Example
2735
```php
28-
use codenixsv\Bitfinex\BitfinexManager;
36+
use Codenixsv\BitfinexApi\BitfinexClient;
37+
38+
$client = new BitfinexClient();
39+
$data = $client->public()->getPlatformStatus();
40+
```
41+
## Available methods
42+
43+
### Public API
2944

30-
$manager = new BitfinexManager();
31-
$client = $manager->createClient();
45+
#### getPlatformStatus
46+
Get the current status of the platform, “Operative” or “Maintenance” (1=operative, 0=maintenance). Maintenance periods generally last for a
47+
few minutes to a couple of hours and may be necessary from time to time during infrastructure upgrades.
3248

33-
$responce = $client->getTicker('btcusd');
49+
```php
50+
$data = $client->public()->getPlatformStatus();
3451
```
35-
### Available methods
3652

37-
#### Public API
53+
#### getTickers
54+
The tickers endpoint provides a high level overview of the state of the market. It shows the current best bid and ask,
55+
the last traded price, as well as information on the daily volume and price movement over the last day. The endpoint can retrieve multiple tickers with a single query.
56+
```php
57+
$data = $client->public()->getTickers('tBTCUSD,tLTCUSD,fUSD');
58+
```
3859

39-
##### Get ticker
60+
#### getTicker
61+
The ticker endpoint provides a high level overview of the state of the market for a specified pair. It shows the current
62+
best bid and ask, the last traded price, as well as information on the daily volume and price movement over the last day.
4063
```php
41-
$responce = $client->getTicker('btcusd');
64+
$data = $client->public()->getTicker('tBTCUSD');
4265
```
43-
##### Various statistics about the requested pair.
66+
67+
#### getTrades
68+
The trades endpoint allows the retrieval of past public trades and includes details such as price, size, and time.
69+
Optional parameters can be used to limit the number of results; you can specify a start and end timestamp, a limit, and a sorting method.
4470
```php
45-
$responce = $client->getStats('btcusd');
71+
$data = $client->public()->getTrades('tBTCUSD', ['limit' => 100]);
4672
```
47-
##### Get the full margin funding book.
73+
74+
#### getBook
75+
The Public Books endpoint allows you to keep track of the state of Bitfinex order books on a price aggregated basis with
76+
customizable precision. Raw books can be retrieved by using precision `R0`.
4877
```php
49-
$responce = $client->getFundingBook('usd');
78+
$data = $client->public()->getBook('tBTCUSD', 'P0');
5079
```
51-
##### Get the full order book..
80+
81+
#### getStats
82+
The Stats endpoint provides various statistics on a specified trading pair or funding currency. Use the available keys
83+
to specify which statistic you wish to retrieve.
84+
85+
Use `side` param only for non-funding queries.
5286
```php
53-
$responce = $client->getOrderBook('btcusd');
87+
$data = $client->public()->getStats('pos.size', '1m', 'tBTCUSD', 'hist', 'long');
88+
$data = $client->public()->getStats('funding.size', '1m', 'fUSD', 'hist');
5489
```
55-
##### Get a list of the most recent trades for the given symbol.
90+
91+
#### getCandles
92+
The Candles endpoint provides OCHL (Open, Close, High, Low) and volume data for the specified funding currency or trading pair.
93+
Funding period required only for funding candles.
5694
```php
57-
$responce = $client->getTrades('btcusd');
95+
$data = $client->public()->getCandles('1m', 'tBTCUSD', 'hist');
96+
$data = $client->public()->getCandles('1m', 'fUSD', 'hist', 'p30');
5897
```
59-
##### Get a list of the most recent funding data for the given currency: total amount provided and Flash Return Rate (in % by 365 days) over time.
98+
99+
#### getConfigs
100+
Fetch currency and symbol site configuration data.
101+
A variety of types of config data can be fetched by constructing a path with an Action, Object, and conditionally a Detail value.
60102
```php
61-
$responce = $client->getLends('usd');
103+
$data = $client->public()->getConfigs('list', 'pair', 'exchange');
62104
```
63-
##### Get a list of symbol names.
105+
106+
#### getStatus
107+
Endpoint used to receive different types of platform information - currently supports derivatives pair status only.
64108
```php
65-
$responce = $client->getSymbols();
109+
$data = $client->public()->getStatus('deriv', ['keys' => 'tBTCF0:USTF0']);
110+
$data = $client->public()->getStatus('deriv/tBTCF0:USTF0/hist', ['start' => 157057800000, 'end' => 1573566992000]);
66111
```
67-
##### Get a list of valid symbol IDs and the pair details.
112+
113+
#### getLiquidationFeed
114+
Endpoint to retrieve liquidations. By default it will retrieve the most recent liquidations, but time-specific data can be retrieved using timestamps.
68115
```php
69-
$responce = $client->getSymbolsDetails();
70-
```
116+
$data = $client->public()->getLiquidationFeed();
117+
```
118+
119+
#### getLeaderboards
120+
The leaderboards endpoint allows you to retrieve leaderboard standings for unrealized profit (period delta), unrealized profit (inception), volume, and realized profit.
121+
```php
122+
$data = $client->public()->getLeaderboards('vol', '3h', 'tBTCUSD', 'hist');
123+
```
124+
125+
## Further Information
126+
Please, check the [Bitfinex site](https://docs.bitfinex.com/docs/rest-general) documentation for further
127+
information about API.
128+
129+
## License
130+
131+
`codenix-sv/bitfinex-api` is released under the MIT License. See the bundled [LICENSE](./LICENSE) for details.

composer.json

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,35 @@
11
{
22
"name": "codenix-sv/bitfinex-api",
3-
"description": "PHP client for the Bitfinex API",
4-
"keywords": [
5-
"bitfinex",
6-
"bitcoin",
7-
"btc",
8-
"bitfinex-api"
9-
],
103
"type": "library",
11-
"license": "BSD-3-Clause",
4+
"description": "PHP client for Bitfinex API",
5+
"homepage": "https://github.com/codenix-sv/bitfinex-api",
6+
"keywords": ["client", "api", "php", "bitfinex", "rest", "bitfinex-api", "exchange"],
7+
"license": "MIT",
128
"support": {
139
"issues": "https://github.com/codenix-sv/bitfinex-api/issues?state=open",
1410
"source": "https://github.com/codenix-sv/bitfinex-api"
1511
},
1612
"authors": [
1713
{
18-
"name": "Vladymyr Svyryd",
14+
"name": "Volodymyr Svyryd",
1915
"email": "codenix.sv@gmail.com",
2016
"role": "Developer"
2117
}
2218
],
2319
"require": {
24-
"php": ">=7.1"
20+
"php": "^7.2",
21+
"ext-json": "*"
22+
2523
},
2624
"require-dev": {
27-
"phpunit/phpunit": "~6.0"
25+
"phpunit/phpunit": "^8.0",
26+
"guzzlehttp/guzzle": "~6.0"
2827
},
2928
"autoload": {
30-
"psr-4": {
31-
"codenixsv\\Bitfinex\\": "src/"
32-
}
29+
"psr-4": { "Codenixsv\\BitfinexApi\\": "src/" }
3330
},
3431
"autoload-dev": {
35-
"psr-4": {
36-
"codenixsv\\B itfinex\\": "tests/"
37-
}
38-
}
39-
}
32+
"psr-4": { "Codenixsv\\BitfinexApi\\Tests\\": "tests/"}
33+
},
34+
"prefer-stable": true
35+
}

phpunit.xml.dist

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="vendor/autoload.php"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.2/phpunit.xsd"
34
backupGlobals="false"
45
backupStaticAttributes="false"
56
colors="true"
6-
verbose="true"
7+
bootstrap="vendor/autoload.php"
78
convertErrorsToExceptions="true"
89
convertNoticesToExceptions="true"
910
convertWarningsToExceptions="true"
1011
processIsolation="false"
1112
stopOnFailure="false">
1213
<testsuites>
13-
<testsuite name="Bitfinex API Unit Test Suite">
14-
<directory>./tests/unit</directory>
15-
</testsuite>
16-
<testsuite name="Bitfinex API Functional Test Suite">
17-
<directory>./tests/functional</directory>
14+
<testsuite name="tests">
15+
<directory suffix="Test.php">./tests</directory>
1816
</testsuite>
1917
</testsuites>
2018
<filter>
21-
<whitelist>
22-
<directory suffix=".php">./src/</directory>
19+
<whitelist processUncoveredFilesFromWhitelist="true">
20+
<directory suffix=".php">./src</directory>
2321
</whitelist>
2422
</filter>
2523
<logging>
26-
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
24+
<log type="coverage-html" target="build/coverage"/>
2725
<log type="coverage-text" target="build/coverage.txt"/>
2826
<log type="coverage-clover" target="build/logs/clover.xml"/>
2927
</logging>

0 commit comments

Comments
 (0)