codenix-sv/bitfinex-api

PHP client for Bitfinex API

v1.0.1 2020-07-29 05:37 UTC

This package is auto-updated.

Last update: 2024-10-29 05:28:24 UTC


README

Build Status Scrutinizer Code Quality License: MIT Packagist

A simple PHP wrapper for Bitfinex API. Bitfinex The world's largest and most advanced cryptocurrency trading platform

Pay attention to the WebSocket client in PHP for the Bitfinex API

Requirements

  • PHP >= 7.2
  • ext-json
  • Bitfinex, API key and API secret

Installation

The preferred way to install this extension is through composer.

Either run

$ composer require codenix-sv/bitfinex-api

or add

"codenix-sv/bitfinex-api" : "^1.0"

to the require section of your application's composer.json file.

Basic usage

Example

use Codenixsv\BitfinexApi\BitfinexClient;

$client = new BitfinexClient();
$data = $client->public()->getPlatformStatus();

Available methods

Public API

getPlatformStatus

Get the current status of the platform, “Operative” or “Maintenance” (1=operative, 0=maintenance). Maintenance periods generally last for a few minutes to a couple of hours and may be necessary from time to time during infrastructure upgrades.

$data = $client->public()->getPlatformStatus();

getTickers

The tickers endpoint provides a high level overview of the state of the market. It shows the current best bid and ask, 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.

$data = $client->public()->getTickers('tBTCUSD,tLTCUSD,fUSD');

getTicker

The ticker endpoint provides a high level overview of the state of the market for a specified pair. It shows the current best bid and ask, the last traded price, as well as information on the daily volume and price movement over the last day.

$data = $client->public()->getTicker('tBTCUSD');

getTrades

The trades endpoint allows the retrieval of past public trades and includes details such as price, size, and time. 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.

$data = $client->public()->getTrades('tBTCUSD', ['limit' => 100]);

getBook

The Public Books endpoint allows you to keep track of the state of Bitfinex order books on a price aggregated basis with customizable precision. Raw books can be retrieved by using precision R0.

$data = $client->public()->getBook('tBTCUSD', 'P0');

getStats

The Stats endpoint provides various statistics on a specified trading pair or funding currency. Use the available keys to specify which statistic you wish to retrieve.

Use side param only for non-funding queries.

$data = $client->public()->getStats('pos.size', '1m', 'tBTCUSD', 'hist', 'long');
$data = $client->public()->getStats('funding.size', '1m', 'fUSD', 'hist');

getCandles

The Candles endpoint provides OCHL (Open, Close, High, Low) and volume data for the specified funding currency or trading pair. Funding period required only for funding candles.

$data = $client->public()->getCandles('1m', 'tBTCUSD', 'hist');
$data = $client->public()->getCandles('1m', 'fUSD', 'hist', 'p30');

getConfigs

Fetch currency and symbol site configuration data. A variety of types of config data can be fetched by constructing a path with an Action, Object, and conditionally a Detail value.

$data = $client->public()->getConfigs('list', 'pair', 'exchange');

getStatus

Endpoint used to receive different types of platform information - currently supports derivatives pair status only.

$data = $client->public()->getStatus('deriv', ['keys' => 'tBTCF0:USTF0']);
$data = $client->public()->getStatus('deriv/tBTCF0:USTF0/hist', ['start' => 157057800000, 'end' => 1573566992000]);

getLiquidationFeed

Endpoint to retrieve liquidations. By default it will retrieve the most recent liquidations, but time-specific data can be retrieved using timestamps.

$data = $client->public()->getLiquidationFeed();

getLeaderboards

The leaderboards endpoint allows you to retrieve leaderboard standings for unrealized profit (period delta), unrealized profit (inception), volume, and realized profit.

$data = $client->public()->getLeaderboards('vol', '3h', 'tBTCUSD', 'hist');

Further Information

Please, check the Bitfinex site documentation for further information about API.

License

codenix-sv/bitfinex-api is released under the MIT License. See the bundled LICENSE for details.