punksolid / bitso
Bitso API的PHP包装器
v0.7.3
2024-03-04 02:56 UTC
Requires
- php: >=8.2
- moneyphp/money: ^4.4
- symfony/http-client: ^7
Requires (Dev)
- phpunit/phpunit: ^10
- rector/rector: ^0.18.5
- symfony/var-dumper: ^6.3
- vimeo/psalm: ^5.15
This package is auto-updated.
Last update: 2024-09-04 04:18:30 UTC
README
这是一个用于Bitso API的PHP包装器。
安装
要安装bitso php api包装器: $ composer require punksolid/bitso:*
或者在你的composer.json文件中相应地配置
{ "require": { "punksolid/bitso": "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->orderBook(["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->accountStatus(); ##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->userTrades(['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->placeOrder(['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->fundingDestination(['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密钥以进行测试,因为测试文件中有空位用于密钥。