create account

Update for beem - missing API calls and ImageUploader added by holger80

View this thread on: hive.blogpeakd.comecency.com
· @holger80 · (edited)
$107.14
Update for beem - missing API calls and ImageUploader added
#### Repository
https://github.com/holgern/beem

<center>
![beem-logo.png](https://cdn.utopian.io/posts/d563a408c062506aed88befbe7781399184fbeem-logo.png)
</center>
[beem](https://github.com/holgern/beem) is a python library for steem. beem has now 526 unit tests and a coverage of 76 %. The current version is 0.19.39.
I created a discord channel for answering a question or discussing beem: https://discord.gg/4HM592V

## New features
### ImageUploader
Thanks to @embrebeyler and his python library [imagehoster-python-client](https://github.com/emre/imagehoster-python-client) I was able to add a ImageUploader class to beem. I could simplify the original code to:
```
from beemgraphenebase.ecdsasig import sign_message
message = py23_bytes(self.challange, "ascii") + image_data
signature = sign_message(message, posting_wif)
signature_in_hex = hexlify(signature).decode("ascii")
```
It is now possible to upload images in bytes representation directly to steemitimages.com:
```
from beem.imageuploader import ImageUploader
from beem import Steem

import io
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
import matplotlib.figure
from matplotlib.figure import Figure

fig = Figure(figsize=(10,  10), dpi=100)
canvas = FigureCanvas(fig)
ax = fig.add_axes([.1, .1, .8, .8])
ax.plot(range(15))
ax.set_xlabel('x')
ax.set_ylabel('y')
buf = io.BytesIO()
fig.savefig(buf, format='png')
buf.seek(0)

stm = Steem(keys=["xxx"])
io = ImageUploader(steem_instance=stm)
io.upload(buf.read(), "holger80")
```
with the result:
```
{'url': 'https://cdn.steemitimages.com/DQmXvmNs3UxXRYqwA7ieP3WMcTLJeRyN3UdvsejD46UqaMv/image'}
```
It's then possible to embed this link into a post:
```
![]('https://cdn.steemitimages.com/DQmXvmNs3UxXRYqwA7ieP3WMcTLJeRyN3UdvsejD46UqaMv/image)
```
![]('https://cdn.steemitimages.com/DQmXvmNs3UxXRYqwA7ieP3WMcTLJeRyN3UdvsejD46UqaMv/image)

## `update_nodes()` from `NodeList` improved
`update_nodes` calculates now the score for each node by:
```
score = (n - rank) / (n- 1) * 100
weigthed_score = score * weights_dict[benchmark]
sum_score += weigthed_score 
```
where `rank` is the rank of the node at the specific benchmark. `n` is the number of nodes and `weights_dict[benchmark]` the the weight for this benchmark. The sum of `weights_dict` is one.
At the moment 5 benchmarks are calculated every hour are written into the metadata field of @fullnodeupdate.
Available benchmarks:

* block
* history
* apicall
* block_diff
* config

## Api Definitions
[Api Definitions](https://beem.readthedocs.io/en/latest/apidefinitions.html) are created with examples for all available API calls defined [here](https://developers.steem.io/apidefinitions/#apidefinitions-condenser-api).

![image.png](https://ipfs.busy.org/ipfs/QmfN2d8CVammXQUYLsKVaDaVPLeCy3yMi6vg9sH8cw7Sbo)


## Missing API calls were added
* `get_expiring_vesting_delegations`
```
from beem.account import Account
acc = Account("emrebeyler")
print(acc.get_expiring_vesting_delegations())

[{'id': 2341553, 'delegator': 'emrebeyler', 'vesting_shares': '2439949.303020 VESTS', 'expiration': '2018-06-22T15:10:00'}, {'id': 2212414, 'delegator': 'emrebeyler', 'vesting_shares': '20338.649992 VESTS', 'expiration': '2018-06-25T23:48:45'}]
```
*  `get_feed_entries`
```
from beem.account import Account
acc = Account("gtg")
for f in acc.get_feed_entries():
    print(f)
```
*  `get_blog_authors`
```
from beem.account import Account
acc = Account("gtg")
for h in acc.get_blog_authors():
    print(h)
```
*  `get_savings_withdrawals`
```
from beem.account import Account
acc = Account("gtg")
print(acc.get_savings_withdrawals(direction="from"))
print(acc.get_savings_withdrawals(direction="to"))
```
*  `get_escrow`
```
from beem.account import Account
acc = Account("gtg")
print(acc.get_escrow())
```
* `get_account_reputations`
```
from beem.blockchain import Blockchain
b = Blockchain()
for h in b.get_account_reputations():
    print(h)
```

* `Discussions_by_author_before_date`
```
from beem.discussions import Query, Discussions_by_author_before_date
for h in Discussions_by_author_before_date(limit=10, author="gtg"):
    print(h)
```
* `get_transaction_hex`
```
from beem.blockchain import Blockchain
b = Blockchain()
block = b.get_current_block()
trx = block.json()["transactions"][0]
print(b.get_transaction_hex(trx))
```
* `get_tags_used_by_author`
```
from beem.account import Account
acc = Account("gtg")
print(acc.get_tags_used_by_author())
```
* `Replies_by_last_update`
```
from beem.discussions import Query, Replies_by_last_update
q = Query(limit=10, start_author="steemit", start_permlink="firstpost")
for h in Replies_by_last_update(q):
    print(h)
```
* `Trending_tags`
```
from beem.discussions import Query, Trending_tags
q = Query(limit=10, start_tag="steemit")
for h in Trending_tags(q):
    print(h)

```
*  `get_vesting_delegations`
```
from beem.account import Account
acc = Account("gtg")
for v in acc.get_vesting_delegations():
    print(v)

```

## Commit history
### Try to improve blocks with threading and some more error caption
* [commit 782544b](https://github.com/holgern/beem/commit/782544be64109f9d64f0c4061d045c3086a95619)

### `get_expiring_vesting_delegations` added to account
* [commit dc18460](https://github.com/holgern/beem/commit/dc184607344f46ff0bd2956d5bab6ce2aff04b9c)
#### Account
* `get_expiring_vesting_delegations` added
#### Blockchain
* thread_limit parameter removed
* batch_mode set to True for threaded blocks()
* block sanity check added for threaded blocks()

### Add missing api functions
* [commit 093ab14](https://github.com/holgern/beem/commit/093ab145687ab7f4ceec17d8e68f254e390d051c)
#### Account
* `get_feed_entries`, `get_blog_authors`, `get_savings_withdrawals`, `get_escrow`
* Documentation improved
* Account parameter handling improved
#### Blockchain
* `get_account_reputations` added

### ImageUploader added
* [commit 169dc2b](https://github.com/holgern/beem/commit/169dc2b2074d3647dca5449314daeeded17da603)
* ImageUploader can be used to upload an image file or an image in bytes

### Improved score calculated for update_nodes
* [commit e669e14](https://github.com/holgern/beem/commit/e669e145f619c482e19eb3c70425ce8c15a9ee37)

### Improved blocks with threads and improved unit test
* [commit 61ddd1e](https://github.com/holgern/beem/commit/61ddd1e2081b463e431b555f8ba24aea77d66b75)

### Add Discussions_by_author_before_date and improve some other discussions class
* [commit 6b5526](https://github.com/holgern/beem/commit/6b5526b22f345528d40f661d688d5f0b25fced7d)
#### Discussions
* `Discussions_by_author_before_date`  added
#### beemapi/Nodes
* add an option to freeze a node, in order to prevent switching to the next node

### get_vesting_delegations added and block date conversion improved
* [commit ce9c512](https://github.com/holgern/beem/commit/ce9c51265d57a3ea91b7c336634804cf73e4638f)
#### Account
* `get_vesting_delegations` added

### More functions added and a complete list of API definitions added to docs
* [commit c955f2a](https://github.com/holgern/beem/commit/c955f2ada6d2b53b1bfaa00ad7bd07159f05a7da)

#### Discussions
* `Replies_by_last_update` and `Trending_tags` added
#### Blockchain
* `get_transaction_hex` added
#### Account
* `get_tags_used_by_author` added
#### Docs
* apidifinitions added

### Block and Blockchain improved and Readme adapted to changes
* [commit 62fe18c](https://github.com/holgern/beem/commit/62fe18cdec72ecc39317dc75eb75c4f7d68e82bf)

### Block identifier handling improved and test_blockchain_treading improved
* [commit 347c7ba](https://github.com/holgern/beem/commit/347c7ba791276bfc614775b8a69982fa1c256a46)

### GitHub Account
https://github.com/holgern
___
If you like what I'm doing, please consider @holger80 as one of your witnesses ([steemconnect](https://v2.steemconnect.com/sign/account-witness-vote?witness=holger80&approve=1)).
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorholger80
permlinkupdate-for-beem-missing-api-calls-and-imageuploader-added
categoryutopian-io
json_metadata"{"community": "busy", "app": "beempy/0.23.10", "format": "markdown", "users": ["embrebeyler", "fullnodeupdate.", "holger80"], "links": ["https://github.com/holgern/beem", "https://github.com/holgern/beem", "https://discord.gg/4HM592V", "/@embrebeyler", "https://github.com/emre/imagehoster-python-client", "/@fullnodeupdate", "https://beem.readthedocs.io/en/latest/apidefinitions.html", "https://developers.steem.io/apidefinitions/#apidefinitions-condenser-api", "https://github.com/holgern/beem/commit/782544be64109f9d64f0c4061d045c3086a95619", "https://github.com/holgern/beem/commit/dc184607344f46ff0bd2956d5bab6ce2aff04b9c"], "tags": ["utopian-io", "development", "beem", "python", "busy"], "canonical_url": "https://hive.blog/utopian-io/@holger80/update-for-beem-missing-api-calls-and-imageuploader-added"}"
created2018-06-20 18:36:15
last_update2020-05-23 14:32:54
depth0
children3
last_payout2018-06-27 18:36:15
cashout_time1969-12-31 23:59:59
total_payout_value81.071 HBD
curator_payout_value26.072 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length7,876
author_reputation358,857,509,568,825
root_title"Update for beem - missing API calls and ImageUploader added"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id61,531,275
net_rshares52,225,965,086,610
author_curate_reward""
vote details (47)
@codingdefined ·
Thank you for your contribution. Again a great update to a project.


Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/guidelines), as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, [click here](https://review.utopian.io/result/3/1212212).

---- 
Need help? Write a ticket on https://support.utopian.io/. 
Chat with us on [Discord](https://discord.gg/uTyJkNm). 
[[utopian-moderator]](https://join.utopian.io/)
properties (22)
authorcodingdefined
permlinkre-holger80-update-for-beem-missing-api-calls-and-imageuploader-added-20180621t082837465z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"links":["https://join.utopian.io/guidelines","https://review.utopian.io/result/3/1212212","https://support.utopian.io/","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"}
created2018-06-21 08:28:39
last_update2018-06-21 08:28:39
depth1
children0
last_payout2018-06-28 08:28:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length559
author_reputation528,928,811,128,670
root_title"Update for beem - missing API calls and ImageUploader added"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id61,608,458
net_rshares0
@scipio ·
Hi @holger80 , took a break for a while, but big kudos from me on Beem! Keep it up, if you need a hand at something let me know.

@scipio
properties (22)
authorscipio
permlinkre-holger80-update-for-beem-missing-api-calls-and-imageuploader-added-20180623t210235796z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["holger80","scipio"],"app":"steemit/0.1"}
created2018-06-23 21:02:36
last_update2018-06-23 21:02:36
depth1
children0
last_payout2018-06-30 21:02:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length137
author_reputation34,229,826,851,736
root_title"Update for beem - missing API calls and ImageUploader added"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id61,961,113
net_rshares0
@utopian-io ·
Hey @holger80
**Thanks for contributing on Utopian**.
We’re already looking forward to your next contribution!

**Contributing on Utopian**
Learn how to contribute on <a href='https://join.utopian.io'>our website</a> or by watching <a href='https://www.youtube.com/watch?v=8S1AtrzYY1Q'>this tutorial</a> on Youtube.

**Want to chat? Join us on Discord https://discord.gg/h52nFrV.**

<a href='https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
properties (22)
authorutopian-io
permlinkre-update-for-beem-missing-api-calls-and-imageuploader-added-20180623t054008z
categoryutopian-io
json_metadata"{"app": "beem/0.19.29"}"
created2018-06-23 05:40:09
last_update2018-06-23 05:40:09
depth1
children0
last_payout2018-06-30 05:40:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length505
author_reputation152,955,367,999,756
root_title"Update for beem - missing API calls and ImageUploader added"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id61,866,297
net_rshares0