<center></center> <div class="text-justify"> Hace unos días se publicó un post desde la cuenta de Aliento, hablando de la nueva App que he ayudado a desarrollar [Ver anuncio](https://peakd.com/hive-110011/@aliento/pjpawhbg#@aliento/re-liveofdalla-r9dw42), así desde la misma comunidad han surgido dudas de como hago para solicitar datos a la blockchain Hive mediante APIs y para no responder la duda de manera individual, me motivé hacer este post. Para hacer requerimientos a la blockchain de una manera más común es mediante las APIs que integran a la plataforma, para ver todas las APIs puedes ingresar al siguiente link: <center>https://beacon.peakd.com/</center> Allí dentro de esa página puedes ver las diferentes APIs, donde la más popular es https://api.hive.blog #### ¿Qué necesito para extraer datos de Hive? + Conocimientos básicos en algún lenguaje de programación como Python o JavaScript + Instalar y explorar una librería de Hive correspondiente al lenguaje de programación que más domines, en mi caso uso [Beem](https://beem.readthedocs.io/en/latest/) para Python. + Un editor de texto como [sublimetext](https://www.sublimetext.com/) Estructura básica para extraer datos ``` ### Extraer las propiedades básicas de la blockchain from pprint import pprint from beem import Hive from beem.account import Account from beem.instance import set_shared_blockchain_instance hived_nodes = [ 'https://api.deathwing.me', 'https://api.openhive.network', ] hive = Hive(node=hived_nodes) pprint(hive.get_chain_properties()) ``` ------ Resultado: ``` {'account_creation_fee': {'amount': '3000', 'nai': '@@000000021', 'precision': 3}, 'account_subsidy_budget': 797, 'account_subsidy_decay': 347321, 'hbd_interest_rate': 1200, 'maximum_block_size': 65536} ``` Vamos a explorar la librería de Beem con un ejemplo: Lo primero que hacemos es ver como podemos extraer datos a partir de los módulos de Liberia mediante APIs [Ver](https://beem.readthedocs.io/en/latest/beem.account.html) <center></center> Para mostrar un ejemplo, voy a crear un código que me diga el balance de mi cuenta de Hive. Así está en la librería de Beem el módulo. <center></center> Solo debemos agregar los siguientes códigos, para saber el balance de una cuenta de Hive: ``` account = Account("enrique89", blockchain_instance= hive) balance = account.get_balances() pprint (balance) ``` Resultado: ``` {'available': [731.184 HIVE, 27.270 HBD, 10243276.539006 VESTS], 'rewards': [0.000 HIVE, 0.000 HBD, 994.817549 VESTS], 'savings': [0.000 HIVE, 0.000 HBD], 'total': [731.184 HIVE, 27.270 HBD, 10244271.356555 VESTS]} [Finished in 2.4s] ``` Ahora vamos a probar con la reputación: <center></center> Para solicitar la reputación agregamos el siguiente el código: ``` reputacion = account.get_reputation() pprint (reputacion) ``` Resultado: ``` 75.2643870917311 ``` Podemos interpretar que para solicitar información con la librería de Beem solo debemos sustituir el módulo. Hay algunas que tienen más variables como la siguiente: ``` get_notifications(only_unread=True, limit=100, raw_data=False, account=None) ``` Probamos el módulo: get_notifications(only_unread=True, limit=100, raw_data=False, account=None) Únicamente voy a modificar el limit y quitaré la variable account, con esta configuración me mostrará las no leídas. ``` notificaciones = account.get_notifications(only_unread=True, limit=10, raw_data=False) pprint (notificaciones) ``` Resultado: ``` [{'date': datetime.datetime(2022, 4, 12, 0, 17, tzinfo=<UTC>), 'id': 10217310, 'msg': '@poshtoken mentioned you and 123 others', 'score': 60, 'type': 'mention', 'url': '@poshtoken/posh-1649722618709'}, {'date': datetime.datetime(2022, 4, 11, 16, 29, 42, tzinfo=<UTC>), 'id': 10173683, 'msg': '@hive-data mentioned you and 31 others', 'score': 50, 'type': 'mention', 'url': '@hive-data/daily-twitter-data-reports-as-of-april-10-2022-2520-hive-tweets-of-the-day'}, {'date': datetime.datetime(2022, 4, 10, 23, 15, 27, tzinfo=<UTC>), 'id': 10095215, 'msg': '@victoriabsb mentioned you and 68 others', 'score': 60, 'type': 'mention', 'url': '@victoriabsb/hive-blockchain-la-guia-completa-para-nuevos-usuarios'}, {'date': datetime.datetime(2022, 4, 10, 22, 43, 3, tzinfo=<UTC>), 'id': 10092952, 'msg': '@reylimarian replied to your post', 'score': 40, 'type': 'reply', 'url': '@reylimarian/re-enrique89-ra5b3r'}, {'date': datetime.datetime(2022, 4, 10, 22, 23, 39, tzinfo=<UTC>), 'id': 10091467, 'msg': '@dhenz voted on your post ($2.74)', 'score': 75, 'type': 'vote', 'url': '@enrique89/es-momento-para-empezar-hive'}, {'date': datetime.datetime(2022, 4, 10, 20, 28, 12, tzinfo=<UTC>), 'id': 10080643, 'msg': '@orinoco voted on your post ($0.28)', 'score': 50, 'type': 'vote', 'url': '@enrique89/es-momento-para-empezar-hive'}, {'date': datetime.datetime(2022, 4, 10, 20, 11, 57, tzinfo=<UTC>), 'id': 10079481, 'msg': '@ladyunicorn voted on your post ($0.02)', 'score': 25, 'type': 'vote', 'url': '@enrique89/es-momento-para-empezar-hive'}, {'date': datetime.datetime(2022, 4, 10, 18, 23, 6, tzinfo=<UTC>), 'id': 10069980, 'msg': '@grisvisa mentioned you and 0 others', 'score': 60, 'type': 'mention', 'url': '@grisvisa/re-enrique89-ra4z2g'}, {'date': datetime.datetime(2022, 4, 10, 18, 23, 6, tzinfo=<UTC>), 'id': 10069979, 'msg': '@grisvisa replied to your post', 'score': 60, 'type': 'reply', 'url': '@grisvisa/re-enrique89-ra4z2g'}, {'date': datetime.datetime(2022, 4, 10, 17, 49, 9, tzinfo=<UTC>), 'id': 10067275, 'msg': '@nahupuku replied to your comment', 'score': 50, 'type': 'reply_comment', 'url': '@nahupuku/re-enrique89-ra4xhh'}] ``` Esto es parte de lo que puedes hacer con la Liberia de Beem conectada a la blockchain Hive, con esto ya comenzar o pensar en hacer muchas aplicaciones y soluciones para estar conectados a los datos de esta gran blockchain. Estaré publicando este tipo de post, para animar a los desarrolladores que están en Hive a producir aplicaciones, bot y más, que estén conectados a Hive. Saludos. </div> <center>https://images.hive.blog/0x0/https://files.peakd.com/file/peakd-hive/enrique89/zLRXvucf-rect908.png</center> <center> https://images.hive.blog/0x0/https://files.peakd.com/file/peakd-hive/enrique89/1wK1k8h4-rect4225.png </center>
author | enrique89 | ||||||
---|---|---|---|---|---|---|---|
permlink | hacer-consultas-a-la-blockchain-hive-mediante-apis-y-python | ||||||
category | hive-154226 | ||||||
json_metadata | {"app":"peakd/2022.04.4","format":"markdown","tags":["spanish","web3","python","blockchain","hive"],"users":["aliento","000000021","poshtoken","hive-data","victoriabsb","reylimarian","dhenz","enrique89","orinoco","ladyunicorn"],"image":["https://files.peakd.com/file/peakd-hive/enrique89/23t76t9qhNjrg7wTwPXUDVNPkdko1Wfu7jjwdWBaKKEBcsLTitD4ekLGHvUAf66u8TaX6.png","https://files.peakd.com/file/peakd-hive/enrique89/23tSz8K6WhzAF3ZymjePr6Q8zj5u1PPvdKf2j2Wu2Tb34ipZnac6gVAc5vuRiqZ1UJCQV.png","https://files.peakd.com/file/peakd-hive/enrique89/23y9KK8B12q5bdGi1wHBZV5zwhhtPytJAPsDwuZqEuwrb3o9QSGLVzX2NAWFSmg718HGe.png","https://files.peakd.com/file/peakd-hive/enrique89/23twAQDSDynrzMt4uYPq6sSG28T9DUvnVxAGbvrMXisL3b1C1xcgSTJ6RidrFk43RVc53.png","https://files.peakd.com/file/peakd-hive/enrique89/zLRXvucf-rect908.png","https://files.peakd.com/file/peakd-hive/enrique89/1wK1k8h4-rect4225.png"]} | ||||||
created | 2022-04-12 01:35:24 | ||||||
last_update | 2022-04-12 01:35:24 | ||||||
depth | 0 | ||||||
children | 4 | ||||||
last_payout | 2022-04-19 01:35:24 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 28.706 HBD | ||||||
curator_payout_value | 28.927 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 7,052 | ||||||
author_reputation | 664,568,480,404,036 | ||||||
root_title | "Hacer consultas a la blockchain Hive mediante APIs y Python" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 112,216,048 | ||||||
net_rshares | 51,153,403,954,882 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
rok-sivante | 0 | 2,684,122,656 | 100% | ||
gerber | 0 | 12,961,330,972 | 8% | ||
ezzy | 0 | 471,916,472 | 8% | ||
exyle | 0 | 71,007,412,800 | 8% | ||
anarcist69 | 0 | 5,529,792,831 | 7.5% | ||
jlufer | 0 | 9,917,039,603 | 100% | ||
clayboyn | 0 | 10,873,522,593 | 10% | ||
makinstuff | 0 | 15,321,118,803 | 12.5% | ||
rach | 0 | 2,226,315,431 | 100% | ||
shadowmyst | 0 | 17,958,093,098 | 100% | ||
delso | 0 | 43,808,483,733 | 100% | ||
amberyooper | 0 | 18,429,882,327 | 10% | ||
iansart | 0 | 28,313,202,692 | 8% | ||
followbtcnews | 0 | 149,447,775,774 | 15% | ||
minnowsupport | 0 | 3,618,693,008,953 | 25% | ||
crimsonclad | 0 | 226,333,424,870 | 15% | ||
joeyarnoldvn | 0 | 603,666,753 | 1.76% | ||
koh | 0 | 1,082,539,537 | 15% | ||
ernick | 0 | 5,503,787,510 | 50% | ||
knightwarrior | 0 | 1,187,676,585 | 12.5% | ||
felander | 0 | 44,806,334,984 | 8% | ||
cconn | 0 | 701,258,862 | 8% | ||
yogacoach | 0 | 8,246,984,716 | 8% | ||
karlin | 0 | 43,676,440,129 | 50% | ||
fatman | 0 | 8,102,911,442 | 2% | ||
oizaguirres | 0 | 6,823,932,417 | 50% | ||
viper160891 | 0 | 25,043,555,707 | 100% | ||
investegg | 0 | 282,335,154,026 | 11.9% | ||
imisstheoldkanye | 0 | 106,266,191,119 | 100% | ||
macodi1 | 0 | 722,395,781 | 50% | ||
hojaraskita | 0 | 716,600,548 | 50% | ||
leninbracho50 | 0 | 4,892,723,199 | 50% | ||
syllem | 0 | 17,474,024,397 | 50% | ||
elbrava | 0 | 4,380,508,082 | 50% | ||
nahupuku | 0 | 5,121,556,585 | 51% | ||
rodyservi | 0 | 521,408,438 | 50% | ||
pexpresiones | 0 | 20,141,813,412 | 50% | ||
yolmare | 0 | 37,091,314,451 | 50% | ||
ninachejov | 0 | 892,240,370 | 50% | ||
warpedpoetic | 0 | 3,117,009,734 | 12.5% | ||
unconditionalove | 0 | 820,434,701 | 4% | ||
reonfi | 0 | 4,797,573,922 | 100% | ||
jadams2k18 | 0 | 505,078,320 | 50% | ||
movement19 | 0 | 670,144,781 | 4.68% | ||
erilej | 0 | 3,962,517,745 | 25% | ||
victoriabsb | 0 | 77,658,049,554 | 20% | ||
fermionico | 0 | 160,856,584,586 | 25% | ||
reazuliqbal | 0 | 40,634,468,773 | 8% | ||
bestboom | 0 | 2,224,930,739 | 8% | ||
karolines | 0 | 3,205,354,430 | 50% | ||
axeltheartist | 0 | 3,627,030,789 | 50% | ||
abdulmath | 0 | 10,133,446,537 | 50% | ||
geadriana | 0 | 34,813,988,738 | 100% | ||
jolugo23 | 0 | 1,559,342,347 | 100% | ||
yonilkar | 0 | 10,219,132,903 | 100% | ||
meanbees | 0 | 2,221,277,234 | 0.8% | ||
solominer | 0 | 1,098,012,429,782 | 18.75% | ||
eleazarvo | 0 | 4,221,884,543 | 30% | ||
zaxan | 0 | 1,746,927,877 | 22.5% | ||
gabrielr29 | 0 | 4,720,474,201 | 100% | ||
raybull | 0 | 1,349,568,636 | 50% | ||
alcidescadiz | 0 | 33,673,386,174 | 50% | ||
carl05 | 0 | 1,551,353,457 | 100% | ||
jauregui98 | 0 | 32,538,968,757 | 100% | ||
joserafaelhf | 0 | 10,294,471,673 | 50% | ||
yormalis | 0 | 559,359,974 | 100% | ||
wendyth16 | 0 | 38,033,665,601 | 69% | ||
sbi7 | 0 | 88,328,724,647 | 40.56% | ||
themanny | 0 | 66,612,959,650 | 100% | ||
junior182 | 0 | 4,125,055,817 | 50% | ||
belial2412 | 0 | 5,129,013,562 | 50% | ||
bobby.madagascar | 0 | 2,346,539,309 | 8% | ||
voter001 | 0 | 74,408,088,038 | 89.3% | ||
racarjoal | 0 | 1,369,316,660 | 25% | ||
blarchive | 0 | 21,278,797,348 | 15% | ||
marinmex | 0 | 11,279,377,519 | 50% | ||
anarcist | 0 | 793,484,827 | 15% | ||
geeklania | 0 | 3,300,906,190 | 100% | ||
celi130 | 0 | 151,417,986,032 | 50% | ||
theycallmedan | 0 | 42,877,002,067,098 | 54% | ||
cakemonster | 0 | 3,610,623,369 | 4% | ||
gudnius.comics | 0 | 19,699,046,089 | 100% | ||
steem-on-2020 | 0 | 10,545,017,691 | 29% | ||
escuadron201 | 0 | 8,337,597,380 | 100% | ||
miguelmederico | 0 | 4,622,017,997 | 40% | ||
princessdani | 0 | 1,338,414,686 | 50% | ||
mfblack | 0 | 1,062,688,371 | 7.6% | ||
lazybug | 0 | 849,797,125 | 25% | ||
yiobri | 0 | 16,836,135,769 | 50% | ||
firefuture | 0 | 545,217,456 | 4% | ||
milu-the-dog | 0 | 1,322,291,669 | 8% | ||
triplea.bot | 0 | 1,869,055,837 | 8% | ||
iraeli | 0 | 1,320,555,540 | 50% | ||
steem.leo | 0 | 9,459,610,418 | 8% | ||
beta500 | 0 | 8,740,047,845 | 8% | ||
liaminit1 | 0 | 7,386,500,796 | 90% | ||
whangster79 | 0 | 261,964,779,496 | 18.75% | ||
ribary | 0 | 2,802,685,980 | 4% | ||
mice-k | 0 | 728,627,689 | 8% | ||
dpend.active | 0 | 561,013,593 | 1.6% | ||
nildasalazar | 0 | 1,264,770,060 | 50% | ||
dcityrewards | 0 | 255,865,609,038 | 8% | ||
lqch | 0 | 39,860,451,855 | 100% | ||
benantca | 0 | 2,215,900,146 | 50% | ||
patronpass | 0 | 500,515,900 | 8% | ||
obandoduarte | 0 | 10,219,341,014 | 50% | ||
sevalo13 | 0 | 4,223,098,912 | 50% | ||
recoveryinc | 0 | 5,512,503,538 | 9.37% | ||
josemoises | 0 | 7,319,941,726 | 50% | ||
lenincarrizo | 0 | 7,517,070,718 | 50% | ||
vicnzia | 0 | 7,901,940,802 | 25% | ||
dying | 0 | 561,904,591 | 18.75% | ||
ilsanunez | 0 | 4,302,736,396 | 50% | ||
ochitoalreves | 0 | 80,940,196,856 | 67% | ||
leone.bianco | 0 | 1,059,023,632 | 100% | ||
melochacalie | 0 | 2,045,198,631 | 50% | ||
alimaneiro | 0 | 7,458,033,374 | 50% | ||
paolazun | 0 | 1,080,601,745 | 12.5% | ||
doudoer | 0 | 0 | 100% | ||
jesusin | 0 | 2,076,826,157 | 50% | ||
dcrops | 0 | 28,696,299,243 | 4% | ||
samrisso | 0 | 5,977,839,133 | 9.37% | ||
tomtothetom | 0 | 2,368,385,832 | 18.75% | ||
drricksanchez | 0 | 45,640,722,004 | 10% | ||
surglen | 0 | 20,079,022,584 | 100% | ||
merwinrod | 0 | 1,370,379,912 | 75% | ||
jaybone | 0 | 847,876,516 | 100% | ||
zapataalex | 0 | 1,364,006,512 | 100% | ||
yulilemus02 | 0 | 0 | 100% | ||
pishio | 0 | 461,146,899,689 | 8% | ||
iamleicester | 0 | 560,937,251 | 90% | ||
cugel | 0 | 3,376,598,652 | 9.37% | ||
javivisan | 0 | 3,563,815,715 | 100% | ||
detrasdelbar | 0 | 4,900,080,592 | 100% | ||
lugodev | 0 | 1,677,377,776 | 100% | ||
ragnarokreinier | 0 | 764,363,004 | 100% | ||
hoffmeister84 | 0 | 1,264,633,900 | 50% | ||
mariano123 | 0 | 3,164,907,954 | 100% | ||
yendiradigital | 0 | 2,981,640,857 | 100% | ||
lovely.logic | 0 | 2,042,582,123 | 12.5% | ||
neocientiacu | 0 | 460,395,128 | 100% | ||
xtheycallmedan | 0 | -443,145,031 | -54% | ||
edopujol | 0 | 638,309,786 | 100% |
<center>[](https://hivebuzz.me/@enrique89) <center>@enrique89, sorry to see you have less Hive Power. Your level lowered and you are now a **Minnow**!</center> **Check out the last post from @hivebuzz:** <table><tr><td><a href="/hive-122221/@hivebuzz/pum-202204-6"><img src="https://images.hive.blog/64x128/https://i.imgur.com/R438YeH.png"></a></td><td><a href="/hive-122221/@hivebuzz/pum-202204-6">Hive Power Up Month - Feedback from April day 6</a></td></tr></table> ###### Support the HiveBuzz project. [Vote](https://hivesigner.com/sign/update_proposal_votes?proposal_ids=%5B%22199%22%5D&approve=true) for [our proposal](https://peakd.com/me/proposals/199)!
author | hivebuzz |
---|---|
permlink | notify-enrique89-20220413t073458 |
category | hive-154226 |
json_metadata | {"image":["http://hivebuzz.me/notify.t6.png"]} |
created | 2022-04-13 07:34:57 |
last_update | 2022-04-13 07:34:57 |
depth | 1 |
children | 0 |
last_payout | 2022-04-20 07:34:57 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 755 |
author_reputation | 370,655,473,623,475 |
root_title | "Hacer consultas a la blockchain Hive mediante APIs y Python" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 112,253,569 |
net_rshares | 0 |
Muchísimas gracias por tu post, soy un usuario con conocimientos básicos en Python pero es muy sencillo trabajar con las APIS para obtener datos. Ya me hice un bot en Telegram alojado en una Rasberry Pi que me envía información de mis cuentas de Splinterlands. Espero seguir aprendiendo con estos tutoriales. Uno de como enviar automáticamente tokens de una cuenta a otra sería maravilloso. ¡Te felicito!
author | javivisan |
---|---|
permlink | re-enrique89-ra809o |
category | hive-154226 |
json_metadata | {"tags":["hive-154226"],"app":"peakd/2022.04.4"} |
created | 2022-04-12 09:41:48 |
last_update | 2022-04-12 09:41:48 |
depth | 1 |
children | 0 |
last_payout | 2022-04-19 09:41:48 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 404 |
author_reputation | 278,634,217,465,295 |
root_title | "Hacer consultas a la blockchain Hive mediante APIs y Python" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 112,224,697 |
net_rshares | 0 |
https://twitter.com/enriquevee/status/1513937696292491266 <sub> The rewards earned on this comment will go directly to the person sharing the post on Twitter as long as they are registered with @poshtoken. Sign up at https://hiveposh.com.</sub>
author | poshtoken | ||||||
---|---|---|---|---|---|---|---|
permlink | re-enrique89-hacer-consultas-a-la-blockchain-hive-mediante-apis-4564 | ||||||
category | hive-154226 | ||||||
json_metadata | "{"app":"Poshtoken 0.0.1"}" | ||||||
created | 2022-04-12 18:11:27 | ||||||
last_update | 2022-04-12 18:11:27 | ||||||
depth | 1 | ||||||
children | 0 | ||||||
last_payout | 2022-04-19 18:11:27 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 0.000 HBD | ||||||
curator_payout_value | 0.000 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 245 | ||||||
author_reputation | 5,661,158,329,216,187 | ||||||
root_title | "Hacer consultas a la blockchain Hive mediante APIs y Python" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 0 | ||||||
post_id | 112,236,765 | ||||||
net_rshares | 0 |
Gracias por el post. No conocía esta comunidad ni esa librería para Python. Pronto estaré mostrando algunas cosillas interesantes que quiero hacer 🙃
author | ragnarokreinier |
---|---|
permlink | re-enrique89-ra94tl |
category | hive-154226 |
json_metadata | {"tags":["hive-154226"],"app":"peakd/2022.04.5"} |
created | 2022-04-13 00:17:48 |
last_update | 2022-04-13 00:17:48 |
depth | 1 |
children | 0 |
last_payout | 2022-04-20 00:17:48 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 148 |
author_reputation | 1,142,478,689,879 |
root_title | "Hacer consultas a la blockchain Hive mediante APIs y Python" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 112,245,421 |
net_rshares | 0 |