PHPackages                             currency-cloud/client - 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. currency-cloud/client

ActiveLibrary[API Development](/categories/api)

currency-cloud/client
=====================

A PHP library which implements the complete functionality of v2 of the The Currency Cloud API.

v6.4.0(2mo ago)17327.2k↓15.4%40[6 issues](https://github.com/CurrencyCloud/currencycloud-php/issues)MITPHPPHP &gt;=7.2

Since Nov 10Pushed 2mo ago42 watchersCompare

[ Source](https://github.com/CurrencyCloud/currencycloud-php)[ Packagist](https://packagist.org/packages/currency-cloud/client)[ Docs](https://github.com/CurrencyCloud/currencycloud-php)[ RSS](/packages/currency-cloud-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (125)Used By (0)

[![packagist](https://camo.githubusercontent.com/6b627ed1f3ecf699d27dcc99977965d26c6a8b2ea28d1a2853769e8bb9a894b6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63757272656e63792d636c6f75642f636c69656e74)](https://camo.githubusercontent.com/6b627ed1f3ecf699d27dcc99977965d26c6a8b2ea28d1a2853769e8bb9a894b6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63757272656e63792d636c6f75642f636c69656e74)

Currencycloud API v2 PHP client
===============================

[](#currencycloud-api-v2-php-client)

Version: 6.4.0
--------------

[](#version-640)

This is the official PHP SDK for the Currencycloud API. Additional documentation for each API endpoint can be found at [developer.currencycloud.com](https://developer.currencycloud.com/guides/getting-started/introduction/).

If you have any queries or you require support, please contact our development team at . Please quote your login id in any correspondence as this makes it simpler for us to locate your account and give you the support you need.

Prerequisites
-------------

[](#prerequisites)

### Composer (optional, but highly recommended)

[](#composer-optional-but-highly-recommended)

CurrencyCloud-PHP is a Composer project. While using Composer is not strictly required, it will be far easier to simply make use of Composer to do the dependency management and autoloading for you.

### Supported PHP version

[](#supported-php-version)

This library aims to support and is tested against PHP 7.4 and PHP 8.0.

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

[](#installation)

The recommended way to install Currencycloud SDK is through [Composer](http://getcomposer.org).

If you do not have composer installed check [Composer installation guide](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx).

Assuming you have composer installed globally you can require Currencycloud SDK into you project by executing:

```
composer require currency-cloud/client
```

After installing, you need to require Composer's autoloader if you did not require it before:

```
require 'vendor/autoload.php';
```

Usage
=====

[](#usage)

You can register for demo API key at [developer.currencycloud.com](https://developer.currencycloud.com/register-for-an-api-key/).

An example in PHP 7:

```
use CurrencyCloud\CurrencyCloud;
use CurrencyCloud\Session;

require_once __DIR__ . '/vendor/autoload.php';

$session = new Session(
    Session::ENVIRONMENT_DEMONSTRATION,
    '',
    ''
);

$client = CurrencyCloud::createDefault($session);

//Authenticate
$client->authenticate()
    ->login();

//Get available currencies
$currencies =
    $client->reference()
        ->availableCurrencies();

echo "Supported currencies:\n";

foreach ($currencies as $currency) {
    printf(
        "Currency: %s; Code: %s; Decimal places: %d\n",
        $currency->getName(),
        $currency->getCode(),
        $currency->getDecimalPlaces()
    );
}

echo "Balances:\n";

//Find balances
$balances =
    $client->balances()
        ->find();

foreach ($balances->getBalances() as $balance) {
    printf(
        "Balance ID: %s; Currency: %s; Amount: %s\n",
        $balance->getId(),
        $balance->getCurrency(),
        $balance->getAmount()
    );
}

//Close session
$client->authenticate()->close();
```

For a slightly longer example, see [cook-book.php](/examples/cook-book.php).

Common Patterns
---------------

[](#common-patterns)

### Reusing client for multiple requests

[](#reusing-client-for-multiple-requests)

Authentication tokens are long-lived and are meant to be reused for multiple requests. This will improve performance of calls through the api.

On Behalf Of
------------

[](#on-behalf-of)

If you want to make calls on behalf of another user (e.g. someone who is your end-client), you can execute certain commands 'on behalf of' the user's contact id. Here is an example:

```
$client->onBehalfOf('c6ece846-6df1-461d-acaa-b42a6aa74045', function (CurrencyCloud $client) {
    $balances =
        $client->balances()
            ->find();

    foreach ($balances->getBalances() as $balance) {
        printf(
            "Balance ID: %s; Currency: %s; Amount: %s\n",
            $balance->getId(),
            $balance->getCurrency(),
            $balance->getAmount()
        );
    }
});
```

Each of the above transactions will be executed in scope of the limits for that contact and linked to that contact. Note that the real user who executed the transaction will also be stored.

Errors
------

[](#errors)

When an error occurs in the API, the library aims to give us much information as possible. A `CurrencyCloudException` will be thrown that contains much useful information that you can access via its methods. When the exception converted to string, it will provide information such as the following:

```
BadRequestException
---
platform: 'PHP 7.1.11-1+deb.sury.org~trusty+1'
request:
    parameters: {  }
    verb: get
    url: 'https://devapi.currencycloud.com/v2/rates/detailed?buy_currency=EUR&sell_currency=GBP&fixed_side=buy&amount=10000.00'
response:
    status_code: 400
    date: 'Tue, 13 Nov 2018 13:40:00 GMT'
    request_id: '2915002181730358306'
errors:
    -
        field: base
        code: rate_could_not_be_retrieved
        message: 'Rate could not be retrieved'
        params: {  }
```

This is split into 5 sections:

1. Error Type: In this case `BadRequestException` represents an HTTP 400 error
2. Platform: The PHP implementation that was used in the client
3. Request: Details about the HTTP request that was made, e.g. the POST parameters
4. Response: Details about the HTTP response that was returned, e.g. HTTP status code
5. Errors: A list of errors that provide additional information

The final section contains valuable information:

- Field: The parameter that the error is linked to
- Code: A code representing this error
- Message: A human readable message that explains the error
- Params: A map that contains dynamic parts of the error message for building custom error messages

When troubleshooting API calls with Currencycloud support, including the full error in any correspondence can be very helpful.

Development
===========

[](#development)

Testing
-------

[](#testing)

Test cases can be run with `vendor/bin/phpunit`.

Dependencies
------------

[](#dependencies)

- [Guzzle](https://github.com/guzzle/guzzle)
- [Symfony YAML](https://github.com/symfony/yaml)
- [Symfony event dispatcher](https://github.com/symfony/event-dispatcher)

Contributing
============

[](#contributing)

**We welcome pull requests from everyone!** Please see [CONTRIBUTING](CONTRIBUTING.md). Our sincere thanks for [helping us](HALL_OF_FAME.md) create the best API for moving money anywhere around the world!

Versioning
==========

[](#versioning)

This project uses [semantic versioning](http://semver.org/). You can safely express a dependency on a major version and expect all minor and patch versions to be backwards compatible.

Deprecation Policy
------------------

[](#deprecation-policy)

Technology evolves quickly and we are always looking for better ways to serve our customers. From time to time we need to make room for innovation by removing sections of code that are no longer necessary. We understand this can be disruptive and consequently we have designed a Deprecation Policy that protects our customers' investment and that allows us to take advantage of modern tools, frameworks and practices in developing software.

Deprecation means that we discourage the use of a feature, design or practice because it has been superseded or is no longer considered efficient or safe but instead of removing it immediately, we mark it as **@deprecated** to provide backwards compatibility and time for you to update your projects. While the deprecated feature remains in the SDK for a period of time, we advise that you replace it with the recommended alternative which is explained in the relevant section of the code.

We remove deprecated features after **three months** from the time of announcement.

The security of our customers' assets is of paramount importance to us and sometimes we have to deprecate features because they may pose a security threat or because new, more secure, ways are available. On such occasions we reserve the right to set a different deprecation period which may range from **immediate removal** to the standard **three months**.

Once a feature has been marked as deprecated, we no longer develop the code or implement bug fixes. We only do security fixes.

### List of features being deprecated

[](#list-of-features-being-deprecated)

```

```

Support
=======

[](#support)

We actively support the latest version of the SDK. We support the immediate previous version on best-efforts basis. All other versions are no longer supported nor maintained.

Security Consideration
======================

[](#security-consideration)

1. Authentication
    1. All data under [this folder](tests/VCR) provide and return dummy credentials to verify that authentication workflows behave as expected.

Copyright
=========

[](#copyright)

Copyright (c) 2015-2021 Currencycloud. See [LICENSE](LICENSE.md) for details.

###  Health Score

61

—

FairBetter than 99% of packages

Maintenance79

Regular maintenance activity

Popularity47

Moderate usage in the ecosystem

Community32

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor2

2 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 ~77 days

Recently: every ~21 days

Total

50

Last Release

67d ago

Major Versions

v1.11.2 → v2.0.12020-12-02

v2.2.1 → v3.0.02021-08-18

v3.10.1 → v4.0.02025-05-28

v4.1.0 → v5.0.02025-10-01

v5.1.0 → v6.0.02025-12-17

PHP version history (3 changes)v0.7.0PHP &gt;=5.5

v1.0.1PHP &gt;=7.1

v3.0.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/68c3cc4b630a6e178b0f6783cc571c9920bf4dd732f7b5abcbe89b7be1cc2236?d=identicon)[currencycloud](/maintainers/currencycloud)

![](https://www.gravatar.com/avatar/ba59b44938f9c8e155d6e2c096bccb4d4995314691b1ff8f110ab62e73c4df07?d=identicon)[sclinton\_visa](/maintainers/sclinton_visa)

---

Top Contributors

[![cpacalevcc](https://avatars.githubusercontent.com/u/43750647?v=4)](https://github.com/cpacalevcc "cpacalevcc (143 commits)")[![jonathancouchman](https://avatars.githubusercontent.com/u/44161978?v=4)](https://github.com/jonathancouchman "jonathancouchman (142 commits)")[![zlikavac32](https://avatars.githubusercontent.com/u/1078270?v=4)](https://github.com/zlikavac32 "zlikavac32 (100 commits)")[![EAddario](https://avatars.githubusercontent.com/u/29247825?v=4)](https://github.com/EAddario "EAddario (28 commits)")[![francescobbo](https://avatars.githubusercontent.com/u/854304?v=4)](https://github.com/francescobbo "francescobbo (13 commits)")[![libsdk-gh](https://avatars.githubusercontent.com/u/200106417?v=4)](https://github.com/libsdk-gh "libsdk-gh (10 commits)")[![korki](https://avatars.githubusercontent.com/u/27666?v=4)](https://github.com/korki "korki (7 commits)")[![ollieza](https://avatars.githubusercontent.com/u/288799?v=4)](https://github.com/ollieza "ollieza (4 commits)")[![falconetpt](https://avatars.githubusercontent.com/u/18429692?v=4)](https://github.com/falconetpt "falconetpt (4 commits)")[![liamm](https://avatars.githubusercontent.com/u/201030?v=4)](https://github.com/liamm "liamm (4 commits)")[![arjanwestdorp](https://avatars.githubusercontent.com/u/7716654?v=4)](https://github.com/arjanwestdorp "arjanwestdorp (3 commits)")[![borilyordanov](https://avatars.githubusercontent.com/u/11679283?v=4)](https://github.com/borilyordanov "borilyordanov (3 commits)")[![derikvercueil](https://avatars.githubusercontent.com/u/32518774?v=4)](https://github.com/derikvercueil "derikvercueil (3 commits)")[![rjnienaber](https://avatars.githubusercontent.com/u/521795?v=4)](https://github.com/rjnienaber "rjnienaber (2 commits)")[![gergelykovacs](https://avatars.githubusercontent.com/u/7645879?v=4)](https://github.com/gergelykovacs "gergelykovacs (2 commits)")[![codoffer](https://avatars.githubusercontent.com/u/16318845?v=4)](https://github.com/codoffer "codoffer (1 commits)")[![Lizzie88](https://avatars.githubusercontent.com/u/18439600?v=4)](https://github.com/Lizzie88 "Lizzie88 (1 commits)")[![niall-logue](https://avatars.githubusercontent.com/u/177738336?v=4)](https://github.com/niall-logue "niall-logue (1 commits)")[![CNimmo16](https://avatars.githubusercontent.com/u/48329714?v=4)](https://github.com/CNimmo16 "CNimmo16 (1 commits)")[![pedro-bruno-cc](https://avatars.githubusercontent.com/u/115085326?v=4)](https://github.com/pedro-bruno-cc "pedro-bruno-cc (1 commits)")

---

Tags

currencycloud

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/currency-cloud-client/health.svg)

```
[![Health](https://phpackages.com/badges/currency-cloud-client/health.svg)](https://phpackages.com/packages/currency-cloud-client)
```

###  Alternatives

[sylius/sylius

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

8.4k5.6M651](/packages/sylius-sylius)[statamic/cms

The Statamic CMS Core Package

4.8k3.2M720](/packages/statamic-cms)[alibabacloud/client

Alibaba Cloud Client for PHP - Use Alibaba Cloud in your PHP project

2223.5M367](/packages/alibabacloud-client)[jordikroon/google-vision

Google Vision Api for PHP (https://cloud.google.com/vision/)

6374.9k1](/packages/jordikroon-google-vision)[rustici-software/scormcloud-api-v2-client-php

20253.2k](/packages/rustici-software-scormcloud-api-v2-client-php)[otherguy/php-currency-api

A PHP API Wrapper to offer a unified programming interface for popular Currency Rate APIs.

2526.2k](/packages/otherguy-php-currency-api)

PHPackages © 2026

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