Ripple recently announced an improved, unified interface to the Ripple Consensus Ledger.

The new RippleAPI merges two original APIs, ripple-lib and Ripple-REST, into a single high-level interface for JavaScript that, according to Ripple is “fully documented, tested, schema-validated, stateless, and easier to use.”

Prior to RippleAPI, there were three very different APIs to the Ripple Consensus Ledger:

  • The rippled APIs: a low-level interface, not designed for ease of use.
  • The ripple-lib API: a low-level javascript interface, largely undocumented
  • The Ripple-REST API: a high-level HTTP interface

To better focus efforts as a company and provide a better user experience, Ripple merged two of the APIs into a single high-level JavaScript interface.

Ripple indicates that the ledger ‘s source code also has improvements. The RippleAPI source code is written in the latest JavaScript standard, ECMAScript 6, and uses Promises to return values from asynchronous calls. The new source code also follows many of the paradigms of functional programming.

Rome Reginelli, Ripple’s Documentation Engineer, notes:

For better organization, we used the “weak layering principle” to structure the source, according to which each layer can only depend on layers below it. This means that the source files are structured into subdirectories and there are very few imports that reach into parent or sibling directories.

Reginelli indicates that the RippleAPI comes with a comprehensive array of tests, including ubiquitous unit test coverage, integration tests for every method, flow type checking, ESLint checks, and automated testing of the documentation.

Reginelli continues:

All API methods have JSON schemas that specify the return values and parameter types. The unit tests use the schemas to validate the return values, which guarantees that the API results are consistent with expectations.

We generate human-readable documentation using Embedded JavaScript, which utilizes the schemas to generate parameter tables and the test fixtures as code samples. Every Git commit comes with the latest copy of the resulting Markdown documentation, thanks to unit tests which ensure that the documentation has been re-generated whenever changes are made. As long as the unit tests are passing, the documentation is consistent with the tests, and therefore with the source code.