-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON Web API #55
Comments
Any feature requests and feedback are welcome. At the moment not sure if it would be good to add them in the explorer, or make it a separate project. Open Monero project's aim is all about making REST JSON service for monero, so maybe it would be easier to add it there. But then maybe explorer is better for this in this case, as your api endpoints are more specific to the explorer's functionality. Don't know yet, guess it depends what data would you like to see in the json response. If you have an example of a specific json response, I can try adding it to the explorer first, if its not too complicated, and see how it works. But like I wrote in the earlier issue, before I start working "full time" on something new, such as json or cmake builds, I need to finish other things. Thus, not sure when I could add full api support, except adding one or two endpoints for quick tests at the moment, if they would not require lots of changes to existing codebase. |
The endpoint are indeed essentially identical to what the block explorer currently has, but I agree OpenMonero is centered around REST JSON services. Here's what I came up with for the spec for the first two endpoints:
It would be nice if the transactions API let you set the limit like I describe, maybe with a cap at 25. I can see myself only needing 10 usually, but sometimes wanting more or less, so it would be nice to have a dynamic limit. The pagination might tricky if you start including limits, so feel free to not do limits if it starts becoming annoying. More of a nice-to-have. |
Thanks. I will try to come up with something next week, and will let you know if something has happened in this regard. |
JSON api was added. Information are in README in this branch: If you want you can test it, see what is there, what is missing, etc. Any feedback welcomed as usual. |
Wow!!! Going to give this a spin now. |
Looks amazing so far. I've already gotten started on prototyping my web app now that these API's are in place. Thanks for doing this. |
Could you enable cross origin requests (CORS)? Maybe this link helps... ipkn/crow#201 |
@moneroexamples I'm noticing that tx_fee (at least for mempool, probably for tx too) is some variable amount of digits. Could it always be 12 units, with 0's all the way out until it hits the 12 digits? I even converted your python
|
Hi I added the header for cors:
Fees are just represented as unsigned integer of base 1e12. So divide them by p.s. |
Looks good. As a side not you can also pull some info from monero deamon itself, if something is not available through the explorer. Also maybe can add something extra functionality. For example, some statistics about network. Currently there is this http://monerostats.com/ but i think its dead now. There is also this http://moneroblocks.info/stats but its rather basic. p.s. |
I'm getting close to a public release Here's where I am right now: http://monerochain-166203.appspot.com/ I'll have an ability to switch "nodes" - basically whatever domain the API is hosted on. There's some mobile weirdness that I have to fix, and some other misc tweaks, but its mostly done. Tell me what you think! |
Looks awesome. The only comment I can have at the moment is that on front page it shows last 25 txs, but there is no button to show older ones, like going to next page back in the blockchain. Not sure this is intentional or not? Also probably in tx page, you would need to rename the fields to be more user friendly. For example, |
@moneroexamples Yup - pagination is being worked on. And yeah, some of those fields should probably be changed. I'm just using whatever the API returns right now |
@moneroexamples Could you add the # of total pages in the response for |
Just added it. Its in As a side note, Let me know if something else is needed or something is buggy:-) |
Thank you so much!
One thing - I previously suggested a pattern like `/api/v1/<blah>`, in part
because changes to existing fields can have unintended affects. Adding the
public keys of the mixins (making mixins value a dictionary instead of just
a flat value) actually broke my table due since it expected flat data.
Obviously I'm using your dev environment for my dev so I shouldn't assume
any stability there, but it would be nice if the api had versioning so that
cool updates like this could exist without changing the structure of the
data for the current version.
…On Sun, May 7, 2017 at 1:22 AM, moneroexamples ***@***.***> wrote:
Just added it. Its in total_page_no variable.
As a side note, api/transaction has been extended: public keys of mixins
have been added to key images in api/transaction calls.
Let me know if something else is needed or something is buggy:-)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#55 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHf02WoLo8Bz7g36MEF2EddsSZ96tdAPks5r3WM2gaJpZM4M-iTK>
.
|
I remember and sorry for breaking things. The explorer itself does not have any versioning or tags yet. Its more a rolling release, like arch linux, and sometimes things break unfortunately. But I think that in future will start tagging it. Was thinking to be in sync with monero releases. So probably when monero will have next release, I will tag the explorer as well. At the moment I dont plan making more changes to existing json, unless there are some bugs or feature requests. Again sorry for breaking your tx page. |
No worries! Thanks again for adding the And a tagged, versioned release sounds good! |
@moneroexamples Check it out - added paging. Last thing to add is ability to choose back-end "node" (REST API host) and then I think its good for a 1.0 release! |
I do have one additional request actually - mempool is beginning to get quite large (200 currently) and I forsee it getting bigger as monero grows in popularity. Could pagination (and page limiting) be included in the mempool api? |
400 now and 16MB. woow :-) Pagination for mempool is problematic, because it changes very fast. So whatever page number you get in a first request, in a second request, few minutes later, it might be incorrect. That's said I think a good start would be to add option, e.g. But I cant add this today. Maybe tomorrow. |
Just the heads up. Mempool api will break. I'm adding limits and pages, so it will be similar to api/transactions api. Its not yet live on development server, but changes are being made in this branch: https://github.com/moneroexamples/onion-monero-blockchain-explorer/tree/json_mempool_add_limit |
Cool - so you did decide to go with paginating the mempool? Can I ask that you add a And one last thing - could you also add a |
I will add pagination as well, just to check how it work. Results will be interesting, as mempool changes rapidly. The new mempool is already live for tests. Its not merged yet to master, as need more testing, you can have a look already how it shapes up.
As a side note. If you use chrome or chromium, I use this extension to nicely parse the json output from those url: Maybe it will be helpful, if you dont use something similar already. |
I do use that extension already! I like it. Could you let me know when the new mempool is up on your dev server? Doesn't seem to be on the dev server right now (139.162.32.245) actually seems to be down. Excited to implement this final thing and then move to a stable release! |
@moneroexamples Great idea! Actually the fact that your dev server is http solves the issue of safari / edge, so I may even default to that unless you say not to. And yes, good idea for adding testnet support. I'm going to do that as well, and then put up a banner saying testnet when its enabled. |
The existent explorer json api wont be changing anymore I think. But I will add one or two new calls probably. Having said that the explorer will be going off line from time to time as I work on it. Currently, adding some network info to index pages as per this issue: So having the dev server as default is not good idea in my view, unless you can detect that its off online and switch to alternative one quickly. I think your project is very nice. once it grows and more nodes will join, can have unique set of stats and information constructed using the aggregate of these nodes. |
Interesting... @suhz A bit of a silly ask, but any chance you could host a non-https explorer on another subdomain? The reason I need this is because certain browsers (edge, safari), don't like it when you make cross-domain cross http-https requests, and glitch out. Let me know if thats something you're willing to do :) |
@dternyak Sorry, I do not think I can do that because xmr.my have HSTS preloaded, including subdomains. it will still redirect to https even if that subdomain is not exist. Another way to do this is to host the api on new top level domain. Or, maybe you can create new subdomain (eg: api.monerochain.com), and CNAME it to my server (node.xmr.my). I can configure my server to serve the API for your domain. |
Maybe changing headers for json would help? Currently the headers are:
If you know any better or more permissive ones, I can change it. |
@moneroexamples - I don't think its a backend header thing, I think its a browser thing. @suhz - having CNAME point to your server from my subdomain would be awesome. I'm not super familiar with DNS and how that works - is it as simple as adding a CNAME record with setting host to I tried the above, but it didn't work, so I probably did something wrong. |
@dternyak I see that you've already pointed it to my server. It didn't work earlier because I haven't yet configure it for your domain. It works now, try http://api.monerochain.com/api/mempool EDIT |
@suhz Thank you! And I definitely understand about the limiting. How has the traffic been so far? I've purposefully added no analytics whatsoever so I really have no way of knowing. |
@dternyak I don't log either. But I can see how much bandwidth it consume each day. |
fyi. just added version to api. |
Not sure you know but https://moneroexplorer.com/ node seems down. Also, just merged huge PR into master in preparation for the next monero release. Just in case you want to use current master, latest development version of monero is needed. |
@moneroexamples thanks, actually its still syncing. I've accidently deleted whole .bitmonero folder few days ago, where I wanted to actually just delete the one for testnet. silly me. |
No problem. The merged PR has lots of changes, including templates. This is this PR: #75 Most imporantly, mempool has been revamp. Now it is its own, separate thread, that periodically checks the mempool. Up until now, each http request resulted in mempool check, which could be very intensive for a server. Hopefully now, mempool processing will be better. |
@moneroexamples I was unable to compile the latest explorer, it is related to ssl something. I unistall openssl that comes with ubuntu 16.04, compile & install openssl 1.1, and still didn't help. Here is the error - https://pastebin.com/raw/5Lnc8wzm |
From the pastebin, it seems that one reason could be that explorer did not find
Are you sure you are running recent monero development version? This is new library, not present in 10.3.1, from what I recall. Also, whenever you run |
okay, I pull latest monero master (commit 48f96c18dfa8d2f5c86dc7c6c538b0b003992200) fresh into new folder and built it. compiling explorer, also in fresh build folder, Xmr_CNCRYPTO_LIBRARIES issue seems fixed. but there is still error related to SSL which I do not understand. Please have a look - https://pastebin.com/raw/qYAvth9P |
On ubuntu I use this dependencies for ssl: |
I have that installed already
|
I think I know what is happening. Same issue was reported here microsoft/cpprestsdk#132 and was identified as bug of boost with openssl 1.1. You are running |
note sure what happen with my VPS, I ended up reinstalling it with fresh ubuntu. now it works. Thanks :) |
good it works now:-) |
@moneroexamples Any chance you could double check to see you enabled CORS? I would like to piggy back off of xmrchain.net (as @Gingeropolous has previously seemed ok with it), but the server is responding with:
|
In the meantime, I could proxy requests via my own backend, but this somewhat defeats the purpose of an entirely client side blockchain explorer that works with any |
I have these headers set for api:
If other values or new heards are needed, I would be grateful for info how and what to set. I dont know if xmrchain is using the onion explorer version with these headers. Can you check using this explorer: https://moneroexplorer.com/ This one for sure should be using latest version and have these headers. |
@moneroexamples Using MoneroExplorer does indeed fix my problem -- XmrChain.net must not have been on the latest version (and missing those headers as a result). http://monerochain.com is fully functioning once again! Thank you for your help. |
Cool it works. Thanks for the info. |
@moneroexamples I think this issue has served it's purpose ;) I'll be closing this one now, thanks again on your hard fork maintaining this and other projects. |
No problem, and thanks for help with the api. |
I'd like to create some some Web Apps based on the extremely performant and feature-rich back-end of this project. This will be much easier to do if there is a web-facing JSON API to interact with.
Ideally, the JSON API would expose the following endpoints (to start):
/api/v1/mempool
/api/v1/search?blkhash='blah'/?txhash/etc
. Ideally all the supported search types of the main site./api/v1/transactions?page=1
/api/v1/transactions?page=2
/api/v1/tx/<tx_hash>
I'll work to develop the spec of the JSON response itself for each endpoint, but sane defaults will also be fine. Basically whatever is already being returned to the traditional back-end rendered template handlerbar/mustache engine would be great.
I'm not sure how much work this is, or how realistic it is to even ask for this, but I'm hoping that it can be fairly easily integrated given the existing architecture.
However, I also understand that this project has a focus on darknet support, which is not especially compatible with the type of service I am proposing. Perhaps a fork of this project is a better proposal?
Eager to hear your thoughts. This is probably an ambitious ask, so please let me know if I am overreaching.
The text was updated successfully, but these errors were encountered: