XChange icon indicating copy to clipboard operation
XChange copied to clipboard

Ripple API support

Open MarkusTeufelberger opened this issue 13 years ago • 9 comments

While this might be a bit more difficult to manage (Ripple allows several issuers per currency, so there might be the need to set up multiple "exchanges" e.g. "USD.Bitstamp <--> BTC.Bitstamp" and "USD.Bitstamp <--> BTC.Weexchange") it might be good to have the prices on Ripple for both display and active trading available in XChange.

Documentation of API commands is available at https://ripple.com/wiki/RPC_API and the interface to ripple would be either a local server ("rippled") or any public one (a safe one to use would be s1.ripple.com). Commands can be sent via POST or (preferrably) websockets.

I don't do much Java but at least I could help with any questions that arise. :)

MarkusTeufelberger avatar Oct 14 '13 15:10 MarkusTeufelberger

There also a bounty for this: https://www.bountysource.com/trackers/3604734-ripple-trade

mmazi avatar Jul 11 '14 08:07 mmazi

Ripple also provides a simplified REST API. I've implemented this in Java here: https://github.com/mmazi/ripple-rest-java

This can be used for payments, but I don't think it can be used for trading (though I am not sure).

mmazi avatar Jul 11 '14 09:07 mmazi

I've now added order entry, order cancel and balance query here . However, I've only briefly tested it so don't feel it is quite ready for a pull request yet. However, the order cancel is causing a couple of rescu warnings in the log file:

WARN  [si.mazi.rescu.RestMethodMetadata] DELETE request declared as consuming method body as application/json. While body is allowed, it should be ignored by the server. Is this intended?
WARN  [si.mazi.rescu.RestInvocation] DELETE request will contain a body. While this is allowed, the body should be ignored by the server. Is this intended?

Since the Ripple REST API requires a json body in the order cancel DELETE request (https://github.com/ripple/ripple-rest#cancel-order), can @mmazi or anyone suggest the best way of suppressing, or avoiding these warnings?

ww3456 avatar Jun 07 '15 21:06 ww3456

The reason for the warnings is that ripple-rest doesn't conform to the HTTP protocol. Now that you know this, you can safely ignore the warnings :) The warnings are intended for the (rescu) users to start bugging the server (ripple-rest in this case) developers to make a HTTP-protocol-conforming server.

An alternative to ignoring the warnings is to configure logging differently (eg. set threshold for si.mazi.rescu.RestInvocation to ERROR) -- note that I don't recommend doing this since it will turn off other logging that may be important.

Also note that the RestMethodMetadata warning will be logged once (per client instance), while the RestInvocation warning will be logged with every order cancel request.

Bottom line: I think the current behavior with the logged warnings makes sense, considering that people should not write servers that don't conform to protocols, and considering that some clients will simply fail (or, I believe, issue a POST instead of a DELETE, etc.) in such cases.

mmazi avatar Jun 08 '15 11:06 mmazi

Thanks for the explanation, if it starts creating too much noise I'll look into adding an application logback filter for the specific message text.

@ripple would it be possible to make your ripple-rest API HTTP protocol compliant for order cancel requests? i.e. not use a DELETE message requiring a message body.

ww3456 avatar Jun 08 '15 12:06 ww3456

It seems to conform: http://tools.ietf.org/rfcmarkup?doc=7231#section-4.3.5

"A payload within a DELETE request message has no defined semantics; sending a payload body on a DELETE request might cause some existing implementations to reject the request."

MarkusTeufelberger avatar Jun 08 '15 12:06 MarkusTeufelberger

From the HTTP 1.1 spec:

4.3:

[I]f the request method does not include defined semantics for an entity-body, then the message-body SHOULD be ignored when handling the request.

Section 9.7 DELETE does not mention "entity-body" or anything similar. I interpret this as there not being any defined semantics for the body for DELETE, hence (by 4.3) the server should ignore the message body. The ripple-rest server does not (cannot) ignore the message body (it requires the data therein) so I believe it to be non-conformant.

Note that the client that sends a DELETE with body does conform to the spec: sending the body is allowed, but the server should respond in the same way no matter what the body is.

mmazi avatar Jun 08 '15 12:06 mmazi

From the same document you linked: "This document has been superseded. In 2014, RFC2616 was replaced by multiple RFCs (7230-7237)."

I linked you the current version of RFC 7231.

I also think it's stupid to put a body in a DELETE request (and the secret key should be transferred as a header instead), also there is a clear warning in 7231 that some existing implementations may break or just ignore anything there. Feel free to file bug reports at https://github.com/ripple/ripple-rest/issues.

MarkusTeufelberger avatar Jun 08 '15 13:06 MarkusTeufelberger

done.

timmolter avatar Sep 21 '15 20:09 timmolter