skydiablo/coinbase-pro
Composer 安装命令:
composer require skydiablo/coinbase-pro
包简介
A library to interact with Coinbase Pro via API.
README 文档
README
A library written in PHP to interact with Coinbase Pro via API. This is the ReactPHP variant with a Promise based interface and inspired by blakedhamilton/coinbase-pro.
https://github.com/skydiablo/Coinbase-Pro
https://docs.pro.coinbase.com/
Table of contents
Installation with Composer
The latest version can be installed via Composer, therefore you will need to install Composer if you do not have it installed already.
Next, require the library with:
composer require skydiablo/coinbase-pro
Usage
Getting started
First you'll need to obtain an instance of the base Coinbase class by providing your API credentials.
Your API credentials can be obtained at:
- Production: https://pro.coinbase.com/profile/api
- Sandbox: https://public.sandbox.pro.coinbase.com/profile/api
Once you have your API credentials, obtain an instance of the Coinbase class with:
<?php use Coinbase\Coinbase; // Your API key, secret, and passphrase. $key = 'API_KEY'; $secret = 'API_SECRET'; $passphrase = 'API_PASSPHRASE'; // Sandbox mode indicates whether you want to // make API calls against Coinbase's production // or sandbox servers for development. $sandbox = true; // Create an instance of the Coinbase base class. $coinbase = Coinbase::create($key, $secret, $passphrase, $sandbox);
Making requests
Accounts
https://docs.pro.coinbase.com/#accounts
// Get a list of trading accounts from the profile of the API key. $accounts = $coinbase->accounts->list(); // Get a single trading account. $account = $coinbase->accounts->get('account_id'); // Get trading account history. // Available options can be found at: https://docs.pro.coinbase.com#get-account-history $history = $coinbase->accounts->getHistory('account_id'); $history = $coinbase->accounts->getHistory('account_id', $options = []); // Get trading account holds. // Available options can be found at: https://docs.pro.coinbase.com#get-holds $holds = $coinbase->accounts->getHolds('account_id'); $holds = $coinbase->accounts->getHolds('account_id', $options = []);
Orders
https://docs.pro.coinbase.com/#orders
// Get a list of orders. // Available options can be found at: https://docs.pro.coinbase.com#list-orders $orders = $coinbase->orders->list(); $orders = $coinbase->orders->list($options = []); // Get a single order. $order = $coinbase->orders->get('order_id'); // Place a new order. // Available options can be found at: https://docs.pro.coinbase.com#place-a-new-order $order = $coinbase->orders->place($options = []); // Cancel an order. // Available options can be found at: https://docs.pro.coinbase.com#cancel-an-order $result = $coinbase->orders->delete('order_id'); $result = $coinbase->orders->delete('order_id', $options = []); // Cancel all orders. // Available options can be found at: https://docs.pro.coinbase.com#cancel-all $result = $coinbase->orders->deleteAll();
Fills
https://docs.pro.coinbase.com/#fills
// Get a list of recent fills of the API key's profile. // Available options can be found at: https://docs.pro.coinbase.com#list-fills $fills = $coinbase->fills->list(); $fills = $coinbase->fills->list($options = []);
Limits
https://docs.pro.coinbase.com/#limits
// Get current exchange limits. $limits = $coinbase->limits->get();
Deposits
https://docs.pro.coinbase.com/#deposits
// Get a list of deposits from the profile of the API key. // Available options can be found at: https://docs.pro.coinbase.com#list-deposits $deposits = $coinbase->deposits->list(); $deposits = $coinbase->deposits->list($options = []); // Get information on a single deposit. $deposit = $coinbase->deposits->get('deposit_id'); // Deposit funds from a payment method. // Available options can be found at: // - https://docs.pro.coinbase.com#payment-method // - https://docs.pro.coinbase.com#coinbase $deposit = $coinbase->deposits->create($options = []); // Generate an address for crypto deposits. $address = $coinbase->deposits->createCryptoDepositAddress('coinbase_account_id');
Withdrawals
https://docs.pro.coinbase.com/#withdrawals
// Get a list of withdrawals from the profile of the API key. // Available options can be found at: https://docs.pro.coinbase.com#list-withdrawals $withdrawals = $coinbase->withdrawals->list(); $withdrawals = $coinbase->withdrawals->list($options = []); // Get information on a single withdrawal. $withdrawal = $coinbase->withdrawals->get('withdrawal_id'); // Withdraw funds to a payment method. // Available options can be found at: // - https://docs.pro.coinbase.com#payment-method55 // - https://docs.pro.coinbase.com#coinbase56 // - https://docs.pro.coinbase.com/#crypto $withdrawal = $coinbase->withdrawals->create($options = []); // Gets the network fee estimate when sending to the given address. // Available options can be found at: https://docs.pro.coinbase.com#fee-estimate $estimate = $coinbase->withdrawals->getFeeEstimate($options);
Stablecoin Conversions
https://docs.pro.coinbase.com/#stablecoin-conversions
// Create a conversion. // Available options can be found at: https://docs.pro.coinbase.com#stablecoin-conversions $conversion = $coinbase->stablecoinConversions->create($options = []);
Payment Methods
https://docs.pro.coinbase.com/#payment-methods
// Get a list of payment methods. $paymentMethods = $coinbase->paymentMethods->get();
Coinbase Accounts
https://docs.pro.coinbase.com/#list-accounts64
// Get a list of your Coinbase accounts. $coinbaseAccounts = $coinbase->coinbaseAccounts->get();
Fees
https://docs.pro.coinbase.com/#fees
// Get your current maker & taker fee rates, as well as your 30-day trailing volume. $fees = $coinbase->fees->get();
Reports
https://docs.pro.coinbase.com/#reports
// Get all reports for a profile. // Available options can be found at: https://docs.pro.coinbase.com#get-report-status $reports = $coinbase->reports->list(); $reports = $coinbase->reports->list($options = []); // Get a report's status. $status = $coinbase->reports->get('report_id'); // Create a new report. // Available options can be found at: https://docs.pro.coinbase.com#create-a-new-report $report = $coinbase->reports->create($options = []);
Profiles
https://docs.pro.coinbase.com/#profiles26
// Get a List of your profiles. // Available options can be found at: https://docs.pro.coinbase.com#list-profiles $profiles = $coinbase->profiles->list(); $profiles = $coinbase->profiles->list($options = []); // Get a single profile. $profile = $coinbase->profiles->get('profile_id'); // Transfer funds from API key's profile to another user owned profile. // Available options can be found at: https://docs.pro.coinbase.com#create-profile-transfer $result = $coinbase->profiles->create($options = []);
Oracle
https://docs.pro.coinbase.com/#oracle
// Get cryptographically signed prices ready to be posted on-chain using Open Oracle smart contracts. $result = $coinbase->oracle->get();
Market data
Products
https://docs.pro.coinbase.com/#products
// List all products. $products = $coinbase->marketData->products->get(); // Get a single product. $product = $coinbase->marketData->products->get('product_id'); // Get product order book data. // Available options can be found at: https://docs.pro.coinbase.com#get-product-order-book $orderBook = $coinbase->marketData->products->getOrderBook('product_id'); $orderBook = $coinbase->marketData->products->getOrderBook('product_id', $options = []); // Get product ticker data. $ticker = $coinbase->marketData->products->getTicker('product_id'); // List the latest trades of a product. // Available options can be found at: https://docs.pro.coinbase.com/#get-trades $orderBook = $coinbase->marketData->products->getTrades('product_id'); $orderBook = $coinbase->marketData->products->getTrades('product_id', $options = []); // Get historic rates of a product. // Available options can be found at: https://docs.pro.coinbase.com/#get-historic-rates $historicRates = $coinbase->marketData->products->getHistoricRates('product_id'); $historicRates = $coinbase->marketData->products->getHistoricRates('product_id', $options = []); // Get 24 hr stats of a product. $stats = $coinbase->marketData->products->getDailyStats('product_id');
Currencies
https://docs.pro.coinbase.com/#currencies
// List known currencies. $currencies = $coinbase->marketData->currencies->get(); // Get a single currency. $currency = $coinbase->marketData->currencies->get('currency_id');
Time
https://docs.pro.coinbase.com/#time
// Get the API server time. $time = $coinbase->marketData->time->get();
skydiablo/coinbase-pro 适用场景与选型建议
skydiablo/coinbase-pro 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 12 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 skydiablo/coinbase-pro 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 skydiablo/coinbase-pro 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-12-18