{"id":21557062,"url":"https://github.com/xrplwin/xrpl","last_synced_at":"2026-02-07T15:17:26.702Z","repository":{"id":57767565,"uuid":"474004993","full_name":"XRPLWin/XRPL","owner":"XRPLWin","description":"PHP REST API for XRPL","archived":false,"fork":false,"pushed_at":"2024-11-25T11:57:09.000Z","size":419,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-24T09:11:38.889Z","etag":null,"topics":["api","php","php8","xahau","xahaud","xrpl"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/XRPLWin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["zgrguric"]}},"created_at":"2022-03-25T12:43:17.000Z","updated_at":"2024-11-30T21:06:11.000Z","dependencies_parsed_at":"2023-10-02T07:55:20.892Z","dependency_job_id":"13949956-9ff4-4f3b-a80c-3f4f6ad6ff8a","html_url":"https://github.com/XRPLWin/XRPL","commit_stats":{"total_commits":38,"total_committers":2,"mean_commits":19.0,"dds":"0.052631578947368474","last_synced_commit":"7a71d983545a3a18739f5b54b3d1b21354b41e3d"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XRPLWin%2FXRPL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XRPLWin%2FXRPL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XRPLWin%2FXRPL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XRPLWin%2FXRPL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/XRPLWin","download_url":"https://codeload.github.com/XRPLWin/XRPL/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248199088,"owners_count":21063641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","php","php8","xahau","xahaud","xrpl"],"created_at":"2024-11-24T08:10:50.571Z","updated_at":"2026-02-07T15:17:26.692Z","avatar_url":"https://github.com/XRPLWin.png","language":"PHP","funding_links":["https://github.com/sponsors/zgrguric"],"categories":[],"sub_categories":[],"readme":"![main workflow](https://github.com/XRPLWin/XRPL/actions/workflows/main.yml/badge.svg)\n[![GitHub license](https://img.shields.io/github/license/XRPLWin/XRPL)](https://github.com/XRPLWin/XRPL/blob/main/LICENSE)\n[![Total Downloads](https://img.shields.io/packagist/dt/xrplwin/xrpl.svg?style=flat)](https://packagist.org/packages/xrplwin/xrpl)\n\n# PHP XRPL API Connector\n\n## Requirements\n- PHP 8.1 or higher\n- [Composer](https://getcomposer.org/)\n\n## Installation\n```\ncomposer require xrplwin/xrpl\n```\n\n## Usage sample\n\nIn sample below we will be using account_tx method.\n\n### Init Client\n```PHP\n$client = new \\XRPLWin\\XRPL\\Client([\n    # Following values are defined by default, uncomment to override\n    //'endpoint_reporting_uri' =\u003e 'http://s1.ripple.com:51234',\n    //'endpoint_fullhistory_uri' =\u003e 'https://xrplcluster.com'\n]);\n```\n\n### Creating first request\n```PHP\n# Create new 'account_tx' method instance\n$account_tx = $client-\u003eapi('account_tx')-\u003eparams([\n    'account' =\u003e 'rAccount...',\n    'limit' =\u003e 10\n]);\n```\nThis will return an instance of `XRPLWin\\XRPL\\Api\\Methods\\AccountTx`.\n\n### Custom rate limit handling\nIf you wish to define custom behaviour when request is rate-limited you can via `Closure` function. Define this before executing `send()`.\n```PHP\n//(optional) Override default cooldown seconds (default is 5 seconds)\n$account_tx-\u003esetCooldownSeconds(10);\n//(optional) Override default number of tries when request is rate-limited (default is 3)\n$account_tx-\u003esetTries(5);\n//(optional) Set http timeout to 3 seconds (default is 0 - eg no timeout)\n//           After 3 seconds method will throw \\XRPLWin\\XRPL\\Exceptions\\BadRequestException on timeout\n$account_tx-\u003esetTimeout(3);\n\n//(optional) Define custom cooldown callback\n$account_tx-\u003esetCooldownHandler(\n    /**\n     * @param int $current_try Current try 1 to max\n     * @param int $default_cooldown_seconds Predefined cooldown seconds\n     * @return void|boolean return false to stop process\n     */\n    function(int $current_try, int $default_cooldown_seconds) {\n        //Sample usage: calculate how much sleep() is needed depending on \n        $sec = $default_cooldown_seconds * $current_try;\n        if($sec \u003e 15) return false; //force stop\n        sleep($sec);\n    }\n);\n```\n\n### Fetching response\n```PHP\n# Send request to Ledger\ntry {\n    $account_tx-\u003esend();\n} catch (\\XRPLWin\\XRPL\\Exceptions\\XWException $e) {\n    // Handle errors\n    throw $e;\n}\n\nif(!$account_tx-\u003eisSuccess()) {\n    //XRPL response is returned but field result.status did not return 'success'\n}\n\n# Get fetched response as array\n$response       = $account_tx-\u003eresultArray(); //array response from ledger\n# Get fetched response as object\n$response       = $account_tx-\u003eresult();      //object response from ledger\n# Get fetched final result from helper (varies method to method)\n$transactions   = $account_tx-\u003efinalResult(); //array of transactions\n```\n\nClass 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.\n\n### Promises\nAlternative to fetch syncronous response as defined above, you can get `Promise`  \n[Read more](https://github.com/guzzle/promises) about Promises. Returned object is [Promises/A+](https://promisesaplus.com/) implementation. \n```PHP\n$promise = $account_tx-\u003erequestAsync();\n\n$promises = [\n    'rAcct1' =\u003e $promise,\n    //...more promises\n];\n\n// Wait for the requests to complete\n// Throws a ConnectException if any of the requests fail\n$responses = \\GuzzleHttp\\Promise\\Utils::unwrap($promises);\n\n//Fill response data back into $account_tx instance\n$account_tx-\u003efill($responses['rAcct1']);\n\n//...\n$transactions = $account_tx-\u003efinalResult();\n\n```\n*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.\n\n### Paginating result\n```PHP\n\n# Check if there is next page\n//$has_next_page = $account_tx-\u003ehasNextPage(); //bool\n\n# Fetch next page of transactions if there is next page (next() does not return null)\nif($next_account_tx = $account_tx-\u003enext()) {\n    $next_result = $next_account_tx-\u003esend()-\u003efinalResult();\n    // ...\n}\n```\n\nTo 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-\u003eapi('account_tx')-\u003eparams([ ..., ['marker'] =\u003e [ ... ]]`.\n\nSee [samples](samples/paginating.php) for more information.\n\n## Request workflow\n\n1. Prepare instance by setting params\n2. 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)\n4. XRPLedger response is stored in memory and it is available to read via  \n`-\u003eresult()`  \n`-\u003eresultArray()`  \n`-\u003efinalResult()`\n\n## Methods\n\n### account_tx\n\n```PHP\n$account_tx = $client-\u003eapi('account_tx')-\u003eparams([\n    'account' =\u003e 'rAccount...',\n    'limit' =\u003e 10\n]);\n```\n\n### tx\n\n```PHP\n$account_tx = $client-\u003eapi('tx')-\u003eparams([\n    'transaction' =\u003e 'DE80B0064677CEFFDE...',\n    'binary' =\u003e false\n]);\n```\nFor other methods refer to https://xrpl.org/websocket-api-tool.html and [src/Api/Methods](src/Api/Methods)\n\n## Utilities\n\nThere are few utilities available with this package:\n- Balance changes (with trading fees optional calculation)\n- Flags\n- UNLReport Flag Ledger\n- Currency code to readable currency code\n\n### Flags\n\n```PHP\nuse XRPLWin\\XRPL\\Utilities\\Flags;\n\n//Methods:\nFlags::extract(int $flags, string $transactionType): array\nFlags::description(string $transactiontype, string $flagname, bool $htmlFormat = false): string\nFlags::hasFlag(int $flags, int $check): bool\n```\n\n### UNLReportFlagLedger\n\nFlag ledger is calculated using modulo formula LedgerIndex % 256.\n\n```PHP\nuse XRPLWin\\XRPL\\Utilities\\UNLReportFlagLedger;\n\nUNLReportFlagLedger::isFlag(256);   //for ledger sequence 256 - true\nUNLReportFlagLedger::isFlag(257);   //for ledger sequence 257 - false\nUNLReportFlagLedger::prev(6873600);          //6873344\nUNLReportFlagLedger::prevOrCurrent(6873600); //6873600\nUNLReportFlagLedger::next(6873600);          //6873856\nUNLReportFlagLedger::nextOrCurrent(6873600); //6873600\n```\n\n### Util class\nConverts Currency Code ISO or HEX to human readable representation.  \n\n```PHP\nuse XRPLWin\\XRPL\\Utilities\\Util;\n#Syntax: Util::currencyToSymbol(string $ISO_or_HEX, $malformedUtf8ReturnString = '?')\n\n//ISO Currency Code\nUtil::currencyToSymbol('EUR') //EUR \n//Deprecated Demurrage Currency Code\nUtil::currencyToSymbol('0158415500000000C1F76FF6ECB0BAC600000000') //XAU (-0.5% pa)\n//Nonstandard Currency Code\nUtil::currencyToSymbol('534F4C4F00000000000000000000000000000000') //SOLO\n```\nRead more:\n- https://xrpl.org/docs/references/protocol/data-types/currency-formats/#currency-formats\n- https://xrpl.org/docs/concepts/tokens/fungible-tokens/demurrage/\n\n## Running tests\nRun all tests in \"tests\" directory.\n```\ncomposer test\n```\nor\n```\n./vendor/bin/phpunit --testdox\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxrplwin%2Fxrpl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxrplwin%2Fxrpl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxrplwin%2Fxrpl/lists"}