/ethermine_api

Lightweight Ruby wrapper for the ethermine.org API

Primary LanguageRubyMIT LicenseMIT

EthermineApi

Light weight ethermine.org api wrapper written in Ruby

Installation

Add this line to your application's Gemfile:

gem 'ethermine_api'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ethermine_api

Usage

Ethpool, Ethermine & Flypool provide a harmonized API for accessing all publicly available information. Access to the API is limited to 100 requests / 15 minutes / ip. All information is cached for 2 minutes so there is no point in making more frequent requests.

ethermine.org api doc

Pool

Basic Pool Stats

EthermineApi::Pool.stats
# => #<OpenStruct status="OK", data=#<OpenStruct minedBlocks=[#<OpenStruct number=4380856, miner="f6F26015F0760f7A4B7f93E765bc48883Daf79a5", time=1508297435>, #<OpenStruct number=4380847, miner="848F0a6dC1ABe357b56892884C97387348858CA2", time=1508297307>, #<OpenStruct number=4380847, miner="10a7b4813166d8aa2ee61762d727010524a3927d", time=1508297282>, #<OpenStruct number=4380843, miner="3509F7bd9557F8a9b793759b3E3bfA2Cd505ae31", time=1508297257>, #<OpenStruct number=4380842, miner="bc049f47d8d6cdcf8d784aeb66bc0bbdd7dc1a45", time=1508297254>,#<OpenStruct number=4380830, miner="2F73FDA67B06b617a5d5F4de2c81b3427D53C680", time=1508297118>, #<OpenStruct number=4380826, miner="a23a1970cdb3eb47bff9e04171141776fe8a6cb1", time=1508297084>, #<OpenStruct number=4380823, miner="f88798b68067166e6d2fb1c50b7934db688fa118", time=1508297024>, #<OpenStruct number=4380821, miner="92CF722FAbF55fb8Bff11beebaC58897D242D8a6", time=1508297003>, #<OpenStruct number=4380820, miner="00F8f4508ddF1F210C1874060B4Ceab5dDAbd13E", time=1508296997>], topMiners=[#<OpenStruct miner="f1b3e00955d7cbcde70f4337e333cd84da3a1c36", hashRate=461864222222.22217>, #<OpenStruct miner="276b88fe9f3d8dc71a53034cc052f62648e3e99f", hashRate=196604222222.22223>, #<OpenStruct miner="b7b03ce91e5826bd8d223b15dedbdb8ef4ddd4a8", hashRate=184991888888.8889>, #<OpenStruct miner="362c89a6d8a1597ff41eb03e1e897d0d95827c54", hashRate=125916722222.22234>, #<OpenStruct miner="a65f825e4f82c26aee244512cba7add256bc0788", hashRate=123880111111.11111>, #<OpenStruct miner="482f7753b3d62c7d1fd0fdcb8fcc2d61704dfced", hashRate=81146333333.33336>, #<OpenStruct miner="58801ebec6685d0d5461a30999fa5df91549a59e", hashRate=78271888888.88887>, #<OpenStruct miner="68847a67605350c471b7a46c0ef27206512a6a14", hashRate=70088000000>, #<OpenStruct miner="0d4efc9557218e6ac6431c9d45ed7b4770cbe252", hashRate=69118111111.11111>, #<OpenStruct miner="d060904aa97c021ec31c8a502a8b2443f51a38bd", hashRate=64865666666.666664>], poolStats=#<OpenStruct hashRate=28705896277778.773, miners=66733, workers=230401, blocksPerHour=69.63>, price=#<OpenStruct usd=307.1, btc=0.05606>>>

Credits list (only for ethpool.org)

EthermineApi::Pool.credits(base_url: 'http://api.ethpool.org')
# => #<OpenStruct status="OK", data=[#<OpenStruct miner="87e22465bfe36496ae21a23c0be5f5956480e25b", hashrate=414166666.6666666, credit=2645199800000000>, #<OpenStruct miner="4ef8295f6D04452DD8aD040bf43Da859379Dc564", hashrate=238333333.33333337, credit=2634510200000000>, #<OpenStruct miner="249586e792dB363A179A259060bF32fd6C36c013", hashrate=257722222.2222222, credit=2632519800000000>, #<OpenStruct miner="2B9F67024dC91dEbab6A322d27201f5F80f6b06A", hashrate=945888888.888889, credit=2631665684962467>,...]>

