<p>You can use both solutions. Api is based on Json-RPC. Its app for getting transactions on address. You can change it for your needs.</p>

<p><code>const RippleAPI = require('ripple-lib').RippleAPI;
var test_server = 'wss://s2.ripple.com';
const api = new RippleAPI({
    server: test_server // Public rippled server
});
api.connect().then(() =&gt; {
    /* begin custom code ------------------------------------ */
    const myAddress = 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn';
    console.log('getting account info for', myAddress);
    return api.getTransactions(myAddress);
}).then(info =&gt; {
    console.log(info);
    /* end custom code -------------------------------------- */
}).then(() =&gt; {
    return api.disconnect();
}).then(() =&gt; {
    console.log('done and disconnected.');
}).catch(console.error);</code></p>

<p>Good luck)</p>

CC BY-SA 4.0
2018-05-30T13:40:58.930Z
2018-05-30T13:40:58.930Z
Дима Марков
<p>I need to write a program that monitors the transactions that sent to me.
My approach is to periodically (like every 2 minutes) call the Ripple public api to get transactions for my account.  But on the developer doc, I find two way to achieve this:</p>

<ol>
<li><a href="https://developers.ripple.com/data-api.html#get-account-transaction-history" rel="nofollow noreferrer">Ripple Data API</a> . 
example: </li>
</ol>

<blockquote>
  <p><a href="https://data.ripple.com/v2/accounts/rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn/transactions?type=Payment&amp;result=tesSUCCESS&amp;limit=3" rel="nofollow noreferrer">https://data.ripple.com/v2/accounts/rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn/transactions?type=Payment&amp;result=tesSUCCESS&amp;limit=3</a></p>
</blockquote>

<ol start="2">
<li><a href="https://developers.ripple.com/account_tx.html" rel="nofollow noreferrer">WebSocket/Json-RPC API</a>. send to <code>s2.ripple.com:443</code>
with websocket or http.  example:</li>
</ol>

<blockquote>
  <p>{   "id": 1,   "command": "account_tx",<br>
  "account": 
  "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",<br>
  "ledger_index_min": -1,<br>
  "ledger_index_max": -1,<br>
  "binary": false,   "count": false,<br>
  "limit": 10,   "forward": false }</p>
</blockquote>

<p>I didn't check carefully, but they seem to have same response(with different format). </p>

<p>My question is :</p>

<ol>
<li><p>are they equivalent?</p></li>
<li><p>which one should be preferred or which one is recommended by ripple? </p></li>
</ol>

CC BY-SA 4.0
2018-05-30T13:32:50.427Z
They provide the same data. The data API is a high reliability service provided by Ripple. The websocket API is a less reliable service anyone running the XRP Ledger software can provide. The websocket APi is a bit harder to use because you have to carefully track which ledgers you've searched over.
David Schwartz
<ripple><ripple-api>
Ripple Data API vs Ripple RPC
matrix
# Ripple Data API vs Ripple RPC

(Asked by: username_0 on 2018-05-29)

I need to write a program that monitors the transactions that sent to me.
My approach is to periodically (like every 2 minutes) call the Ripple public api to get transactions for my account. But on the developer doc, I find two way to achieve this:

1. [Ripple Data API](https://developers.ripple.com/data-api.html#get-account-transaction-history) .
   example:

> <https://data.ripple.com/v2/accounts/rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn/transactions?type=Payment&result=tesSUCCESS&limit=3>

2. [WebSocket/Json-RPC API](https://developers.ripple.com/account_tx.html). send to `s2.ripple.com:443`
   with websocket or http. example:

> { "id": 1, "command": "account\_tx",  
> "account":
> "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",  
> "ledger\_index\_min": -1,  
> "ledger\_index\_max": -1,  
> "binary": false, "count": false,  
> "limit": 10, "forward": false }

I didn't check carefully, but they seem to have same response(with different format).

My question is :

1. are they equivalent?
2. which one should be preferred or which one is recommended by ripple?

**Tags:** ripple, ripple-api

> **Comments:**
> **username_1**: They provide the same data. The data API is a high reliability service provided by Ripple. The websocket API is a less reliable service anyone running the XRP Ledger software can provide. The websocket APi is a bit harder to use because you have to carefully track which ledgers you've searched over.  

---

## 1 answers

### Answer by username_2 on 2018-05-30. Score: 0 | Accepted answer

You can use both solutions. Api is based on Json-RPC. Its app for getting transactions on address. You can change it for your needs.

`const RippleAPI = require('ripple-lib').RippleAPI;
var test_server = 'wss://s2.ripple.com';
const api = new RippleAPI({
server: test_server // Public rippled server
});
api.connect().then(() => {
/* begin custom code ------------------------------------ */
const myAddress = 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn';
console.log('getting account info for', myAddress);
return api.getTransactions(myAddress);
}).then(info => {
console.log(info);
/* end custom code -------------------------------------- */
}).then(() => {
return api.disconnect();
}).then(() => {
console.log('done and disconnected.');
}).catch(console.error);`

Good luck)


---

