Skip to content

goxrp/rippled-rest-api

Repository files navigation

Rippled REST API

Build Status Go Report Card Docs License Swagger UI Heroku

Rippled REST API provides a REST-like API proxy for the rippled server. It is more REST-like than the existing interfaces and should be easier to use for those with REST API experience, while remaining close enough to the rippled server's API to ensure eaiser maintenance, support and documenation than if a larger change was introduced.

A primary design goal of Rippled REST API is to support the OpenAPI Specification and tools such as Swagger UI.

Note: if you just want to use Postman, see the rippled-postman Postman Collection which can connect to rippled servers directly.

Providing a REST-like interface to Rippled requires thoughtful API design. Increasing REST-likeness will be introduced in several phases with different API versions of the Rippled REST API having specific design guidelines for that version.

It can run as any of the following:

  1. Server using net/http or fasthttp
  2. AWS Lambda function behind AWS API Gateway
  3. Heroku server

A test server is available at:

https://rippled-rest-api.herokuapp.com

Installation

Environment Variables

  1. HTTP_ENGINE: set to nethttp, fasthttp or awslambda.
  2. PORT: TCP port to listen on

Server

$ go get github.com/goxrp/rippled-rest-api
$ rippled-rest-api

AWS Lambda

  1. Use the aws-package.sh script to create a zip file to upload to AWS Lambda.
  2. Change "Runtime settings" > "Handler" to main from hello

Heroku

Deploy

or

$ heroku create
$ git push heroku master
$ heroku open

Heroku will automatically set the PORT environment variable.

Testing

Test with:

  • curl -XGET 'https://{gatewayId}.execute-api.{awsZone}.amazonaws.com/{stage}/api'
  • curl -XPOST 'https://{gatewayId}.execute-api.{awsZone}.amazonaws.com/{stage}/api/v1/account_info' -H 'Content-Type: application/json' -d @docs/examples/endpoint_account_info_request.json

API Spec

The API Spec is a work in progress and available at:

Example Request

API Request: HTTP API

POST /api/v1/account_info

{
  "account": "rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn",
  "strict": true,
  "ledger_index": "current",
  "queue": true
}
curl -XPOST 'http://localhost:8080/api/account_info' -d '{"account": "rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn", "strict": true, "ledger_index": "current", "queue": true}'

API Request: Websockets

{
  "id": 2,
  "command": "account_info",
  "account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
  "strict": true,
  "ledger_index": "current",
  "queue": true
}

API Request: JSON-RPC

POST /api/account_info

{
  "method": "account_info",
  "params": [
    {
      "account": "rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn",
      "strict": true,
      "ledger_index": "current",
      "queue": true
    }
  ]
}

Credits

  1. Heroku support provided via github.com/grokify/goheroku.