PHPackages                             neto737/coinbase - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. neto737/coinbase

ActiveLibrary[API Development](/categories/api)

neto737/coinbase
================

Coinbase API library

v2.9.0(4y ago)112Apache-2.0PHPPHP &gt;=7.3.0

Since Jul 29Pushed 4y agoCompare

[ Source](https://github.com/neto737/coinbase-php)[ Packagist](https://packagist.org/packages/neto737/coinbase)[ Docs](http://coinbase.com)[ RSS](/packages/neto737-coinbase/feed)WikiDiscussions main Synced 4d ago

READMEChangelog (1)Dependencies (5)Versions (14)Used By (0)

Coinbase Wallet PHP Library
===========================

[](#coinbase-wallet-php-library)

[![Build Status](https://camo.githubusercontent.com/de31d51357d22657a8511f5313fccf1712934af438bf1b16f1e41f4fab4bab47/68747470733a2f2f6170692e7472617669732d63692e636f6d2f6e65746f3733372f636f696e626173652d7068702e7376673f6272616e63683d6d61696e)](https://travis-ci.com/github/neto737/coinbase-php)[![Latest Stable Version](https://camo.githubusercontent.com/8d639ff7087402abbca2f61dac95d78b2e5eef6f6483bf01a34721afebd2b945/68747470733a2f2f706f7365722e707567782e6f72672f6e65746f3733372f636f696e626173652f762f737461626c65)](https://packagist.org/packages/neto737/coinbase)[![Total Downloads](https://camo.githubusercontent.com/00ac9f6d1cc30f96fbab4d6043de4e2aea60fecd35e63dc6d77f8f637f6367a0/68747470733a2f2f706f7365722e707567782e6f72672f6e65746f3733372f636f696e626173652f646f776e6c6f616473)](https://packagist.org/packages/neto737/coinbase)[![Latest Unstable Version](https://camo.githubusercontent.com/9611e720c2169559cd5f9947ece981b35f3a3546ebef49088e8a51559a7ecedb/68747470733a2f2f706f7365722e707567782e6f72672f6e65746f3733372f636f696e626173652f762f756e737461626c65)](https://packagist.org/packages/neto737/coinbase)[![License](https://camo.githubusercontent.com/102dd8bf64fa59030972c32fbede5a94ecb966fa86153971ba8601fd2f17f0c5/68747470733a2f2f706f7365722e707567782e6f72672f6e65746f3733372f636f696e626173652f6c6963656e7365)](https://packagist.org/packages/neto737/coinbase)

This is a fork of the [official client library](https://github.com/coinbase/coinbase-php) for the [Coinbase Wallet API v2](https://developers.coinbase.com/api/v2). We provide an intuitive, stable interface to integrate Coinbase Wallet into your PHP project.

*Important:* As this library is targeted for newer API v2, it requires v2 permissions (i.e. `wallet:accounts:read`).

Installation
------------

[](#installation)

Install the library using Composer. Please read the [Composer Documentation](https://getcomposer.org/doc/01-basic-usage.md) if you are unfamiliar with Composer or dependency managers in general.

```
"require": {
    "neto737/coinbase": "~2.0"
}
```

Authentication
--------------

[](#authentication)

### API Key

[](#api-key)

Use an API key and secret to access your own Coinbase account.

```
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;

$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);
```

### OAuth2

[](#oauth2)

Use OAuth2 authentication to access a user's account other than your own. This library does not handle the handshake process, and assumes you have an access token when it's initialized. You can handle the handshake process using an [OAuth2 client](https://packagist.org/search/?q=oauth2%20client) such as [league/oauth2-client](https://packagist.org/packages/league/oauth2-client).

```
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;

// with a refresh token
$configuration = Configuration::oauth($accessToken, $refreshToken);

// without a refresh token
$configuration = Configuration::oauth($accessToken);

$client = Client::create($configuration);
```

### Two factor authentication

[](#two-factor-authentication)

The send money endpoint requires a 2FA token in certain situations (read more [here](https://developers.coinbase.com/docs/wallet/coinbase-connect#two-factor-authentication)). A specific exception is thrown when this is required.

```
use Coinbase\Wallet\Enum\Param;
use Coinbase\Wallet\Exception\TwoFactorRequiredException;
use Coinbase\Wallet\Resource\Transaction;

$transaction = Transaction::send([
    'toEmail' => 'test@test.com',
    'bitcoinAmount' => 1
]);

$account = $client->getPrimaryAccount();
try {
    $client->createAccountTransaction($account, $transaction);
} catch (TwoFactorRequiredException $e) {
    // show 2FA dialog to user and collect 2FA token

    // retry call with token
    $client->createAccountTransaction($account, $transaction, [
        Param::TWO_FACTOR_TOKEN => '123456',
    ]);
}
```

### Pagination

[](#pagination)

Several endpoints are [paginated](https://developers.coinbase.com/api/v2#pagination). By default, the library will only fetch the first page of data for a given request. You can easily load more than just the first page of results.

```
$transactions = $client->getAccountTransactions($account);
while ($transactions->hasNextPage()) {
    $client->loadNextTransactions($transactions);
}
```

You can also use the `fetch_all` parameter to have the library issue all the necessary requests to load the complete collection.

```
use Coinbase\Wallet\Enum\Param;

$transactions = $client->getAccountTransactions($account, [
    Param::FETCH_ALL => true,
]);
```

### Warnings

[](#warnings)

It's prudent to be conscious of warnings. The library will log all warnings to a standard PSR-3 logger if one is configured.

```
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;

$configuration = Configuration::apiKey($apiKey, $apiSecret);
$configuration->setLogger($logger);
$client = Client::create($configuration);
```

### Resource references

[](#resource-references)

In some cases the API will return resource references in place of expanded resource objects. These references can be expanded by refreshing them.

```
$deposit = $this->client->getAccountDeposit($account, $depositId);
$transaction = $deposit->getTransaction();
if (!$transaction->isExpanded()) {
    $this->client->refreshTransaction($transaction);
}
```

You can also request that the API return an expanded resource in the initial request by using the `expand` parameter.

```
use Coinbase\Wallet\Enum\Param;

$deposit = $this->client->getAccountDeposit($account, $depositId, [
    Param::EXPAND = ['transaction'],
]);
```

Resource references can be used when creating new resources, avoiding the overhead of requesting a resource from the API.

```
use Coinbase\Wallet\Resource\Deposit;
use Coinbase\Wallet\Resource\PaymentMethod;

$deposit = new Deposit([
    'paymentMethod' => PaymentMethod::reference($paymentMethodId)
]);

// or use the convenience method
$deposit = new Deposit([
    'paymentMethodId' => $paymentMethodId
]);
```

### Responses

[](#responses)

There are multiple ways to access raw response data. First, each resource object has a `getRawData()` method which you can use to access any field that are not mapped to the object properties.

```
$data = $deposit->getRawData();
```

Raw data from the last HTTP response is also available on the client object.

```
$data = $client->decodeLastResponse();
```

### Active record methods

[](#active-record-methods)

The library includes support for active record methods on resource objects. You must enable this functionality when bootstrapping your application.

```
$client->enableActiveRecord();
```

Once enabled, you can call active record methods on resource objects.

```
use Coinbase\Wallet\Enum\Param;

$transactions = $account->getTransactions([
    Param::FETCH_ALL => true,
]);
```

Usage
-----

[](#usage)

This is not intended to provide complete documentation of the API. For more detail, please refer to the [official documentation](https://developers.coinbase.com/api/v2).

### [Market Data](https://developers.coinbase.com/api/v2#data-api)

[](#market-data)

**List supported native currencies**

```
$currencies = $client->getCurrencies();
```

**List exchange rates**

```
$rates = $client->getExchangeRates();
```

**Buy price**

```
$buyPrice = $client->getBuyPrice('BTC-USD');
```

**Sell price**

```
$sellPrice = $client->getSellPrice('BTC-USD');
```

**Spot price**

```
$spotPrice = $client->getSpotPrice('BTC-USD');
```

**Current server time**

```
$time = $client->getTime();
```

### [Users](https://developers.coinbase.com/api/v2#users)

[](#users)

**Get authorization info**

```
$auth = $client->getCurrentAuthorization();
```

**Lookup user info**

```
$user = $client->getUser($userId);
```

**Get current user**

```
$user = $client->getCurrentUser();
```

**Update current user**

```
$user->setName('New Name');
$client->updateCurrentUser($user);
```

### [Accounts](https://developers.coinbase.com/api/v2#accounts)

[](#accounts)

**List all accounts**

```
$accounts = $client->getAccounts();
```

**List account details**

```
$account = $client->getAccount($accountId);
```

**List primary account details**

```
$account = $client->getPrimaryAccount();
```

**Set account as primary**

```
$client->setPrimaryAccount($account);
```

**Create a new bitcoin account**

```
use Coinbase\Wallet\Resource\Account;

$account = new Account([
    'name' => 'New Account'
]);
$client->createAccount($account);
```

**Update an account**

```
$account->setName('New Account Name');
$client->updateAccount($account):
```

**Delete an account**

```
$client->deleteAccount($account);
```

### [Addresses](https://developers.coinbase.com/api/v2#addresses)

[](#addresses)

**List receive addresses for account**

```
$addresses = $client->getAccountAddresses($account);
```

**Get receive address info**

```
$address = $client->getAccountAddress($account, $addressId);
```

**List transactions for address**

```
$transactions = $client->getAddressTransactions($address);
```

**Create a new receive address**

```
use Coinbase\Wallet\Resource\Address;

$address = new Address([
    'name' => 'New Address'
]);
$client->createAccountAddress($account, $address);
```

### [Transactions](https://developers.coinbase.com/api/v2#transactions)

[](#transactions)

**List transactions**

```
$transactions = $client->getAccountTransactions($account);
```

**Get transaction info**

```
$transaction = $client->getAccountTransaction($account, $transactionId);
```

**Send funds**

```
use Coinbase\Wallet\Enum\CurrencyCode;
use Coinbase\Wallet\Resource\Transaction;
use Coinbase\Wallet\Value\Money;

$transaction = Transaction::send([
    'toBitcoinAddress' => 'ADDRESS',
    'amount'           => new Money(5, CurrencyCode::USD),
    'description'      => 'Your first bitcoin!',
    'fee'              => '0.0001' // only required for transactions under BTC0.0001
]);

try { $client->createAccountTransaction($account, $transaction); }
catch(Exception $e) {
     echo $e->getMessage();
}
```

**Transfer funds to a new account**

```
use Coinbase\Wallet\Resource\Transaction;
use Coinbase\Wallet\Resource\Account;

$fromAccount = Account::reference($accountId);

$toAccount = new Account([
    'name' => 'New Account'
]);
$client->createAccount($toAccount);

$transaction = Transaction::transfer([
    'to'            => $toAccount,
    'bitcoinAmount' => 1,
    'description'   => 'Your first bitcoin!'
]);

$client->createAccountTransaction($fromAccount, $transaction);
```

**Request funds**

```
use Coinbase\Wallet\Enum\CurrencyCode;
use Coinbase\Wallet\Resource\Transaction;
use Coinbase\Wallet\Value\Money;

$transaction = Transaction::request([
    'amount'      => new Money(8, CurrencyCode::USD),
    'description' => 'Burrito'
]);

$client->createAccountTransaction($transaction);
```

**Resend request**

```
$account->resendTransaction($transaction);
```

**Cancel request**

```
$account->cancelTransaction($transaction);
```

**Fulfill request**

```
$account->completeTransaction($transaction);
```

### [Buys](https://developers.coinbase.com/api/v2#buys)

[](#buys)

**List buys**

```
$buys = $client->getAccountBuys($account);
```

**Get buy info**

```
$buy = $client->getAccountBuy($account, $buyId);
```

**Buy bitcoins**

```
use Coinbase\Wallet\Resource\Buy;

$buy = new Buy([
    'bitcoinAmount' => 1
]);

$client->createAccountBuy($account, $buy);
```

**Commit a buy**

You only need to do this if you pass `commit=false` when you create the buy.

```
use Coinbase\Wallet\Enum\Param;

$client->createAccountBuy($account, $buy, [Param::COMMIT => false]);
$client->commitBuy($buy);
```

### [Sells](https://developers.coinbase.com/api/v2#sells)

[](#sells)

**Get sell info**

```
$sell = $client->getAccountSell($account, $sellId);
```

**Sell bitcoins**

```
use Coinbase\Wallet\Resource\Sell;

$sell = new Sell([
    'bitcoinAmount' => 1
]);

$client->createAccountSell($account, $sell);
```

**Commit a sell**

You only need to do this if you pass `commit=false` when you create the sell.

```
use Coinbase\Wallet\Enum\Param;

$client->createAccountSell($account, $sell, [Param::COMMIT => false]);
$client->commitSell($sell);
```

### [Deposit](https://developers.coinbase.com/api/v2#deposits)

[](#deposit)

**List deposits**

```
$deposits = $client->getAccountDeposits($account);
```

**Get deposit info**

```
$deposit = $client->getAccountDeposit($account, $depositId);
```

**Deposit funds**

```
use Coinbase\Wallet\Enum\CurrencyCode;
use Coinbase\Wallet\Resource\Deposit;
use Coinbase\Wallet\Value\Money;

$deposit = new Deposit([
    'amount' => new Money(10, CurrencyCode::USD)
]);

$client->createAccountDeposit($account, $deposit);
```

**Commit a deposit**

You only need to do this if you pass `commit=false` when you create the deposit.

```
use Coinbase\Wallet\Enum\Param;

$client->createAccountDeposit($account, $deposit, [Param::COMMIT => false]);
$client->commitDeposit($deposit);
```

### [Withdrawals](https://developers.coinbase.com/api/v2#withdrawals)

[](#withdrawals)

**List withdrawals**

```
$withdrawals = $client->getAccountWithdrawals($account);
```

**Get withdrawal**

```
$withdrawal = $client->getAccountWithdrawal($account, $withdrawalId);
```

**Withdraw funds**

```
use Coinbase\Wallet\Enum\CurrencyCode;
use Coinbase\Wallet\Resource\Withdrawal;
use Coinbase\Wallet\Value\Money;

$withdrawal = new Withdrawal([
    'amount' => new Money(10, CurrencyCode::USD)
]);

$client->createAccountWithdrawal($account, $withdrawal);
```

**Commit a withdrawal**

You only need to do this if you pass `commit=true` when you call the withdrawal method.

```
use Coinbase\Wallet\Enum\Param;

$client->createAccountWithdrawal($account, $withdrawal, [Param::COMMIT => false]);
$client->commitWithdrawal($withdrawal);
```

### [Payment Methods](https://developers.coinbase.com/api/v2#payment-methods)

[](#payment-methods)

**List payment methods**

```
$paymentMethods = $client->getPaymentMethods();
```

**Get payment method**

```
$paymentMethod = $client->getPaymentMethod($paymentMethodId);
```

Contributing and testing
------------------------

[](#contributing-and-testing)

The test suite is built using PHPUnit. Run the suite of unit tests by running the `phpunit` command.

```
phpunit

```

There is also a collection of integration tests that issues real requests to the API and inspects the resulting objects. To run these tests, you must copy `phpunit.xml.dist` to `phpunit.xml`, provide values for the `CB_API_KEY` and `CB_API_SECRET` variables, and specify the `integration` group when running the test suite.

```
phpunit --group integration

```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor3

3 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~190 days

Recently: every ~341 days

Total

13

Last Release

1652d ago

PHP version history (3 changes)v2.0.0PHP &gt;=5.5.0

2.7.0PHP &gt;=5.6.0

v2.9.0PHP &gt;=7.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/bf38d9675a95dfdd8b4b401459be6ef7c0342ea40359f23772a0c3ad2feae12b?d=identicon)[neto737](/maintainers/neto737)

---

Top Contributors

[![aianus](https://avatars.githubusercontent.com/u/1322087?v=4)](https://github.com/aianus "aianus (34 commits)")[![sds](https://avatars.githubusercontent.com/u/677877?v=4)](https://github.com/sds "sds (15 commits)")[![neto737](https://avatars.githubusercontent.com/u/2430438?v=4)](https://github.com/neto737 "neto737 (14 commits)")[![marchrius](https://avatars.githubusercontent.com/u/534837?v=4)](https://github.com/marchrius "marchrius (10 commits)")[![jorilallo](https://avatars.githubusercontent.com/u/31465?v=4)](https://github.com/jorilallo "jorilallo (7 commits)")[![kriswallsmith](https://avatars.githubusercontent.com/u/33886?v=4)](https://github.com/kriswallsmith "kriswallsmith (7 commits)")[![KAMAELUA](https://avatars.githubusercontent.com/u/3611515?v=4)](https://github.com/KAMAELUA "KAMAELUA (3 commits)")[![gbutiri](https://avatars.githubusercontent.com/u/6015141?v=4)](https://github.com/gbutiri "gbutiri (3 commits)")[![codermarcel](https://avatars.githubusercontent.com/u/12887835?v=4)](https://github.com/codermarcel "codermarcel (2 commits)")[![jimbursch](https://avatars.githubusercontent.com/u/7603814?v=4)](https://github.com/jimbursch "jimbursch (2 commits)")[![jborseth](https://avatars.githubusercontent.com/u/68551817?v=4)](https://github.com/jborseth "jborseth (1 commits)")[![DavidLiedle](https://avatars.githubusercontent.com/u/126598?v=4)](https://github.com/DavidLiedle "DavidLiedle (1 commits)")[![jsgv](https://avatars.githubusercontent.com/u/2798097?v=4)](https://github.com/jsgv "jsgv (1 commits)")[![StefanYohansson](https://avatars.githubusercontent.com/u/1783252?v=4)](https://github.com/StefanYohansson "StefanYohansson (1 commits)")[![luiz-brandao](https://avatars.githubusercontent.com/u/704231?v=4)](https://github.com/luiz-brandao "luiz-brandao (1 commits)")[![comeacoder](https://avatars.githubusercontent.com/u/1582623?v=4)](https://github.com/comeacoder "comeacoder (1 commits)")[![noplanman](https://avatars.githubusercontent.com/u/9423417?v=4)](https://github.com/noplanman "noplanman (1 commits)")[![renapoliveira](https://avatars.githubusercontent.com/u/771063?v=4)](https://github.com/renapoliveira "renapoliveira (1 commits)")[![chrisshennan](https://avatars.githubusercontent.com/u/1922601?v=4)](https://github.com/chrisshennan "chrisshennan (1 commits)")[![sh6khan](https://avatars.githubusercontent.com/u/6743784?v=4)](https://github.com/sh6khan "sh6khan (1 commits)")

---

Tags

bitcoincoinbase

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/neto737-coinbase/health.svg)

```
[![Health](https://phpackages.com/badges/neto737-coinbase/health.svg)](https://phpackages.com/packages/neto737-coinbase)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[coinbase/coinbase-commerce

Coinbase Commerce API library

148275.7k2](/packages/coinbase-coinbase-commerce)[commercetools/commercetools-sdk

The official PHP SDK for the commercetools Composable Commerce APIs

19281.5k](/packages/commercetools-commercetools-sdk)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[bushlanov-dev/max-bot-api-client-php

Max Bot API Client library

281.6k](/packages/bushlanov-dev-max-bot-api-client-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
