PHPackages                             buttercoin/buttercoin-sdk - 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. buttercoin/buttercoin-sdk

ActiveLibrary[API Development](/categories/api)

buttercoin/buttercoin-sdk
=========================

A PHP library for connecting to the Buttercoin API

0.0.6(11y ago)1153MITPHPPHP &gt;=5.3.3

Since Jul 16Pushed 11y ago1 watchersCompare

[ Source](https://github.com/buttercoin/buttercoinsdk-php)[ Packagist](https://packagist.org/packages/buttercoin/buttercoin-sdk)[ Docs](http://www.buttercoin.com)[ RSS](/packages/buttercoin-buttercoin-sdk/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (2)Versions (7)Used By (0)

Buttercoin PHP SDK Library
==========================

[](#buttercoin-php-sdk-library)

Easy integration with the Buttercoin Trading Platform through our API.

Installation with Composer
--------------------------

[](#installation-with-composer)

```
$ php composer.phar require buttercoin/buttercoin-sdk:~0.0.6
```

Usage
-----

[](#usage)

For composer documentation, please refer to [getcomposer.org](http://getcomposer.org/).

This client was built using [Guzzle](http://guzzlephp.org/), a PHP HTTP client &amp; framework for building RESTful web service clients.

When you first create a new `ButtercoinClient` instance you can pass `publicKey`, `privateKey`, and `environment` as configuration settings. These are optional and can be later specified through Setter methods.

For authenticated API Resources, the `publicKey` and `secretKey` are required and can also be passed to the factory method in the configuration array. The `environment` configuration setting defaults to `'production'`.

For a list of required and available parameters for the different API Endpoints, please consult the Buttercoin [API Reference Docs](https://developer.buttercoin.com).

#### Configuring the Client

[](#configuring-the-client)

The factory method accepts an array of configuration settings for the Buttercoin Webservice Client.

SettingProperty NameDescriptionPublic Key`publicKey`Your Buttercoin API Public KeySecret Key`secretKey`Your Buttercoin API Secret KeyEnvironment`environment`Your development environment (default: `'production'`, set to `'sandbox'` to test with testnet bitcoins)API Version`version`The API Version. Currently used to version the API URL and Service Description###### Example

[](#example)

```
require 'vendor/autoload.php';
use Buttercoin\Client\ButtercoinClient;
date_default_timezone_set('UTC'); // for $timestamp

$client = ButtercoinClient::factory([
	'publicKey' => '',
	'secretKey' => '',
	'environment' => 'sandbox' // leave this blank for production
]);
```

#### Configuration can be updated to reuse the same Client:

[](#configuration-can-be-updated-to-reuse-the-same-client)

You can reconfigure the Buttercoin Client configuration options through available getters and setters. You can get and set the following options: `publicKey`, `secretKey`, `environment`, &amp; `version`

###### Example

[](#example-1)

```
$client->getSecretKey();
$client->setSecretKey('');
```

**Tips**

A note on the `timestamp` param sent to all client methods: This param must always be increasing, and within 5 minutes of Buttercoin server times (GMT). This is to prevent replay attacks on your data.

Before every call, get a new timestamp. (You need only set the timezone once)

```
date_default_timezone_set('UTC'); // Do this only once
$timestamp = round(microtime(true) * 1000);
$client->getKey($timestamp);
```

Additionally, for convenience, if you don't include the timestamp parameter, it will default to the current timestamp.

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

**WARNING**

For Query and Post Params, there is a limitation from the Guzzle library that you always add the params to your array in the order they are displayed in tables below. If you don't do this, the HMAC-SHA256 signature will not be correct and you will get a `401` request error.

### Get Data

[](#get-data)

###### Unauthenticated

[](#unauthenticated)

**Get Order Book**
Return an `array` of current orders in the Buttercoin order book

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

**Get Trade History**
Return an `array` of the last 100 trades

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

**Get Ticker**
Return the current bid, ask, and last sell prices on the Buttercoin platform

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

###### Authenticated

[](#authenticated)

**Key Permissions**
Returns `array` of permissions associated with this key

```
$client->getKey($timestamp);
```

**Balances**
Returns `array` of balances for this account

```
$client->getBalances($timestamp);
```

**Deposit Address**
Returns bitcoin address `string` to deposit your funds into the Buttercoin platform

```
$client->getDepositAddress($timestamp);
```

**Get Orders**
Returns `array` of `arrays` containing information about buy and sell orders

Valid params include (must be added to array in this order):

NameParamDescriptionStatus`status`enum: `['opened', 'partial-filled', 'filled', 'canceled']`Side`side`enum: `['buy', 'sell']`Order Type`orderType`enum: `['market', 'limit']`Date Min`dateMin`format: ISO-8601, e.g. `'2014-05-06T13:15:30Z'`Date Max`dateMax`format: ISO-8601, e.g. `'2014-05-06T13:15:30Z'````
// query for multiple orders
$orderParams = [ "status" => "canceled", "side" => "sell" ];

$client->getOrders($orderParams, $timestamp);

// single order by id
$orderId = '';

$client->getOrderById($orderId, $timestamp);

// single order by url
$url = 'https://api.buttercoin.com/v1/orders/{order_id}';

$client->getOrderByUrl($url, $timestamp);
```

**Get Transaction**
Returns `array` of `arrays` containing information about deposit and withdraw action

Valid params include (must be added to array in this order):

NameParamDescriptionStatus`status`enum: `['pending', 'processing', 'funded', 'canceled', 'failed']`Transaction Type`transactionType`enum: `['deposit', 'withdrawal']`Date Min`dateMin`format: ISO-8601, e.g. `'2014-05-06T13:15:30Z'`Date Max`dateMax`format: ISO-8601, e.g. `'2014-05-06T13:15:30Z'````
// query for multiple transactions
$trxnParams = [ "status" => "funded", "transactionType" => "deposit" ];

$client->getTransactions($trxnParams, $timestamp);

$trxnId = '53a22ce164f23e7301a4fee5';

$client->getTransactionById($trxnId, $timestamp);

// single transaction by url
$url = 'https://api.buttercoin.com/v1/transactions/{transaction_id}';

$client->getTransactionByUrl($url, $timestamp);
```

### Create New Actions

[](#create-new-actions)

**Create Order**

Valid order params include:

NameParamDescriptionInstrument`instrument`enum: `['BTC_USD, USD_BTC']`Side`side`enum: `['buy', 'sell']`, required `true`Order Type`orderType`enum: `['limit', 'market']`, required `true`Price`price``string`, required `false`Quantity`quantity``string`, required `false````
// create an array with the following params
$order = [
  "instrument" => "BTC_USD",
  "side" => "buy",
  "orderType" => "limit",
  "price" => "700.00"
  "quantity" => "5"
];

$client->createOrder($order, $timestamp);
```

**Create Transaction**

*Please contact Buttercoin support before creating a USD deposit using the API*

Deposit transaction params include:

NameParamDescriptionMethod`method`enum: `['wire']`, required `true`Currency`currency`enum: `['USD']`, required `true`Amount`amount``string`, required `true````
// create deposit
$trxnObj = [
  "method" => "wire",
  "currency" => "USD",
  "amount" => "5002"
];

$client->createDeposit($trxnObj, $timestamp);
```

Withdrawal transaction params include:

NameParamDescriptionMethod`method`enum: `['check']`, required `true`Currency`currency`enum: `['USD']`, required `true`Amount`amount``string`, required `true````
// create withdrawal
$trxnObj = [
  "method" => "check",
  "currency" => "USD",
  "amount" => "900.23"
];

$client->createWithdrawal($trxnObj, $timestamp);
```

Send bitcoin transaction params include:

NameParamDescriptionCurrency`currency``['USD']`, required `true`Amount`amount``string`, required `true`Destination`destination`address to which to send currency `string`, required `true````
// send bitcoins to an address
$trxnObj = [
  "currency" => "BTC",
  "amount" => "100.231231",
  "destination" => ""
];

$client->sendCrypto($trxnObj, $timestamp);
```

### Cancel Actions

[](#cancel-actions)

All successful cancel calls to the API return a response status of `204` with a human readable success message

**Cancel Order**
Cancel a pending buy or sell order

```
$client->cancelOrder($orderId, $timestamp);
```

**Cancel Transaction**
Cancel a pending deposit or withdraw action

```
$client->cancelTransaction($trxnId, $timestamp);
```

Further Reading
---------------

[](#further-reading)

[Buttercoin - Website](https://www.buttercoin.com)
[Buttercoin API Docs](https://developer.buttercoin.com)

Contributing
------------

[](#contributing)

This is an open source project and we love involvement from the community! Hit us up with pull requests and issues.

The aim is to take your great ideas and make everyone's experience using Buttercoin even more powerful. The more contributions the better!

Release History
---------------

[](#release-history)

### 0.0.6

[](#006)

- added trade history endpoint

### 0.0.5

[](#005)

- changed test env to sandbox

### 0.0.3

[](#003)

- changed withdraw endpoint from /withdrawal to /withdraw

### 0.0.2

[](#002)

- Made timestamp an optional field, defaults to current timestamp
- Fixed errors in README file

### 0.0.1

[](#001)

- First release.

License
-------

[](#license)

Licensed under the MIT license.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~16 days

Total

6

Last Release

4286d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e0a05b18062341536d28e583d9b7e2299c71babf3c680f5435402e46a50c1fa4?d=identicon)[kevin-buttercoin](/maintainers/kevin-buttercoin)

---

Top Contributors

[![kevin-buttercoin](https://avatars.githubusercontent.com/u/4991153?v=4)](https://github.com/kevin-buttercoin "kevin-buttercoin (27 commits)")

---

Tags

bitcoinbtccryptocurrencytradingbuttercoin

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/buttercoin-buttercoin-sdk/health.svg)

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

###  Alternatives

[ccxt/ccxt

A cryptocurrency trading API with more than 100 exchanges in JavaScript / TypeScript / Python / C# / PHP / Go

43.2k341.0k1](/packages/ccxt-ccxt)[coinpaymentsnet/coinpayments-php

A PHP wrapper for the CoinPayments.net v1 API.

56130.1k](/packages/coinpaymentsnet-coinpayments-php)[kornrunner/ccxt

A PHP cryptocurrency trading library with support for more than 90 bitcoin/altcoin exchanges

371.6k](/packages/kornrunner-ccxt)

PHPackages © 2026

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