Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: sanoplay on February 12, 2019, 08:35:48 PM



Title: Developing of API
Post by: sanoplay on February 12, 2019, 08:35:48 PM
Hello guys, i need your help.
I'm trying to create an API. With help of this API i would like to get statistics for the last 24 hours of Bitcoin network and return something like that:
  • Amount of mined blocks
  • Amount of transactions
  • Hashrate

and so on...

Can you suggest me, how i can access this data without using others APIs?

Thanks

GL and have a good day, guys!


Title: Re: Developing of API
Post by: mocacinno on February 12, 2019, 08:39:18 PM
If you want a quick and easy sollution, check out https://bitcore.io

If you want to do it yourself, you'll have to run a full node and either use the json-rpc interface and build a custom api on top of it, or build a block parser, extract the needed data and build an api on top of this data


Title: Re: Developing of API
Post by: sanoplay on February 13, 2019, 05:59:27 PM
Thank you!
I'll explore and try.

GL


Title: Re: Developing of API
Post by: KingZee on February 14, 2019, 05:25:29 AM
Thank you!
I'll explore and try.

GL

Why don't you want to use an external API?

There are a lot of great solutions out there, even for free. I would recommend chain.so, they have the best realtime socket setup, and you can subscribe to events like mew blocks, or new mempool txes.

Parsing blocks and txes yourself from the full node is a total pain in the ass, while it would be a great idea if you're looking to learn, it's a waste of time if you have some business end-goal from this..


Title: Re: Developing of API
Post by: 100bitcoin on February 16, 2019, 08:35:20 PM
Thank you!
I'll explore and try.

GL

Why don't you want to use an external API?

There are a lot of great solutions out there, even for free. I would recommend chain.so, they have the best realtime socket setup, and you can subscribe to events like mew blocks, or new mempool txes.

Parsing blocks and txes yourself from the full node is a total pain in the ass, while it would be a great idea if you're looking to learn, it's a waste of time if you have some business end-goal from this..

Sometimes, running a full node, is a cost overhead.


Title: Re: Developing of API
Post by: c_atlas on February 17, 2019, 06:23:44 PM
Why don't you want to use an external API?
Could be they want to verify everything themselves and not trust another node. If that's the case they could just aggregate the stats from multiple APIs and avg it out while keeping an eye out for outliers. Probably still easier than running a full node and you've got a bit more assurance.


Title: Re: Developing of API
Post by: Carlton Banks on February 17, 2019, 08:05:54 PM
If you want a quick and easy sollution, check out https://bitcore.io

that software should come with a health warning...


From the bitcore.io front page:

Quote
Bitcore uses the source code (https://github.com/bitcoin/bitcoin/) of Bitcoin directly, so accidental chain forks are a thing of the past.

Right, except when Bitpay change the underlying source code to switch you to a different chain fork, deliberately. At least Bitpay tell you they do this kind of thing, they tell you "bad things will happen" if you don't use the software that uses the chain fork they think you should use.


Unless you want to constantly check how Bitpay are imposing their self-interest on the code you run, you're better off choosing a solution that you can rely on permanently. Or fork their API and patch it into the Bitcoin source code, then you can be compatible with the API and use trustworthy source for the bitcoin network (assuming the API does the job you want)


Title: Re: Developing of API
Post by: CreateCryptoCo.in on February 19, 2019, 12:00:50 AM
best would be to talk directly to bitcoind, throw the rpc interface, just send some json and parse it.

In that way you will not really need to rely to much on any third party(often they come and go).
You might want to have like 2 urls that you get the current block from for checking that your node is up to date.

Alot of blockexplorers work like this, and you will both learn more and offer a better service that you can scale, The down side is that you will have to allocate like 300/250 gb of diskspace for the bitcoins blockchain


Title: Re: Developing of API
Post by: legendster on February 27, 2019, 09:21:18 PM
Hi OP, I know you don't want to use external API's but you can rely on insight (https://insight.is/)
They're open source so you can probably modify and redeploy according to your own needs. This is, of course, if you're sticking to commercial or personal uses and not something proprietary.