PHPackages                             xrplwin/xrpl - 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. xrplwin/xrpl

ActiveLibrary[API Development](/categories/api)

xrplwin/xrpl
============

A PHP package for communication with the XRP Ledger.

v1.2.1(2w ago)32.5k1[2 issues](https://github.com/XRPLWin/XRPL/issues)4MITPHPPHP ^8.1.0CI passing

Since Aug 22Pushed 1mo agoCompare

[ Source](https://github.com/XRPLWin/XRPL)[ Packagist](https://packagist.org/packages/xrplwin/xrpl)[ Docs](https://github.com/XRPLWin)[ GitHub Sponsors](https://github.com/zgrguric)[ RSS](/packages/xrplwin-xrpl/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (20)Versions (51)Used By (4)

[![main workflow](https://github.com/XRPLWin/XRPL/actions/workflows/main.yml/badge.svg)](https://github.com/XRPLWin/XRPL/actions/workflows/main.yml/badge.svg)[![GitHub license](https://camo.githubusercontent.com/3efff8fa0259af65a00ec0549d281296b2c10e09a2c6a0d7f2563705d26878b1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f5852504c57696e2f5852504c)](https://github.com/XRPLWin/XRPL/blob/main/LICENSE)[![Total Downloads](https://camo.githubusercontent.com/c58f5538d321dfd0fc4f003a9093155d8ae113a5a3451e438f762d12a6bec6dc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7872706c77696e2f7872706c2e7376673f7374796c653d666c6174)](https://packagist.org/packages/xrplwin/xrpl)

PHP XRPL API Connector
======================

[](#php-xrpl-api-connector)

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- [Composer](https://getcomposer.org/)

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

[](#installation)

```
composer require xrplwin/xrpl

```

Usage sample
------------

[](#usage-sample)

In sample below we will be using account\_tx method.

### Init Client

[](#init-client)

```
$client = new \XRPLWin\XRPL\Client([
    # Following values are defined by default, uncomment to override
    //'endpoint_reporting_uri' => 'http://s1.ripple.com:51234',
    //'endpoint_fullhistory_uri' => 'https://xrplcluster.com'
]);
```

### Creating first request

[](#creating-first-request)

```
# Create new 'account_tx' method instance
$account_tx = $client->api('account_tx')->params([
    'account' => 'rAccount...',
    'limit' => 10
]);
```

This will return an instance of `XRPLWin\XRPL\Api\Methods\AccountTx`.

### Custom rate limit handling

[](#custom-rate-limit-handling)

If you wish to define custom behaviour when request is rate-limited you can via `Closure` function. Define this before executing `send()`.

```
//(optional) Override default cooldown seconds (default is 5 seconds)
$account_tx->setCooldownSeconds(10);
//(optional) Override default number of tries when request is rate-limited (default is 3)
$account_tx->setTries(5);
//(optional) Set http timeout to 3 seconds (default is 0 - eg no timeout)
//           After 3 seconds method will throw \XRPLWin\XRPL\Exceptions\BadRequestException on timeout
$account_tx->setTimeout(3);

//(optional) Define custom cooldown callback
$account_tx->setCooldownHandler(
    /**
     * @param int $current_try Current try 1 to max
     * @param int $default_cooldown_seconds Predefined cooldown seconds
     * @return void|boolean return false to stop process
     */
    function(int $current_try, int $default_cooldown_seconds) {
        //Sample usage: calculate how much sleep() is needed depending on
        $sec = $default_cooldown_seconds * $current_try;
        if($sec > 15) return false; //force stop
        sleep($sec);
    }
);
```

### Fetching response

[](#fetching-response)

```
# Send request to Ledger
try {
    $account_tx->send();
} catch (\XRPLWin\XRPL\Exceptions\XWException $e) {
    // Handle errors
    throw $e;
}

if(!$account_tx->isSuccess()) {
    //XRPL response is returned but field result.status did not return 'success'
}

# Get fetched response as array
$response       = $account_tx->resultArray(); //array response from ledger
# Get fetched response as object
$response       = $account_tx->result();      //object response from ledger
# Get fetched final result from helper (varies method to method)
$transactions   = $account_tx->finalResult(); //array of transactions
```

Class method `send()` executes request against XRPLedger and response is stored into instance object. After that you can use one of provided class methods to retrieve result.

### Promises

[](#promises)

Alternative to fetch syncronous response as defined above, you can get `Promise`
[Read more](https://github.com/guzzle/promises) about Promises. Returned object is [Promises/A+](https://promisesaplus.com/) implementation.

```
$promise = $account_tx->requestAsync();

$promises = [
    'rAcct1' => $promise,
    //...more promises
];

// Wait for the requests to complete
// Throws a ConnectException if any of the requests fail
$responses = \GuzzleHttp\Promise\Utils::unwrap($promises);

//Fill response data back into $account_tx instance
$account_tx->fill($responses['rAcct1']);

//...
$transactions = $account_tx->finalResult();
```

*Notes*: You will need to handle rate limiting and exception handling yourself when using Promises. Also each promise must be created from new instance of `\XRPLWin\XRPL\Client` this is to make sure each promise has its own seperated HttpClient instance.

### Paginating result

[](#paginating-result)

```
# Check if there is next page
//$has_next_page = $account_tx->hasNextPage(); //bool

# Fetch next page of transactions if there is next page (next() does not return null)
if($next_account_tx = $account_tx->next()) {
    $next_result = $next_account_tx->send()->finalResult();
    // ...
}
```

To quick retrieve next instance to be executed (next page) you can use `next()`. This class method will return instance of `XRPLWin\XRPL\Api\Methods\AccountTx` with same parameters plus added marker from previous request. This helper function is not mandatory, you can always create new method instance manually like this `$client->api('account_tx')->params([ ..., ['marker'] => [ ... ]]`.

See [samples](samples/paginating.php) for more information.

Request workflow
----------------

[](#request-workflow)

1. Prepare instance by setting params
2. Use send() to execute request and handle errors by using try catch. (Request will be re-tried x amount of times if rate-limit is detected)
3. XRPLedger response is stored in memory and it is available to read via
    `->result()`
    `->resultArray()`
    `->finalResult()`

Methods
-------

[](#methods)

### account\_tx

[](#account_tx)

```
$account_tx = $client->api('account_tx')->params([
    'account' => 'rAccount...',
    'limit' => 10
]);
```

### tx

[](#tx)

```
$account_tx = $client->api('tx')->params([
    'transaction' => 'DE80B0064677CEFFDE...',
    'binary' => false
]);
```

For other methods refer to  and [src/Api/Methods](src/Api/Methods)

Utilities
---------

[](#utilities)

There are few utilities available with this package:

- Balance changes (with trading fees optional calculation)
- Flags
- UNLReport Flag Ledger
- Currency code to readable currency code

### Flags

[](#flags)

```
use XRPLWin\XRPL\Utilities\Flags;

//Methods:
Flags::extract(int $flags, string $transactionType): array
Flags::description(string $transactiontype, string $flagname, bool $htmlFormat = false): string
Flags::hasFlag(int $flags, int $check): bool
```

### UNLReportFlagLedger

[](#unlreportflagledger)

Flag ledger is calculated using modulo formula LedgerIndex % 256.

```
use XRPLWin\XRPL\Utilities\UNLReportFlagLedger;

UNLReportFlagLedger::isFlag(256);   //for ledger sequence 256 - true
UNLReportFlagLedger::isFlag(257);   //for ledger sequence 257 - false
UNLReportFlagLedger::prev(6873600);          //6873344
UNLReportFlagLedger::prevOrCurrent(6873600); //6873600
UNLReportFlagLedger::next(6873600);          //6873856
UNLReportFlagLedger::nextOrCurrent(6873600); //6873600
```

### Util class

[](#util-class)

Converts Currency Code ISO or HEX to human readable representation.

```
use XRPLWin\XRPL\Utilities\Util;
#Syntax: Util::currencyToSymbol(string $ISO_or_HEX, $malformedUtf8ReturnString = '?')

//ISO Currency Code
Util::currencyToSymbol('EUR') //EUR
//Deprecated Demurrage Currency Code
Util::currencyToSymbol('0158415500000000C1F76FF6ECB0BAC600000000') //XAU (-0.5% pa)
//Nonstandard Currency Code
Util::currencyToSymbol('534F4C4F00000000000000000000000000000000') //SOLO
```

Read more:

-
-

Running tests
-------------

[](#running-tests)

Run all tests in "tests" directory.

```
composer test

```

or

```
./vendor/bin/phpunit --testdox

```

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance79

Regular maintenance activity

Popularity24

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity69

Established project with proven stability

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

Total

50

Last Release

18d ago

Major Versions

v0.0.11 → v1.0.02023-04-30

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/100956614?v=4)[XRPLWin](/maintainers/xrplwin)[@XRPLWin](https://github.com/XRPLWin)

---

Top Contributors

[![zgrguric](https://avatars.githubusercontent.com/u/108837406?v=4)](https://github.com/zgrguric "zgrguric (101 commits)")

---

Tags

apiphpphp8xahauxahaudxrplcomposerpackageripplexrpxrplrippled

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/xrplwin-xrpl/health.svg)

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M46](/packages/tencentcloud-tencentcloud-sdk-php)[hardcastle/xrpl_php

PHP SDK / Client for the XRP Ledger

1110.7k7](/packages/hardcastle-xrpl-php)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

273.0k](/packages/eslazarev-wildberries-sdk)[dnsimple/dnsimple

The DNSimple API client for PHP.

11222.7k1](/packages/dnsimple-dnsimple)[files.com/files-php-sdk

Files.com PHP SDK

2481.1k](/packages/filescom-files-php-sdk)

PHPackages © 2026

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