承接 devstar/coinbase 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

devstar/coinbase

Composer 安装命令:

composer require devstar/coinbase

包简介

Coinbase API Like the official document interface, Support for arbitrary extension.

README 文档

README

It is recommended that you read the official document first

Coinbase docs https://developers.coinbase.com/api/v2

Coinbase Pro migrated to V3.

Coinbase Pro docs https://docs.cdp.coinbase.com/advanced-trade/docs/welcome

All interface methods are initialized the same as those provided by Coinbase. See details src/api

Most of the interface is now complete, and the user can continue to extend it based on my design, working with me to improve it.

Installation

composer require devstar/coinbase

Support for more request Settings

$coinbase=new Coinbase();
//or
$coinbase=new CoinbasePro();
// or
$coinbase=new CoinbaseExchange();

//You can set special needs
$coinbase->setOptions([
    //Set the request timeout to 60 seconds by default
    'timeout'=>10,
    
    //If you are developing locally and need an agent, you can set this
    'proxy'=>true,
    //More flexible Settings
    /* 'proxy'=>[
     'http'  => 'http://127.0.0.1:12333',
     'https' => 'http://127.0.0.1:12333',
     'no'    =>  ['.cn']
     ], */
    //Close the certificate
    //'verify'=>false,
]);

Coinbase Spot API

Publics API More

$coinbase=new Coinbase();

try {
    $result=$coinbase->publics()->getTime();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$coinbase->publics()->getCurrencies();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$coinbase->publics()->getExchangeRates();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$coinbase->publics()->getPricesBuy([
        'currency_pair'=>'BTC-USD'
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$coinbase->publics()->getPricesSell([
        'currency_pair'=>'BTC-USD'
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$coinbase->publics()->getPricesSpot([
        'currency_pair'=>'BTC-USD'
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

Privates API More

//User
try {
    $result=$coinbase->privates()->getUsers();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$coinbase->privates()->getUser([
        'user_id'=>'fb352ff7-ce80-53ac-b0e1-7cfe51eca2ff'
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$coinbase->privates()->getUserAuth();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$coinbase->privates()->putUser([
        'name'=>'linwenjun'
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

//Accounts
try {
    $result=$coinbase->privates()->getAccounts();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$coinbase->privates()->getAccount([
        'account_id'=>'BTC'
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$coinbase->privates()->putAccount([
        'account_id'=>'BTC',
        'name'=>'bbttcc'
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

//Addresses
try {
    $result=$coinbase->privates()->getAccountAddresses([
        'account_id'=>'BTC'
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

//List transactions
try {
    $result=$coinbase->privates()->getAccountTransactions([
        'account_id'=>'b1096c85-fbf8-5293-9424-5af475446ebd'
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

//List buys
try {
    $result=$coinbase->privates()->getAccountBuys([
        'account_id'=>'b1096c85-fbf8-5293-9424-5af475446ebd'
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$coinbase->privates()->getPaymentMethods();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

//Place buy order
try {
    $result=$coinbase->privates()->postAccountBuys([
        'account_id'=>'b1096c85-fbf8-5293-9424-5af475446ebd',
        'amount'=>'1',
        'currency'=>'BTC',
        //'payment_method'=>'83562370-3e5c-51db-87da-752af5ab9559',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

More Test

More Api

Coinbase Pro Spot API

Market related API More

$coinbase=new CoinbasePro();

try {
    $result=$coinbase->product()->getList();
    print_r($result);
}catch (\Exception $e){
    print_r($e->getMessage());
}

try {
    $result=$coinbase->product()->getBook([
        'product_id'=>'BTC-USD',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r($e->getMessage());
}

try {
    $result=$coinbase->product()->getCandles([
        'product_id'=>'BTC-USD',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r($e->getMessage());
}

Order related API More

$coinbase=new CoinbasePro($key,$secret,$passphrase);

//****************************Market
try {
    $result=$coinbase->order()->post([
        'client_order_id' => time()."",
        'side'=>'SELL',
        'product_id'=>"BTC-USD",
        'order_configuration' => [
            'market_market_ioc' => [
                'base_size'=>'0.001'
            ]
        ]
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r($e->getMessage());
}
sleep(1);

//track the order
try {
    $result=$coinbase->order()->get([
        'id'=>$result['order_id'],
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r($e->getMessage());
}
sleep(1);

//cancellation of order
try {
    $result=$coinbase->order()->delete([
        'id'=>$result['order_id'],
        //'id'=>'6bad6a7d-b01a-4a93-9e6e-e9934bcef4ef',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r($e->getMessage());
}


//track the order
try {
    $result=$coinbase->order()->get([
        'id'=>$result['order_id'],
        //'client_oid'=>''
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r($e->getMessage());
}

Accounts related API More

$coinbase=new CoinbaseExchange($key,$secret,$passphrase);

try {
    $result=$coinbase->account()->getList();
    print_r($result);
}catch (\Exception $e){
    print_r($e->getMessage());
}

try {
    $result=$coinbase->account()->get([
        'account_id'=>'c74a36f5-4f2b-495b-be29-6eb2458d1b3a'
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r($e->getMessage());
}

try {
    $result=$coinbase->account()->getHolds([
        'account_id'=>'c74a36f5-4f2b-495b-be29-6eb2458d1b3a'
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r($e->getMessage());
}

try {
    $result=$coinbase->account()->getLedger([
        'account_id'=>'c74a36f5-4f2b-495b-be29-6eb2458d1b3a'
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r($e->getMessage());
}

More Api More Api

Test

./vendor/bin/phpunit --bootstrap vendor/autoload.php tests/coinbase/AccountTest.php More Test

devstar/coinbase 适用场景与选型建议

devstar/coinbase 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 06 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「coinbase」 「exchange」 「trade」 「coinbase pro」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 devstar/coinbase 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 devstar/coinbase 我们能提供哪些服务?
定制开发 / 二次开发

基于 devstar/coinbase 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 17
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 34
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-06-21