Mined Block Stats

EthermineApi::Pool.blocks_history
# => #<OpenStruct status="OK", data=[#<OpenStruct time=1508212736, nbrBlocks=15, difficulty=1469986226066083>, #<OpenStruct time=1508216246, nbrBlocks=76, difficulty=1498157811667782>, #<OpenStruct time=1508219985, nbrBlocks=65, difficulty=1495924338718297>, #<OpenStruct time=1508223454, nbrBlocks=77, difficulty=1470413115601682>, #<OpenStruct time=1508227187, nbrBlocks=65, difficulty=1460372702365663>, #<OpenStruct time=1508230751, nbrBlocks=70, difficulty=1460910425240631>, #<OpenStruct time=1508234363, nbrBlocks=75, difficulty=1456608509189655>, #<OpenStruct time=1508237945, nbrBlocks=67, difficulty=1423382928506978>, #<OpenStruct time=1508241532, nbrBlocks=52, difficulty=1425447900135137>, #<OpenStruct time=1508245190, nbrBlocks=63, difficulty=1400461436689854>, #<OpenStruct time=1508248720, nbrBlocks=76, difficulty=1410667703939148>, #<OpenStruct time=1508252389, nbrBlocks=71, difficulty=1409925035518444>, #<OpenStruct time=1508255870, nbrBlocks=71, difficulty=1389940935574532>, #<OpenStruct time=1508259561, nbrBlocks=77, difficulty=1407629306676071>, #<OpenStruct time=1508263181, nbrBlocks=61, difficulty=1399384875766905>, #<OpenStruct time=1508266793, nbrBlocks=69, difficulty=1393112908301133>, #<OpenStruct time=1508270344, nbrBlocks=85, difficulty=1390290461807211>, #<OpenStruct time=1508273983, nbrBlocks=78, difficulty=1404529417941880>, #<OpenStruct time=1508277469, nbrBlocks=67, difficulty=1407907030026226>, #<OpenStruct time=1508281198, nbrBlocks=76, difficulty=1424382704053059>, #<OpenStruct time=1508284770, nbrBlocks=79, difficulty=1442483911584531>, #<OpenStruct time=1508288359, nbrBlocks=70, difficulty=1435421392397694>, #<OpenStruct time=1508291898, nbrBlocks=76, difficulty=1433857401029767>, #<OpenStruct time=1508295581, nbrBlocks=58, difficulty=1433133675561812>, #<OpenStruct time=1508298258, nbrBlocks=62, difficulty=1426020651269258>]>

Network Stats

EthermineApi::Pool.network_stats
# => #<OpenStruct status="OK", data=#<OpenStruct time=1508298297, blockTime=14.2129, difficulty=1417655795160128, hashrate=107244424361637, usd=306.59, btc=0.05612>>

Server Hashrate Stats

EthermineApi::Pool.servers_stats
# => #<OpenStruct status="OK", data=[#<OpenStruct miner="87e22465bfe36496ae21a23c0be5f5956480e25b", hashrate=414166666.6666666, credit=2645199800000000>, #<OpenStruct miner="4ef8295f6D04452DD8aD040bf43Da859379Dc564", hashrate=238333333.33333337, credit=2634510200000000>, #<OpenStruct miner="249586e792dB363A179A259060bF32fd6C36c013", hashrate=257722222.2222222, credit=2632519800000000>, #<OpenStruct miner="2B9F67024dC91dEbab6A322d27201f5F80f6b06A", hashrate=945888888.888889, credit=2631665684962467>, #<OpenStruct miner="667C28528018a7Aa3179f3E3DA620E15EDBEED79", hashrate=1324111111.1111112, credit=2626431262474482>,...]>

Miner

History

