RE: Python Libraries: No More BEEM
You are viewing a single comment's thread:
I think you can use the ‘requests’ library to make HTTP requests to the Hive API.
Suppose you have a function that publishes a publication using BEEM:
from beem import Hive
def publicar_mensaje(usuario, clave_privada, mensaje):
Hive = Hive(keys=[clave_privada])
hive.post(mensaje, author=usuario)
You can replace it using the Hive API directly with requests:
import requests
def publicar_mensaje(usuario, clave_privada, mensaje):
url = "https://api.hive.blog/rpc"
payload = {
"jsonrpc": "2.0",
"method": "condenser_api.post",
"params": [usuario, clave_privada, "", mensaje, "", False],
"id": 1,
}
response = requests.post(url, json=payload)
print(response.json())
Or something like that. It's a matter of investing another weekend and doing the relevant tests.
This is tested:
Save as api.py and import your own custom calls 🙂
response
is json, I handle that like this:I think this is clean enough.
Use https://developers.hive.io/ api refenrence for other calls.
Please don't ask me why I called a function
get_last_irreversible_block_num
🤣I just copy pasted this from older code and thought it was a neat example for @slobberchops 😜
However: transaction signing isn't trivial, I'd recommend a library like BEEM.
Sorry for the edits.
Hope this saves someone some time.
Follow my blog 😁 for more.