diff --git a/content/code_samples/rippleapi_quickstart/get-account-info.js b/content/code_samples/rippleapi_quickstart/get-account-info.js new file mode 100644 index 0000000000..6a78a4663e --- /dev/null +++ b/content/code_samples/rippleapi_quickstart/get-account-info.js @@ -0,0 +1,22 @@ +'use strict'; +const {RippleAPI} = require('ripple-lib'); + +const api = new RippleAPI({ + server: 'wss://s1.ripple.com' // Public rippled server +}); +api.connect().then(() => { + /* begin custom code ------------------------------------ */ + var my_address = "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn"; + + console.log("getting account info for",my_address); + api.getAccountInfo(my_address).then( info => { + console.log(info); + console.log("getAccountInfo done"); + } ).catch(console.error); + + /* end custom code -------------------------------------- */ +}).then(() => { + return api.disconnect().then(()=> { + console.log("done and disconnected."); + }).catch(console.error); +}).catch(console.error); diff --git a/content/code_samples/rippleapi_quickstart/package.json b/content/code_samples/rippleapi_quickstart/package.json new file mode 100644 index 0000000000..9cc089ef98 --- /dev/null +++ b/content/code_samples/rippleapi_quickstart/package.json @@ -0,0 +1,18 @@ +{ + "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": "*" + } +} diff --git a/content/rippleapi_quickstart.md b/content/rippleapi_quickstart.md new file mode 100644 index 0000000000..bb8560029e --- /dev/null +++ b/content/rippleapi_quickstart.md @@ -0,0 +1,103 @@ +# RippleAPI Quick Start Guide # + +This tutorial guides you through the basics of building a simple Ripple-connected application using [Node.js](http://nodejs.org/) and [RippleAPI](rippleapi.html), a simple JavaScript API for accessing the Ripple Consensus Ledger. + +# Environment Setup # + +The first step to using RippleAPI successfully 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. Specifically, 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](https://nodejs.org/en/download/package-manager/) for your operating system. If the packages for Node.js and `npm` (Node Package Manager) are separate (this includes Arch Linux, CentOS, Fedora, and RHEL), you should make sure to install both. + +After you have installed Node.js, you can check whether it's installed by checking the version of the `node` binary from a commandline: + +``` +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). In order to use the new features of ECMAScript 6, RippleAPI depends on [Babel-Node](https://babeljs.io) and its ES2015 presets. Fortunately you can use `npm` to install RippleAPI and these dependencies all at once. + +#### 1. Create a new directory for your project + +For example, to create a folder called `my_ripple_experiment`: + +``` +mkdir my_ripple_experiment && cd my_ripple_experiment +``` + +Alternatively, you can [create a repo on GitHub](https://help.github.com/articles/create-a-repo/) in order to share your work. After setting it up, [clone the repo](https://help.github.com/articles/cloning-a-repository/) to your local machine and `cd` into that directory. + +#### 2. Create a new `package.json` file for your project. + +Here's a good template: + +``` +{ + "name": "my_ripple_experiment", + "version": "0.0.1", + "license": "UNLICENSED", + "private": true, + "dependencies": { + "ripple-lib": "*", + "babel-cli": "^6.0.0", + "babel-preset-es2015": "*" + }, + "babel": { + "presets": ["es2015"] + }, + "devDependencies": { + "eslint": "*" + } +} +``` + +This includes RippleAPI itself (`ripple-lib`), Babel (`babel-cli`), the ECMAScript 6 presets for Babel (`babel-preset-es2015`). It also has the optional add-on [ESLint](http://eslint.org/) (`eslint`) for checking your code quality. + +#### 3. Use NPM to install the dependencies. + +``` +npm install +``` + +This automatically installs all the dependencies defined in the `package.json` into the local folder `node_modules/`. (We recommend _not_ using `npm -g` to install the dependencies globally.) + +The install process may take a while, and may end with a few warnings. The following warnings are benign, and do not indicate a real problem: + +``` +npm WARN optional Skipping failed optional dependency /chokidar/fsevents: +npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.6 +npm WARN ajv@1.4.10 requires a peer of ajv-i18n@0.1.x but none was installed. +``` + +#### 4. (Optional) Tell Git to ignore the `node_modules` folder. + +If you are using Git to manage your repository, it's considered a good practice to omit the `node_modules` folder from the Git repo. Other people who check out your code can use `npm` to install the dependencies, and you don't have to keep the repo synchronized with changes to other people's code. Edit the `.gitignore` file and add the following line to it: + +``` +/node_modules/ +``` + +Save and commit the changes: + +``` +git add .gitignore +git commit -m "ignore node_modules" +``` + +# First RippleAPI Script + + + + diff --git a/data-api-v2-tool.html b/data-api-v2-tool.html index 009a6517de..da0ea39889 100644 --- a/data-api-v2-tool.html +++ b/data-api-v2-tool.html @@ -56,6 +56,15 @@
  • Freeze
  • + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + -