A library written in PHP to interact with Coinbase Pro via API.

Overview

Coinbase Pro

A library written in PHP to interact with Coinbase Pro via API.

https://packagist.org/packages/blakedhamilton/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 blakedhamilton/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:

Once you have your API credentials, obtain an instance of the Coinbase class with:



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();
You might also like...
A links dashboard which can be integrated via HTML into various other systems.

quickdash Newest QuickDash version. Combines the API and Client repositories. Requirements PHP version 7.4 - https://www.php.net/ Composer - https://g

Notifies via Telegram when an aircraft passes over a certain area.
Notifies via Telegram when an aircraft passes over a certain area.

adsbTelegramNotifier Notifies via Telegram when an aircraft passes over a certain area. The script gets the data from an existing readsb or dump1090 i

OpenAI API Client is a component-oriented, extensible client library for the OpenAI API. It's designed to be faster and more memory efficient than traditional PHP libraries.

OpenAI API Client in PHP (community-maintained) This library is a component-oriented, extensible client library for the OpenAI API. It's designed to b

A telegram bot to check credit cards. written in php & py

MRBANKER BOT A telegram bot to check credit cards. written in php & py. You can find me on telegram STEP1: goto botfather create a bot copy the token

An asynchronous ClamAV wrapper written in PHP with amphp/socket

amphp-clamav An asynchronous ClamAV wrapper written with amphp/socket Installing composer require pato05/amphp-clamav Examples Ping and scan of a fil

Lightweight PHP library for WhatsApp API to send the whatsapp messages in PHP provided by ultramsg.com

Ultramsg.com WhatsApp API PHP SDK Lightweight PHP library for WhatsApp API to send the whatsappp messages in PHP provided by Ultramsg.com Installation

Google-api-php-client - A PHP client library for accessing Google APIs

Google APIs Client Library for PHP Reference Docs https://googleapis.github.io/google-api-php-client/main/ License Apache 2.0 The Google API Client Li

BeckhoffPLCSoapClient - SoapClient to communicate with BeckHoff PLC. Library made in PHP based on TcAdsWebService JavaScript Library.

BeckhoffPLCSoapClient - SoapClient to communicate with BeckHoff PLC. Library made in PHP based on TcAdsWebService JavaScript Library.

PHP library for the Stripe API.

Stripe PHP bindings The Stripe PHP library provides convenient access to the Stripe API from applications written in the PHP language. It includes a p

Comments
  • Valid syntax for options.

    Valid syntax for options.

    Hello and thank you for the library, I'm sorry in advance If i'm not correctly using this tab as this maynot be an issue with the code but rather my lack of knowledge. What syntax should be passed to the "Options" parameter, for example: $coinbase->orders->place($options = []); I have tried passing it an array, json object, or just a string, however I receive an error, Uncaught Error: Call to undefined method Coinbase\Endpoints\Orders::place().. I'm using the sandbox env. Could you please provide me with a valid example that I could pass in? Thank you

    opened by ygcodes90025 2
  • Thank you for doing it !

    Thank you for doing it !

    Hi @blakedhamilton !

    This is actually not a bug report, just asking do you know if your library is stable to be used ?

    And, I know you're building the documentation, but if you could just place a draft example and I'll take it from there :)

    Thanks a lot for doing this! Will used it as soon as it's testable.

    opened by brunocfalcao 1
Owner
Blake Hamilton
Blake Hamilton
⚡️ Web3 PHP is a supercharged PHP API client that allows you to interact with a generic Ethereum RPC.

Web3 PHP is a supercharged PHP API client that allows you to interact with a generic Ethereum RPC. This project is a work-in-progress. Code and docume

Web3 PHP 665 Dec 23, 2022
Instantly connects the Subtext text messaging service with Paid Memberships Pro.

INSTANTLY CONNECTS AND INTEGRATES THE SUBTEXT TEXT MESSAGING SERVICE WITH PAID MEMBERSHIPS PRO. This plugin instantly and easily connects, and integra

Fourth Estate® 1 May 10, 2022
This library allows you to quickly and easily use the Twilio SendGrid Web API v3 via PHP

This library allows you to quickly and easily use the Twilio SendGrid Web API v3 via PHP

Twilio SendGrid 1.4k Dec 27, 2022
This library is for integration with Salesforce via REST API.

xsolve-pl/salesforce-client Introduction This library is for integration with Salesforce via REST API. Licence This library is under the MIT license.

Boldare / XSolve Sp. z o.o. 31 Oct 13, 2022
Wise-php - This library is written to accommodate the wise API's use in php projects With Wise

Wise-php - This library is written to accommodate the wise API's use in php projects With Wise you can automate payments, connect your business tools, and create ways to manage your finances. You can also power your cross-border and domestic payouts.

Albert Xhani 15 Nov 17, 2022
The library provides convenient access to the Epoint.az API from applications written in the PHP language.

Tural/Epoint library/SDK The library provides convenient access to the Epoint.az API from applications written in the PHP language. It includes a pre-

Tural 5 Jan 20, 2022
The library provides convenient access to the Epoint.az API from applications written in the PHP language.

Tural/Epoint library/SDK The library provides convenient access to the Epoint.az API from applications written in the PHP language. It includes a pre-

Tural 5 Jan 20, 2022
PHP package for the Limg.app website - allowing to upload images via the API of the website.

Limg PHP Client Package. Installation You can install the package via composer: composer require havenstd06/limg-php-client Usage use Havenstd06\Limg\

Thomas 3 Jul 27, 2021
PHP JSON-RPC 2.0 Server/Client Implementation with Automatic Client Class Generation via SMD

PHP JSON-RPC 2.0 Server/Client Implementation with Automatic Client Class Generation via SMD

Sergey Bykov 63 Feb 14, 2022
ProcessTranslatePage – A Processwire module to translate all page fields via Fluency

ProcessTranslatePage – A Processwire module to translate all page fields via Fluency ProcessTranslatePage is an extension for the Processwire module F

Robert Weiss 5 Aug 29, 2022