Api

class golos.api.Api(nodes: Union[List[str], str] = None, **kwargs)[source]

Main class for golos-python - wraps ws_client and provides many helper methods for interacting with the GOLOS blockchain, such as get_accounts() and transfer()

Official Repo: https://github.com/Privex/golos-python

Official PyPi Package Name: golos-python

Basic Usage:

>>> from golos import Api
>>> golos = Api()
>>> acc = golos.get_accounts(['someguy123'])
>>> acc[0]['owner']
'someguy123'
>>> wit = golos.get_witness_by_account('someguy123')
>>> wit['url']
'https://golos.io/ru--delegaty/@someguy123/delegat-someguy123'
__init__(nodes: Union[List[str], str] = None, **kwargs)[source]

Constructor for Privex’s GOLOS wrapper class. No arguments are required, unless you want to override defaults.

Basic Usage:

Use default nodes list and settings:

>>> golos = Api()

Use only this specific node:

>>> golos = Api(nodes='wss://golosd.privex.io')

Use a list of nodes, and enable more verbose logging from WsClient

>>> nodes = ['wss://golosd.privex.io', 'wss://api.golos.blckchnd.com/ws']
>>> golos = Api(nodes=nodes, report=True)

Making basic API calls:

>>> acc = golos.get_accounts(['someguy123'])
>>> acc[0]['owner']
'someguy123'
>>> wit = golos.get_witness_by_account('someguy123')
>>> wit['url']
'https://golos.io/ru--delegaty/@someguy123/delegat-someguy123'
Parameters
  • nodes (list|str) – A list / singular str GOLOS node(s) formatted like such: wss://golosd.privex.io

  • report (bool) – (KWARG) If True - enables more verbose logging from WsClient

  • kwargs – Any additional keyword arguments (will be forwarded to WsClient’s constructor)

Methods

__init__([nodes])

Constructor for Privex’s GOLOS wrapper class.

account_create(login, password, creator, …)

account_create_with_delegation(login, …)

account_metadata(account, json_metadata, wif)

account_update(new_password, account, …)

account_update_password(account, password, wif)

account_witness_proxy(account, proxy, wif)

change_recovery_account(account, …)

check_login(login)

convert_golos_to_vests(amount)

delegate_vesting_shares(delegatee, amount, …)

delegate_vesting_shares_with_interest(…)

follow(wtf, followings, followers, wif, **kwargs)

get_account_count()

get_account_history(account, **kwargs)

get_account_reputations(account)

get_accounts(logins, **kwargs)

Перерасчитываются некоторые параметры по аккаунту “voting_power” - 1..10000 реальная батарейка “golos_power” - сила голоса с учетом делегирования “rshares” - сколько добавится шаров в пост при 100% батарейке “GOLOS”, “GBG” - ликвидные токены “new_post_limit” - сколько постов можно опубликовать “new_post_time” - сколько осталось времени в минутах до публикации без штрафа “bandwidth” = { “avail” - всего доступно в кБ “used_forum” - использовано в кБ “used_market” - использовано в кБ “free_forum” - доступно в кБ “free_market” - доступно в кБ } “value” = {“GOLOS”, “GBG”} - цена апвота по внутренней бирже “order” = {“GOLOS”, “GBG”} - цена апвота по медиане “rating” = репутация в десятичном виде

get_active_witnesses()

get_all_accounts()

get_block(n)

get_chain_properties()

get_config()

get_content(url, **kwargs)

get_curation_percent()

get_current_median_history_price()

get_database_info()

get_dynamic_global_properties()

get_feed_history()

get_follow(account)

get_key_references(public_key)

Позволяет узнать какому логину соответсвует публичный ключ #public_key = ‘GLS6RGi692mJSNkdcVRunY3tGieJdTsa7AZeBVjB6jjqYg98ov5NL’ Но не позволяет если есть авторити у аккаунта

get_market_history_buckets()

get_median_price()

get_open_orders(account)

get_ops_in_block(n)

get_order_book(limit)

get_order_book_extended(limit)

get_order_price()

get_recent_trades(limit)

get_ticker()

try:

get_tickers()

get_volume()

get_witness_by_account(account)

get_witness_count()

get_witness_schedule()

is_login(login)

lookup_witness_accounts(start, limit)

post(title, body, author, wif, **kwargs)

category = ‘’ url = ‘’ permlink = ‘’ tags = []

replace(title, body, author, wif, **kwargs)

repost(url, account, wif, **kwargs)

resolve_url(url)

transfer(to, amount, from_account, wif[, …])

Transfer amount coins (of asset) to from_account using the private key wif and the memo memo

transfer_to_vesting(to, amount, …)

Power up a given amount of DEFAULT_ASSET (default: GOLOS) from from_account into to.

transfers(raw_ops, from_account, wif)

Execute multiple transfers in a single transaction.

vote(url, weight, voters, wif)

withdraw_vesting(account, amount, wif, **kwargs)

get_accounts(logins: List[str], **kwargs) → List[dict][source]

Перерасчитываются некоторые параметры по аккаунту “voting_power” - 1..10000 реальная батарейка “golos_power” - сила голоса с учетом делегирования “rshares” - сколько добавится шаров в пост при 100% батарейке “GOLOS”, “GBG” - ликвидные токены “new_post_limit” - сколько постов можно опубликовать “new_post_time” - сколько осталось времени в минутах до публикации без штрафа “bandwidth” = {

“avail” - всего доступно в кБ “used_forum” - использовано в кБ “used_market” - использовано в кБ “free_forum” - доступно в кБ “free_market” - доступно в кБ }

