bitso/bitso-php

Bitso API 的 PHP 封装器

此包的官方仓库似乎已消失,因此该包已被冻结。

维护者

详细信息

github.com/bitsoex/bitso-php

主页

v1.3 2021-01-21 21:48 UTC

This package is not auto-updated.

Last update: 2024-01-20 06:07:51 UTC


README

Bitso API 提供的 PHP 封装器。

安装

要安装 bitso-php API 封装器:$ composer require bitso/bitso-php:* 或等价地在您的 composer.json 文件中

{
    "require": {
        "bitso/bitso-php": "dev-master"
    }
}

公共 API 使用

require 'vendor/autoload.php'

$bitso = new BitsoAPI\bitso();

默认情况下已设置生产 API,要使用开发 API

require 'vendor/autoload.php'

$bitso = new BitsoAPI\bitso('','',$url);

私有 API 使用

require 'vendor/autoload.php'

$bitso = new BitsoAPI\bitso(API_KEY, API_SECRET, URL);

请参阅上方的说明,了解如何使用开发 API

参数说明

参数必须是以下形式的数组

["arg1"=>"value","arg2"=>"value"]

此外,对于如查询订单、取消订单等方法,没有参数数组,但必须有包含订单 ID 的数组

['id','id','id]

请参阅具体调用以获取详细示例。

公共调用

可用书籍

## Order books available on Bitso
$books = $bitso->available_books();

##sample usage for minimum amount of btc_mxn (0)
$books->payload[0]->minimum_amount;
##for minimum amount of eth_mxn (1)
$books->payload[1]->minimum_amount;

行情

## Ticker information
## Parameters
## [book] - Specifies which book to use
##                  - string
$ticker = $bitso->ticker(["book"=>"btc_mxn"]);

##sample usage for ask price of btc_mxn
$ticker->payload->ask;

订单簿

## Public order book
## Parameters
## [book] - Specifies which book to use
##                  - string
## [aggregate = True] - Group orders with the same price
##                - boolean

$ob = $bitso->order_book(["book"=>"btc_mxn","aggregate"=> "True"]);

## sample usage for array of asks for btc_mxn
$ob->payload->asks;

交易

## Public trades
## Parameters
## [book = 'btc_mxn'] - Specifies which book to use
##                    - str
## [marker = None] - Returns objects that are older or newer (depending on 'sort’) than the object with this ID
##                    - str
## [sort = 'desc'] - Specifies ordering direction of returned objects (asc, desc)
##                    - str
## [limit = '25'] - Specifies number of objects to return. (Max is 100)
##                    - str

$trades = $bitso->trades(["book"=>"btc_mxn"]);

##sample usage to get array of trades 
$trades->payload;

私有调用

私有端点用于管理您的账户和订单。这些请求必须使用您的 Bitso 凭据签名

账户状态

## Your account status
$status = $bitso->account_status();

##sample usage for account status array
$status->payload;

账户余额

## Your account balances
$balances = $bitso->balances();

##sample usage for account balances array
$balances->payload->balances;

费用

## Your trade fees
$fees = $bitso->fees();

##sample usage for fees array
$fees->payload;

账本

## A ledger of your historic operations.
## Parameters
## [marker]    - Returns objects that are older or newer (depending on 'sort’) than the object with this ID
##                 - string
## [limit = 25]   - Limit result to that many transactions
##                 - int
## [sort = 'desc'] - Sorting by datetime
##                 - string - 'asc' or
##                 - 'desc'

$ledger = $bitso->ledger(["limit"=>"15"]);

##sample usage for ledger array of size determined by limit
$ledger->payload;

提款

## Detailed info on your fund withdrawals.
## Parameters
## [wids]    - Specifies which withdrawal objects to return by IDs
##                 - list
## [marker]    - Returns objects that are older or newer (depending on 'sort’) than the object with this ID
##                 - string
## [limit = 25]   - Limit result to that many transactions
##                 - int
## [sort = 'desc'] - Sorting by datetime
##                 - string - 'asc' or
##                 - 'desc'

$withdrawals = $bitso->withdrawals(["limit"=>"20","wids"=>"ids"));

##sample usage for withdrawals array of size determined by limit
$withdrawals->payload;

充值

## Detailed info on your fundings.
## Parameters
## [fids]    - Specifies which funding objects to return by IDs
##                 - list
## [marker]    - Returns objects that are older or newer (depending on 'sort’) than the object with this ID
##                 - string
## [limit = 25]   - Limit result to that many transactions
##                 - int
## [sort = 'desc'] - Sorting by datetime
##                 - string - 'asc' or
##                 - 'desc'

$fundings = $bitso->fundings(["limit"=>"20","fids"->"ids"));

##sample usage for fundings array of size determined by limit
$fundings->payload;

用户交易

## Your trades
## Parameters
## [book = all]- Specifies which book to use
##                 - string
## [marker]    - Returns objects that are older or newer (depending on 'sort’) than the object with this ID
##                 - string
## [limit = 25]   - Limit result to that many transactions
##                 - int
## [sort = 'desc'] - Sorting by datetime
##                 - string - 'asc' or
##                 - 'desc'

$user_trades = $bitso->user_trades(['book'=>'btc_mxn']);

##sample usage for getting array of user trades
$user_trades->payload;

开放订单

## Returns a list of the user’s open orders
## Parameters
## [book] - Specifies which book to use
##                    - str
## [marker]    - Returns objects that are older or newer (depending on 'sort’) than the object with this ID
##                 - string
## [limit = 25]   - Limit result to that many transactions
##                 - int
## [sort = 'desc'] - Sorting by datetime
##                 - string - 'asc' or
##                 - 'desc'
$open_orders = $bitso->open_orders(['book'=>'btc_mxn']);

##sample usage for getting array of open orders
$open_orders->payload;

查询订单

## Returns a list of details for 1 or more orders
## Parameters
## order_ids -  A list of Bitso Order IDs.
##          - string
$lookup_order = $bitso->lookup_order([oids]);

##sample usage for getting status of a specific order (if one oids is passed in)
$lookup_order->payload->status;

##sample usage for getting status of a specific order (if more than one oids are passed in)
$lookup_order->payload[i]->status;

取消订单

## Cancels an open order
## Parameters
## order_id -  A Bitso Order ID.
##          - string
$cancel_order =  $bitso->cancel_order([oids]);

下单

## Places a buy limit order.
## [book] - Specifies which book to use (btc_mxn, eth_mxn)
##                    - str
## [side] - the order side (buy, sell) 
##                    - str
## [order_type] - the order type (limit, market) 
##                    - str
## amount - Amount of major currency to buy.
##        - string
## major  - The amount of major currency for this order. An order must be specified in terms of major or minor, never both.
##        - string. Major denotes the cryptocurrency, in our case Bitcoin (BTC) or Ether (ETH).
## minor  - The amount of minor currency for this order. Minor denotes fiat currencies, in our case Mexican Peso (MXN)
##        - string
## price  - Price per unit of major. For use only with limit orders
##        - string

$place_order = $bitso->place_order(['book'  => 'btc_mxn', 'side'  => 'buy', 'major' => '.01', 'price' => '1000', type'  => 'limit']);

充值目的地地址

## Gets a Funding destination address to fund your account
## fund_currency  - Specifies the currency you want to fund your account with (btc, eth, mxn)
##                            - str
$funding_destination = $bitso->funding_destination(['fund_currency'=>'eth']);

比特币提现

## Triggers a bitcoin withdrawal from your account
## amount  - The amount of BTC to withdraw from your account
##         - string
## address - The Bitcoin address to send the amount to
##         - string

$btc_withdrawal = $bitso->btc_withdrawal(['amount'=>'.05','address'  => '']);

以太坊提现

## Triggers a bitcoin withdrawal from your account
## amount  - The amount of BTC to withdraw from your account
##         - string
## address - The Bitcoin address to send the amount to
##         - string

$eth_withdrawal = $bitso->eth_withdrawal(['amount'  => '.05','address'  => '']);

瑞波币提现

## Triggers a ripple withdrawal from your account
## currency  - The currency to withdraw
##         - string
## amount  - The amount of BTC to withdraw from your account
##         - string
## address - The ripple address to send the amount to
##         - string

$ripple_withdrawal = $bitso->ripple_withdrawal(['currency'=>'MXN','amount'=> '.05','address'  => '']);

银行提现(SPEI)

## Triggers a SPEI withdrawal from your account. These withdrawals are
##   immediate during banking hours (M-F 9:00AM - 5:00PM Mexico City Time).
##
## amount  - The amount of MXN to withdraw from your account
##         - string
## recipient_given_names - The recipient’s first and middle name(s)
##         - string
## recipient_family_names - The recipient’s last name)
##         - string
## clabe - The CLABE number where the funds will be sent to
##         - string
## notes_ref - The alpha-numeric reference number for this SPEI
##         - string
## numeric_ref - The numeric reference for this SPEI
##         - string

$spei_withdrawal = $bitso->spei_withdrawal(['amount'  => '105','recipient_given_names'  => 'Andre Pierre','recipient_family_names'=>'Gignac', 'clabe'=>'CLABE','notes_ref'=>'NOTES_REF','numeric_ref'=>'NUMERIC REF']);

测试

要测试库,安装后,请在bitso.php文件或两个测试文件中输入您的API密钥,然后进入存储库的根目录并运行

./vendor/bin/phpunit

请记住输入API密钥进行测试,因为测试文件中留有空位用于密钥。