jbjnr 2,026 Posted January 3 Share Posted January 3 Hello, I'd like to access the order book on the ledger for XRP/USD.bitstamp in as close to real time as possible. The server here https://xrpcharts.ripple.com/#/markets/XRP/USD:rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B?interval=15m&range=3d&type=line provides a view of the order book for a given currency pair. I can't find any REST API call that delivers this info on the ripple API pages and I wonder if there is a way of running a rippled server with validation disabled, but monitoring the state of transactions (or querying the order book via some call) to produce something similar. I'm only interested in doing this from inside a c++ application, so I don't want any nodejs or other script language based solutions, but I'm happy to query things like a REST API or get data from a websocket from inside the c++ code if I need to. I've compiled rippled locally and am happy to link to parts of it if necessary from my program and am not against ripping just the bits I need out, though I suspect that's not necessary (I would like to avoid having too many rippled threads running that are not under my direct control - I already have several beast/asio threads querying data from other websockets on the go). Can anyone point me in the right direction as to how the best way to get the order book would be. Ideally, I'd like a std::vector of bids and another of asks for xrp/usd.bitstamp etc etc (for now, I'd only really need those two, but might want other IOUs in the future). Thanks. Link to post Share on other sites
jargoman 850 Posted January 3 Share Posted January 3 You could use the websocket api, the json-rest api or the rippled command line optionshttps://xrpl.org/get-started-with-the-rippled-api.html Link to post Share on other sites
jbjnr 2,026 Posted January 3 Author Share Posted January 3 38 minutes ago, jargoman said: You could use the websocket api, the json-rest api or the rippled command line optionshttps://xrpl.org/get-started-with-the-rippled-api.html Aha. The page I needed is here https://xrpl.org/book_offers.html. That's a great help - not sure how I didn't find that previously - I will use the websocket interface and should be able to get what I need. Many thanks indeed. Link to post Share on other sites
jargoman 850 Posted January 4 Share Posted January 4 38 minutes ago, jbjnr said: Aha. The page I needed is here https://xrpl.org/book_offers.html. That's a great help - not sure how I didn't find that previously - I will use the websocket interface and should be able to get what I need. Many thanks indeed. It's better to find a c++ library than doing it all yourself. You need something to sign the transactions this project looks interesting. They've copied the rippled source code into the project to create a library. https://github.com/ripple/ripple-libpp jbjnr 1 Link to post Share on other sites
jbjnr 2,026 Posted January 4 Author Share Posted January 4 I'm curious about the websocket interface - when I request the order book, I get a list of taker offers as expected, but as its a websocket, I expected that I could subscribe to the order_book and every ledger close I would automatically receive a new list (or subset thereof) - rather than having to ping every N seconds to get an update. Am I misunderstanding how the system works - or is there a way to simply listen for updates without sending repeated requests? (which is why I initially assumed that I might need to run some subset of the rippled server to have constant access) Link to post Share on other sites
Sukrim 1,889 Posted January 4 Share Posted January 4 You're close: https://xrpl.org/subscribe.html#order-book-streams is the one you want, after getting the initial full order book via book_offers. jbjnr 1 Link to post Share on other sites
tulo 3,275 Posted January 4 Share Posted January 4 41 minutes ago, Sukrim said: You're close: https://xrpl.org/subscribe.html#order-book-streams is the one you want, after getting the initial full order book via book_offers. The "drawback" is that you need to build the book yourself incrementally from the metadata. You won't have directly bids and asks. jbjnr 1 Link to post Share on other sites
jbjnr 2,026 Posted January 4 Author Share Posted January 4 Thanks everyone. I have the info I need now. Building the order book by hand isn't an issue as long as I don't miss any offers etc. I'll play around and see if doing a full update once every now and then is necessary of if things stay in sync long term. Link to post Share on other sites
tulo 3,275 Posted January 4 Share Posted January 4 17 minutes ago, jbjnr said: Thanks everyone. I have the info I need now. Building the order book by hand isn't an issue as long as I don't miss any offers etc. I'll play around and see if doing a full update once every now and then is necessary of if things stay in sync long term. If you have everything local it should stay in sync 100%. If you need to build autobridged books it's a bit more complex, but nothing impossible, just be careful. There should be some very old topics here on that. jbjnr 1 Link to post Share on other sites
jbjnr 2,026 Posted January 13 Author Share Posted January 13 On 1/4/2021 at 1:36 AM, jargoman said: It's better to find a c++ library than doing it all yourself. You need something to sign the transactions this project looks interesting. They've copied the rippled source code into the project to create a library. https://github.com/ripple/ripple-libpp I just made a small PR to update the demo as it seems very useful - and I will definitely make use of the signing examples in my application. Thanks again. https://github.com/ripple/ripple-libpp/pull/22 Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now