Git Product home page Git Product logo

xrp-api's Introduction

XRP-API Server

An API server that provides a REST-like interface to the XRP Ledger.

Requirements

Initial setup

  1. Clone this repository (or download and extract a copy).

     git clone [email protected]:ripple/xrp-api.git
    
  2. Install dependencies using Yarn.

     yarn install
    
  3. Set up your configuration file for the first time.

     yarn run setup
    

Development

To start the server in development mode:

yarn dev

This starts the server with nodemon so that it will be automatically restarted when you save changes to the code.

Production

As this server is still in active development, we do not recommend using it in production at this time.

Considerations:

  • SSL/TLS must be used for all requests. An SSL/TLS termination proxy is recommended.
  • Restrictions should be made on signing, such as on the types of transactions, amount/velocity, and whitelisting of destinations. This feature is coming in the future.
  • If an error occurs, the server will exit to protect security & data integrity. We recommend using nodemon or forever to restart the server if any errors occur in production.

Tutorial

In this simple tutorial, we will get our account's XRP balance, send a payment, and check the status of our payment.

  1. Get our account's XRP balance.

    In the following example, replace {ACCOUNT_ADDRESS_HERE} with your Address:

     curl -X GET \
       http://localhost:3000/v1/accounts/{ACCOUNT_ADDRESS_HERE}/info
    
  2. Send a payment

    In the following example, replace {ACCOUNT_ADDRESS_HERE} with your Address (2 locations), {API_KEY_HERE} with your API key, and {DESTINATION_ADDRESS_HERE} with a destination address. If you are using the Test Net, you can use the address rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe as a destination.

     curl -X POST \
        http://localhost:3000/v1/payments \
        -H 'Authorization: Bearer {API_KEY_HERE}' \
        -H 'Content-Type: application/json' \
        -d '{
          "payment": {
              "source_address": "{ACCOUNT_ADDRESS_HERE}",
              "source_amount": {
                  "value": "20",
                  "currency": "XRP"
              },
              "destination_address": "{DESTINATION_ADDRESS_HERE}",
              "destination_amount": {
                  "value": "20",
                  "currency": "XRP"
              }
          },
          "submit": true
      }'
    

    The response shows the transaction's identifying hash in the hash field of the tx_json object. Take note of this value for the next step.

  3. Check the status of the payment.

    In the following example, replace {TRANSACTION_ID} with the transaction's identifying hash from the previous step:

     curl -X GET \
       http://localhost:3000/v1/transactions/{TRANSACTION_ID}
    

Docker Container

You can also run the service in a docker container using the Dockerfile in this repo.

  1. Be sure you have done the secret_config step from the Initial Setup section.

  2. Build the container.

    docker build . -t <some_tag>

  3. Run the container.

    docker run -it -p 3000:3000 -v <path_to_secret_config>/.secret_config.js:/xrp-api/.secret_config.js <some_tag>

  4. You should now be able to run the steps in the tutorial.

xrp-api's People

Contributors

intelliot avatar fksripple avatar ayaggarwal avatar fredkschott avatar dependabot[bot] avatar mduo13 avatar sfittje-ripple avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.