“value” = {“GOLOS”, “GBG”} - цена апвота по внутренней бирже “order” = {“GOLOS”, “GBG”} - цена апвота по медиане “rating” = репутация в десятичном виде

get_key_references(public_key: str)[source]

Позволяет узнать какому логину соответсвует публичный ключ #public_key = ‘GLS6RGi692mJSNkdcVRunY3tGieJdTsa7AZeBVjB6jjqYg98ov5NL’ Но не позволяет если есть авторити у аккаунта

get_ticker()[source]
try:

t = {“bid”: round(float(ticker[“highest_bid”]), 6), “ask”: round(float(ticker[“lowest_ask”]), 6)}

except:

return False

post(title, body, author, wif, **kwargs)[source]

category = ‘’ url = ‘’ permlink = ‘’ tags = []

beneficiaries = ‘login:10000’ weight = 10000 curation = max or int 2500..10000

transfer(to: str, amount: Union[decimal.Decimal, float, int, str], from_account: str, wif: str, asset='GOLOS', memo='', **kwargs)[source]

Transfer amount coins (of asset) to from_account using the private key wif and the memo memo

Basic usage:

>>> g = Api()
>>> tf = golos.transfer(
...     to='ksantoprotein', amount='0.1', asset='GOLOS', from_account='someguy123',
...     wif='5Jq19TeeVmGrBFnu32oxfxQMiipnSCKmwW7fZGUVLAoqsKJ9JwP', memo='this is an example transfer'
... )
>>> print('TXID:', tf['id'], 'Block:', tf['block_num'])
TXID: c901c52daf57b60242d9d7be67f790e023cf2780 Block: 30895436
Parameters
  • to (str) – The username of the account you want to send coins to

  • amount (Decimal) – The amount of coins to send, as either a Decimal, str, int or float

  • from_account (str) – The username of the account to send from

  • wif (str) – The active/owner private key for the from_account, as a string in WIF format

  • asset (str) – The asset (coin) to send (Default: GOLOS (value of DEFAULT_ASSET))

  • memo (str) – An optional public message to attach to the transfer (Default: '' - empty string)

  • kwargs – Any additional keyword arguments

Return dict transfer

A dictionary containing info about the completed transfer, inc. id (full ret below)

Return data:

dict(
    ref_block_num: int, ref_block_prefix:int,
    expiration:str, operations:list, extensions:list,
    signatures:List[str], block_num:int, id:str
)
transfer_to_vesting(to: str, amount: Union[decimal.Decimal, float, int, str], from_account: str, wif: str, **kwargs)[source]

Power up a given amount of DEFAULT_ASSET (default: GOLOS) from from_account into to.

Basic Usage (Convert 1000 GOLOS from someguy123 into GESTS to someguy123)

>>> g = Api()
>>> tf = g.transfer_to_vesting(
...   to='someguy123', from_account='someguy123', wif='5Jq19TeeVmGrBFnu32oxfxQMiipnSCKmwW7fZGUVLAoqsKJ9JwP'
...   amount='1000'
... )
>>> print('TXID:', tf['id'], 'Block:', tf['block_num'])
TXID: c901c52daf57b60242d9d7be67f790e023cf2780 Block: 30895436
Parameters
  • to (str) – The username of the account you want to send coins to

  • amount (Decimal) – The amount of coins to send, as either a Decimal, str, int or float

  • from_account (str) – The username of the account to send from

  • wif (str) – The active/owner private key for the from_account, as a string in WIF format

Return dict transfer

A dictionary containing info about the completed TX, inc. id (full ret below)

Return data:

dict(
    ref_block_num: int, ref_block_prefix:int,
    expiration:str, operations:list, extensions:list,
    signatures:List[str], block_num:int, id:str
)
transfers(raw_ops: List[Tuple[str, Union[decimal.Decimal, float, int, str], str, str]], from_account: str, wif: str)[source]

Execute multiple transfers in a single transaction.

>>> tfrs = [('john', '1.234', 'GOLOS', 'thanks man'), ('dave', '0.374', 'GBG', 'hi dave'), ]
>>> g = Api()
>>> tf = g.transfers(raw_ops=tfrs, from_account='someguy123',
...                  wif='5Jq19TeeVmGrBFnu32oxfxQMiipnSCKmwW7fZGUVLAoqsKJ9JwP')
>>> print('TXID:', tf['id'], 'Block:', tf['block_num'])
TXID: c901c52daf57b60242d9d7be67f790e023cf2780 Block: 30895436
Parameters
  • raw_ops (List[Tuple]) – A list of transfers as 4 key tuples: (to:str, amount:str, asset:str, memo:str)

  • from_account (str) – The username of the account to send from

  • wif (str) – The active/owner private key for the from_account, as a string in WIF format

Return dict transfer

A dictionary containing info about the completed TX, inc. id (full ret below)

Return data:

dict(
    ref_block_num: int, ref_block_prefix:int,
    expiration:str, operations:list, extensions:list,
    signatures:List[str], block_num:int, id:str
)