RippleAPI Beginners Guide
This tutorial guides you through the basics of building an XRP Ledger-connected application using Node.js and RippleAPI, a JavaScript API for accessing the XRP Ledger.
The scripts and configuration files used in this guide are available in the Ripple Dev Portal GitHub Repository.
Environment Setup
The first step to using RippleAPI is setting up your development environment.
Install Node.js and npm
RippleAPI is built as an application for the Node.js runtime environment, so the first step is getting Node.js installed. RippleAPI requires Node.js version 0.12, version 4.x, or higher.
This step depends on your operating system. We recommend the official instructions for installing Node.js using a package manager for your operating system. If the packages for Node.js and npm
(Node Package Manager) are separate, install both. (This applies to Arch Linux, CentOS, Fedora, and RHEL.)
After you have installed Node.js, you can check the version of the node
binary from a command line:
node --version
On some platforms, the binary is named nodejs
instead:
nodejs --version
Use NPM to install RippleAPI and dependencies
RippleAPI uses the newest version of JavaScript, ECMAScript 6 (also known as ES2015). To use the new features of ECMAScript 6, RippleAPI depends on Babel-Node and its ES2015 presets. You can use npm
to install RippleAPI and these dependencies together.
1. Create a new directory for your project
Create a folder called (for example) my_ripple_experiment
:
mkdir my_ripple_experiment && cd my_ripple_experiment
Optionally, start a Git repository in that directory so you can track changes to your code.
git init
Alternatively, you can create a repo on GitHub to version and share your work. After setting it up, clone the repo to your local machine and cd
into that directory.
2. Create a new package.json
file for your project.
Use the following template, which includes:
- RippleAPI itself (
ripple-lib
) - Babel (
babel-cli
) - The ECMAScript 6 presets for Babel (
babel-preset-es2015
) - (Optional) ESLint (
eslint
) for checking code quality.
{
"name": "my_ripple_experiment",
"version": "0.0.1",
"license": "MIT",
"private": true,
"//": "Change the license to something appropriate. You may want to use 'UNLICENSED' if you are just starting out.",
"dependencies": {
"ripple-lib": "*",
"babel-cli": "^6.0.0",
"babel-preset-es2015": "*"
},
"babel": {
"presets": ["es2015"]
},
"devDependencies": {
"eslint": "*"
}
}