EthermineApi::Miner.history(id: <miner hash>)
# => #<OpenStruct status="OK", data=[#<OpenStruct time=1508212800, reportedHashrate=0, currentHashrate=223833333.33333334, validShares=193, invalidShares=0, staleShares=13, averageHashrate=255819830.24691355, activeWorkers=3>, #<OpenStruct time=1508213400, reportedHashrate=0, currentHashrate=223111111.1111111, validShares=193, invalidShares=0, staleShares=12, averageHashrate=255527777.77777773, activeWorkers=3>, #<OpenStruct time=1508214000, reportedHashrate=0, currentHashrate=228666666.6666667, validShares=198, invalidShares=0, staleShares=12, averageHashrate=255189429.01234564, activeWorkers=3>,...]>

Payouts

EthermineApi::Miner.payouts(id: <miner hash>)
# => #<OpenStruct status="OK", data=[#<OpenStruct start=4246675, end=4342309, amount=1000144114602165800, txHash="0x376914aba43724b4637bfac6c0ba3d852f01de6ac9e82f988d8e9663e1f52475",paidOn=1507307206>, #<OpenStruct start=4157914, end=4246641, amount=1000300147302413600, txHash="0xeb92d2762a20b7e6ff46ad8f63aeec36227c2674fd0d6da5920b8e22fe261e92", paidOn=1504755124>, #<OpenStruct start=4099637, end=4157883, amount=1000299829170798700, txHash="0x36d380088e9a236a9900aaec0c8e54b3237344071afc79ea394aa63a4cfd1d6f", paidOn=1502740295>, #<OpenStruct start=3976116, end=4099603, amount=1000219294965464200, txHash="0x669907742afefae8c00cc4c2e086caf9890f1efa787ca7b109370465dc45167a", paidOn=1501505905>]>

Rounds

EthermineApi::Miner.rounds(id: <miner hash>)
# => #<OpenStruct status="OK", data=[#<OpenStruct time=1508212800, reportedHashrate=0, currentHashrate=223833333.33333334, validShares=193, invalidShares=0, staleShares=13, averageHashrate=255819830.24691355, activeWorkers=3>, #<OpenStruct time=1508213400, reportedHashrate=0, currentHashrate=223111111.1111111, validShares=193, invalidShares=0, staleShares=12, averageHashrate=255527777.77777773, activeWorkers=3>, #<OpenStruct time=1508214000, reportedHashrate=0, currentHashrate=228666666.6666667, validShares=198, invalidShares=0, staleShares=12, averageHashrate=255189429.01234564, activeWorkers=3>,...]>

Settings

EthermineApi::Miner.settings(id: <miner hash>)

Statistics

EthermineApi::Miner.stats(id: <miner hash>)
# => #<OpenStruct status="OK", data=#<OpenStruct time=1508300400, lastSeen=1508300391, reportedHashrate=0, currentHashrate=253166666.66666666, validShares=222, invalidShares=0, staleShares=9, averageHashrate=207042908.762421, activeWorkers=3, unpaid=367761185780908740, unconfirmed=nil, coinsPerMin=2.4266033723587824e-05, usdPerMin=0.007550619053431588, btcPerMin=1.3637510952656358e-06>>

Worker

All Worker Statistics

EthermineApi::Worker.all(miner_id: <miner hash>)
# => #<OpenStruct status="OK", data=[#<OpenStruct worker="bitty-balls", time=1508299200, lastSeen=1508299195, reportedHashrate=0, currentHashrate=123611111.1111111, validShares=108, invalidShares=0, staleShares=5, averageHashrate=130379629.62962958>, #<OpenStruct worker="bitty-booge", time=1508299200, lastSeen=1508299157, reportedHashrate=0, currentHashrate=111055555.55555555, validShares=98, invalidShares=0, staleShares=3, averageHashrate=89804783.95061725>, #<OpenStruct worker="bitty-boosh", time=1508299200, lastSeen=1508299199, reportedHashrate=0, currentHashrate=27000000, validShares=23, invalidShares=0, staleShares=2, averageHashrate=27170524.69135802>]>

Individual Historical Worker Statistics

EthermineApi::Worker.history(id: <worker id>, miner_id: <miner hash>)

Individual Worker Statistics

EthermineApi::Worker.stats(id: <worker id>, miner_id: <miner hash>)

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ethermine_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the EthermineApi project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.