WebSocket and JSON-RPC APIs
If you want to communicate directly with the rippled server, you have three fairly similar options for how to do that. All of these APIs use the same list of commands, with almost entirely the same parameters in each command. Whereas the Ripple-REST API provides a simplified interface on top of the WebSocket API for easier integration, these APIs provide the full power of Ripple but require slightly more complexity:
-
+
+
+
+
- The WebSocket API uses the WebSocket protocol, available in most browsers and Javascript implementations, to achieve persistent two-way communication. There is not a 1:1 correlation between requests and responses. Some requests prompt the server to send multiple messages back asynchronously; other times, responses may arrive in a different order than the requests that prompted them.
- The JSON-RPC API relies on simple request-response communication via HTTP. For commands that prompt multiple responses, you can provide a callback URL.
- The
rippledprogram can also be used as a quick commandline client to make JSON-RPC requests to a runningrippledserver. This is only intended for administrative purposes, and is not a supported API.
@@ -407,7 +410,7 @@ Null method - Specify a ledger by its Sequence Number in the
ledger_indexparameter. Each closed ledger has an identifying sequence number that is 1 higher than the previously-validated ledger. (The Genesis Ledger has sequence number 0) - Specify a ledger by its hash value in the
ledger_hashparameter. - Specify a ledger by one of the following shortcuts, in the
ledger_indexparameter:-
@@ -485,17 +488,17 @@ Null method
account_info- Get basic data about an account
-account_lines- Get info about an account’s trust lines
-account_offers- Get info about an account’s currency exchange offers
-account_tx- Get info about an account’s transactions
+account_info- Get basic data about an account
+account_lines- Get info about an account’s trust lines
+account_offers- Get info about an account’s currency exchange offers
+account_tx- Get info about an account’s transactionsbook_offers- Get info about offers to exchange two currencies
-ledger- Get info about a ledger version
+ledger- Get info about a ledger versionledger_closed- Get the latest closed ledger version
-ledger_current- Get the current working ledger version
-ledger_data- Get the raw contents of a ledger version
-ledger_entry- Get one element from a ledger version
+ledger_current- Get the current working ledger version
+ledger_data- Get the raw contents of a ledger version
+ledger_entry- Get one element from a ledger versionpath_find- Find a path for a payment between two accounts and receive updatesping- Confirm connectivity with the serverrandom- Generate a random number
@@ -505,12 +508,12 @@ Null methodsign- Cryptographically sign a transactionsubmit- Send a transaction to the networksubscribe- Listen for updates about a particular subject
-transaction_entry- Retrieve info about a transaction from a particular ledger version
-tx- Retrieve info about a transaction from all the ledgers on hand
-tx_history- Retrieve info about all recent transactions
+transaction_entry- Retrieve info about a transaction from a particular ledger version
+tx- Retrieve info about a transaction from all the ledgers on hand
+tx_history- Retrieve info about all recent transactionsunsubscribe- Stop listening for updates about a particular subject
For other errors that returned with HTTP status code
The server is participating in validation of the ledger and currently proposing its own version. -Note: The distinction between
full,validating, andproposingis based on synchronization with the rest of the global network, and it is normal for a server to fluctuate between these states as a course of general operation.Modifying the Ledger
All changes to Ripple’s global shared ledger happen as the result of transactions. Consequently, this means that there is only one public API method that causes a change in the state of the Ripple Network at all: the submit command. Most of the other methods represent different ways to view the data represented in the Ripple Network, and the remaining ones just generate data for your convenience. (The wallet_propose, path_find, and random commands fall into this category.)
For more information on the various transactions you can submit, consult the Transaction Format.
API Methods
API methods for the Websocket and JSON-RPC APIs are defined by command names, and are divided into Public Commands and Admin Commands. Public Commands are not necessarily meant for the general public, but they are used by any client attached to the server. (Think of Public Commands as being for members or customers of the organization running the server, while the Admin Commands are for the personnel in charge of keeping the server operational.) Public Commands include the general operations for Ripple use, including checking the state of the ledger, finding a path to connecting users, and submitting a transaction, among others. Admin Commands, on the other hand, are meant only for the operators of the server, and include commands for managing the state of the server, the nodes it uses for validation, and other administrative features.
This page deals with all the Public Commands available.
List of Public Commands
-
-
Note: The distinction between
full,validating, andproposingis based on synchronization with the rest of the global network, and it is normal for a server to fluctuate between these states as a course of general operation.Modifying the Ledger
All changes to Ripple’s global shared ledger happen as the result of transactions. Consequently, this means that there is only one public API method that causes a change in the state of the Ripple Network at all: the submit command. Most of the other methods represent different ways to view the data represented in the Ripple Network, and the remaining ones just generate data for your convenience. (The wallet_propose, path_find, and random commands fall into this category.)
For more information on the various transactions you can submit, consult the Transaction Format.
API Methods
API methods for the Websocket and JSON-RPC APIs are defined by command names, and are divided into Public Commands and Admin Commands. Public Commands are not necessarily meant for the general public, but they are used by any client attached to the server. (Think of Public Commands as being for members or customers of the organization running the server, while the Admin Commands are for the personnel in charge of keeping the server operational.) Public Commands include the general operations for Ripple use, including checking the state of the ledger, finding a path to connecting users, and submitting a transaction, among others. Admin Commands, on the other hand, are meant only for the operators of the server, and include commands for managing the state of the server, the nodes it uses for validation, and other administrative features.
This page deals with all the Public Commands available.
List of Public Commands
-
+
For other errors that returned with HTTP status code
The
wallet_accountscommand is deprecated and may be removed without further notice.Admin Commands
Additionally, this page contains an explanation of the following important admin-only command:
For information about other Admin Commands, consult the old wiki documentation.
Commandline Access
The
rippledapplication, in addition to acting as a server, can be run (as a separate instance) to act as a JSON-RPC client. In this mode, it has syntax for triggering most API methods with a single line from the command prompt, as described in each method. However, some methods don’t have a commandline shortcut, so it also provides the following catch-all method for performing commands:Managing Accounts
Accounts are the core unit of authentication in the Ripple Network. Each account can hold balances in multiple currencies, and all transactions must be signed by an account’s secret key. In order for an account to exist in a validated ledger version, it must hold a minimum reserve amount of XRP. (The reserve for an account increases with the amount of data it is responsible for in the shared ledger.) It is expected that accounts will correspond loosely to individual users.
account_info
The
account_infocommand retrieves information about an account, its activity, and its XRP balance. All information retrieved is relative to a particular version of the ledger.Request Format
An example of an account_info request:
@@ -589,7 +592,7 @@ rippled -- account_info r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59 true-
WebSocket and JSON-RPC APIs
If you want to communicate directly with the rippled server, you have three fairly similar options for how to do that. All of these APIs use the same list of commands, with almost entirely the same parameters in each command. Whereas the Ripple-REST API provides a simplified interface on top of the WebSocket API for easier integration, these APIs provide the full power of Ripple but require slightly more complexity:
For other errors that returned with HTTP status code
Caution on Errors
When your request results in an error, the entire request is copied back as part of the response, so that you can try to debug the error. However, this also includes any secrets that were passed as part of the request. When sharing error messages, be very careful not to accidentally expose important account secrets to others.
Formatting Conventions
The WebSocket and JSON-RPC APIs generally take the same arguments, although they’re provided in a different way (See Request Formatting for details). Many similar parameters appear throughout the APIs, and there are conventions for how to specify these parameters.
All field names are case-sensitive. In responses, fields that are taken directly from Ledger Node or Transaction objects start with upper-case letters. Other fields, including ones that are dynamically generated for a response, are lower case.
Unique Identifiers
Different types of objects are uniquely identified in different ways:
Accounts are identified by their address, a base-58-encoded string, for example "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59". Addresses always start with “r”. You can also provide an un-encoded hex representation instead.
Transactions are identified by their hash, which is a SHA-512 hash of the transaction’s binary format. Transaction hashes are represented as hex strings.
Each instance of the Ripple Ledger has a sequence number and a hash value. See Specifying a Ledger Instance for details.
Specifying a Ledger Instance
Many API methods require you to specify an instance of the ledger, with the data retrieved being considered accurate and up-to-date as of that particular version of the shared ledger. The commands that accept a ledger version all work the same way. There are three ways you can specify which ledger you want to use:
-
+
Caution on Errors
When your request results in an error, the entire request is copied back as part of the response, so that you can try to debug the error. However, this also includes any secrets that were passed as part of the request. When sharing error messages, be very careful not to accidentally expose important account secrets to others.
Formatting Conventions
The WebSocket and JSON-RPC APIs generally take the same arguments, although they’re provided in a different way (See Request Formatting for details). Many similar parameters appear throughout the APIs, and there are conventions for how to specify these parameters.
All field names are case-sensitive. In responses, fields that are taken directly from Ledger Node or Transaction objects start with upper-case letters. Other fields, including ones that are dynamically generated for a response, are lower case.
Unique Identifiers
Different types of objects are uniquely identified in different ways:
Accounts are identified by their address, a base-58-encoded string, for example "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59". Addresses always start with “r”. You can also provide an un-encoded hex representation instead.
Transactions are identified by their hash, which is a SHA-512 hash of the transaction’s binary format. Transaction hashes are represented as hex strings.
Each instance of the Ripple Ledger has a sequence number and a hash value. See Specifying a Ledger Instance for details.
Specifying a Ledger Instance
Many API methods require you to specify an instance of the ledger, with the data retrieved being considered accurate and up-to-date as of that particular version of the shared ledger. The commands that accept a ledger version all work the same way. There are three ways you can specify which ledger you want to use: