Steem-python Step by Step: #2 Getting Docs from Code

in #steem-dev8 years ago

#2

This is a simple exercise for get updated help about Steemd object, and do an tool overview before the project development.

1. The Script is a file named "steemGetDoc.py"

steemgetdoc

The hashtags in line number 17 is for copy-paste on this post :) (step 3)

2. Execution and redirect it to "steempyDoc.txt"

$python3 steemGetDoc.py > steempyDoc.txt

3. And the raw result is...

broadcast_block :

broadcast_block

broadcast_transaction :

broadcast_transaction

broadcast_transaction_synchronous :

broadcast_transaction_synchronous

chain_params :

dict() -> new empty dictionary
dict(mapping) -> new dictionary initialized from a mapping object's
(key, value) pairs
dict(iterable) -> new dictionary initialized as if via:
d = {}
for k, v in iterable:
d[k] = v
dict(**kwargs) -> new dictionary initialized with the name=value pairs
in the keyword argument list. For example: dict(one=1, two=2)

exec :

Execute a method against steemd RPC.

    Warnings:
        This command will auto-retry in case of node failure, as well as handle
        node fail-over, unless we are broadcasting a transaction.
        In latter case, the exception is **re-raised**.

exec_multi_with_futures :

None

get_account :

Lookup account information such as user profile, public keys, balances, etc.

    Args:
        account (str): STEEM username that we are looking up.

    Returns:
        dict: Account information.

get_account_bandwidth :

get_account_bandwidth

get_account_count :

How many accounts are currently registered on STEEM?

get_account_history :

History of all operations for a given account.

    Args:
       account (str): STEEM username that we are looking up.
       index_from (int): The highest database index we take as a starting point.
       limit (int): How many items are we interested in.

    Returns:
       list: List of operations.

    Example:
       To get the latest (newest) operations from a given user ``furion``, we should set the ``index_from`` to -1.
       This is the same as saying `give me the highest index there is`.

       .. code-block :: python

          s.get_account_history('furion', index_from=-1, limit=3)

       This will yield 3 recent operations like so:

       ::

          [[69974,
            {'block': 9941972,
             'op': ['vote',
              {'author': 'breezin',
               'permlink': 'raising-children-is-not-childsplay-pro-s-and-con-s-of-being-a-young-parent',
               'voter': 'furion',
               'weight': 900}],
             'op_in_trx': 0,
             'timestamp': '2017-03-06T17:09:48',
             'trx_id': '87f9176faccc7096b5ffb5d12bfdb41b3c0b2955',
             'trx_in_block': 5,
             'virtual_op': 0}],
           [69975,
            {'block': 9942005,
             'op': ['curation_reward',
              {'comment_author': 'leongkhan',
               'comment_permlink': 'steem-investor-report-5-march-2017',
               'curator': 'furion',
               'reward': '112.397602 VESTS'}],
             'op_in_trx': 1,
             'timestamp': '2017-03-06T17:11:30',
             'trx_id': '0000000000000000000000000000000000000000',
             'trx_in_block': 5,
             'virtual_op': 0}],
           [69976,
            {'block': 9942006,
             'op': ['vote',
              {'author': 'ejhaasteem',
               'permlink': 'life-of-fishermen-in-aceh',
               'voter': 'furion',
               'weight': 100}],
             'op_in_trx': 0,
             'timestamp': '2017-03-06T17:11:30',
             'trx_id': '955018ac8efe298bd90b45a4fbd15b9df7e00be4',
             'trx_in_block': 7,
             'virtual_op': 0}]]

       If we want to query for a particular range of indexes, we need to consider both `index_from` and `limit` fields.
       Remember, `index_from` works backwards, so if we set it to 100, we will get items `100, 99, 98, 97...`.

       For example, if we'd like to get the first 100 operations the user did, we would write:

       .. code-block:: python

          s.get_account_history('furion', index_from=100, limit=100)

       We can get the next 100 items by running:

       .. code-block:: python

          s.get_account_history('furion', index_from=200, limit=100)

get_account_references :

get_account_references

get_account_reputations :

get_account_reputations

get_account_votes :

All votes the given account ever made.

    Returned votes are in the following format:
    ::

       {'authorperm': 'alwaysfelicia/time-line-of-best-times-to-post-on-steemit-mystery-explained',
       'percent': 100,
       'rshares': 709227399,
       'time': '2016-08-07T16:06:24',
       'weight': '3241351576115042'},


    Args:
        account (str): STEEM username that we are looking up.

    Returns:
        list: List of votes.

get_accounts :

Lookup account information such as user profile, public keys, balances, etc.

    This method is same as ``get_account``, but supports querying for multiple accounts at the time.

get_active_votes :

Get all votes for the given post.

    Args:
        author (str): OP's STEEM username.
        permlink (str): Post identifier following the username. It looks like slug-ified title.

    Returns:
        list: List of votes.

    Example:
        .. code-block:: python

           s.get_active_votes('mynameisbrian', 'steemifying-idioms-there-s-no-use-crying-over-spilt-milk')

        Output:

        ::

           [{'percent': 10000,
             'reputation': '36418980678',
             'rshares': 356981288,
             'time': '2017-03-06T20:04:18',
             'voter': 'dailystuff',
             'weight': '2287202760855'},
             ...
            {'percent': 10000,
             'reputation': 3386400109,
             'rshares': 364252169,
             'time': '2017-03-06T19:32:45',
             'voter': 'flourish',
             'weight': '2334690471157'}]

get_active_witnesses :

Get a list of currently active witnesses.

get_all_usernames :

Fetch the full list of STEEM usernames.

get_api_by_name :

get_api_by_name

get_block :

Get the full block, transactions and all, given a block number.

    Args:
        block_num (int): Block number.

    Returns:
        dict: Block in a JSON compatible format.

    Example:

        .. code-block:: python

           s.get_block(8888888)

        ::

            {'extensions': [],
             'previous': '0087a2372163ff5c5838b09589ce281d5a564f66',
             'timestamp': '2017-01-29T02:47:33',
             'transaction_merkle_root': '4ddc419e531cccee6da660057d606d11aab9f3a5',
             'transactions': [{'expiration': '2017-01-29T02:47:42',
               'extensions': [],
               'operations': [['comment',
                 {'author': 'hilarski',
                  'body': 'https://media.giphy.com/media/RAx4Xwh1OPHji/giphy.gif',
                  'json_metadata': '{"tags":["motocross"],"image":["https://media.giphy.com/media/RAx4Xwh1OPHji/giphy.gif"],"app":"steemit/0.1"}',
                  'parent_author': 'b0y2k',
                  'parent_permlink': 'ama-supercross-round-4-phoenix-2017',
                  'permlink': 're-b0y2k-ama-supercross-round-4-phoenix-2017-20170129t024725575z',
                  'title': ''}]],
               'ref_block_num': 41495,
               'ref_block_prefix': 2639073901,
               'signatures': ['2058b69f4c15f704a67a7b5a7996a9c9bbfd39c639f9db19b99ecad8328c4ce3610643f8d1b6424c352df120614cd535cd8f2772fce68814eeea50049684c37d69']}],
             'witness': 'chainsquad.com',
             'witness_signature': '1f115745e3f6fee95124164f4b57196c0eda2a700064faa97d0e037d3554ee2d5b618e6bfd457473783e8b8333724ba0bf93f0a4a7026e7925c8c4d2ba724152d4'}

get_block_header :

Get block headers, given a block number.

    Args:
       block_num (int): Block number.

    Returns:
       dict: Block headers in a JSON compatible format.

    Example:

        .. code-block:: python

           s.get_block_headers(8888888)

        ::

            {'extensions': [],
             'previous': '0087a2372163ff5c5838b09589ce281d5a564f66',
             'timestamp': '2017-01-29T02:47:33',
             'transaction_merkle_root': '4ddc419e531cccee6da660057d606d11aab9f3a5',
             'witness': 'chainsquad.com'}

get_blocks :

Fetch multiple blocks from steemd at once, given a range.

    Args:
        block_nums (list): A list of all block numbers we would like to tech.

    Returns:
        dict: An ensured and ordered list of all `get_block` results.

get_blocks_range :

Fetch multiple blocks from steemd at once, given a range.

    Args:
        start (int): The number of the block to start with
        end (int): The number of the block at the end of the range. Not included in results.

    Returns:
        dict: An ensured and ordered list of all `get_block` results.

get_blog :

get_blog

get_blog_authors :

get_blog_authors

get_blog_entries :

get_blog_entries

get_chain_properties :

Get witness elected chain properties.

    ::

        {'account_creation_fee': '30.000 STEEM',
         'maximum_block_size': 65536,
         'sbd_interest_rate': 250}

get_comment_discussions_by_payout :

get_comment_discussions_by_payout

get_config :

Get internal chain configuration.

get_content :

get_content

get_content_replies :

get_content_replies

get_conversion_requests :

get_conversion_requests

get_current_median_history_price :

Get the average STEEM/SBD price.

    This price is based on moving average of witness reported price feeds.

    ::

        {'base': '0.093 SBD', 'quote': '1.010 STEEM'}

get_discussions_by_active :

get_discussions_by_active

get_discussions_by_author_before_date :

get_discussions_by_author_before_date

get_discussions_by_blog :

get_discussions_by_blog

get_discussions_by_cashout :

get_discussions_by_cashout

get_discussions_by_children :

get_discussions_by_children

get_discussions_by_comments :

get_discussions_by_comments

get_discussions_by_created :

get_discussions_by_created

get_discussions_by_feed :

get_discussions_by_feed

get_discussions_by_hot :

get_discussions_by_hot

get_discussions_by_payout :

get_discussions_by_payout

get_discussions_by_promoted :

get_discussions_by_promoted

get_discussions_by_trending :

get_discussions_by_trending

get_discussions_by_votes :

get_discussions_by_votes

get_dynamic_global_properties :

get_dynamic_global_properties

get_escrow :

get_escrow

get_expiring_vesting_delegations :

get_expiring_vesting_delegations

get_feed :

get_feed

get_feed_entries :

get_feed_entries

get_feed_history :

Get the hourly averages of witness reported STEEM/SBD prices.

    ::

        {'current_median_history': {'base': '0.093 SBD', 'quote': '1.010 STEEM'},
         'id': 0,
         'price_history': [{'base': '0.092 SBD', 'quote': '1.010 STEEM'},
          {'base': '0.093 SBD', 'quote': '1.020 STEEM'},
          {'base': '0.093 SBD', 'quote': '1.010 STEEM'},
          {'base': '0.094 SBD', 'quote': '1.020 STEEM'},
          {'base': '0.093 SBD', 'quote': '1.010 STEEM'},

get_follow_count :

get_follow_count

get_followers :

get_followers

get_following :

get_following

get_hardfork_version :

Get the current version of the chain.

    Note:
        This is not the same as latest minor version.

get_key_references :

get_key_references

get_liquidity_queue :

Get the liquidity queue.

    Warning:
        This feature is currently not in use, and might be deprecated in the future.

get_market_history :

Returns the market history for the internal SBD:STEEM market.

get_market_history_buckets :

Returns the bucket seconds being tracked by the plugin.

get_next_scheduled_hardfork :

get_next_scheduled_hardfork

get_open_orders :

get_open_orders

get_ops_in_block :

get_ops_in_block

get_order_book :

Get the internal market order book.

    This method will return both bids and asks.

    Args:
        limit (int): How many levels deep into the book to show.

    Returns:
        dict: Order book.

    Example:

        .. code-block:: python

           s.get_order_book(2)

        Outputs:

        ::

            {'asks': [{'created': '2017-03-06T21:29:54',
               'order_price': {'base': '513.571 STEEM', 'quote': '50.000 SBD'},
               'real_price': '0.09735752213423265',
               'sbd': 50000,
               'steem': 513571},
              {'created': '2017-03-06T21:01:39',
               'order_price': {'base': '63.288 STEEM', 'quote': '6.204 SBD'},
               'real_price': '0.09802806219188472',
               'sbd': 6204,
               'steem': 63288}],
             'bids': [{'created': '2017-03-06T21:29:51',
               'order_price': {'base': '50.000 SBD', 'quote': '516.503 STEEM'},
               'real_price': '0.09680485882947436',
               'sbd': 50000,
               'steem': 516503},
              {'created': '2017-03-06T17:30:24',
               'order_price': {'base': '36.385 SBD', 'quote': '379.608 STEEM'},
               'real_price': '0.09584887568228277',
               'sbd': 36385,
               'steem': 379608}]}

get_owner_history :

get_owner_history

get_post_discussions_by_payout :

get_post_discussions_by_payout

get_posts :

Get multiple posts in an array.

        :param int limit: Limit the list of posts by ``limit``
        :param str sort: Sort the list by "recent" or "payout"
        :param str category: Only show posts in this category
        :param str start: Show posts after this post. Takes an
                          identifier of the form ``@author/permlink``

get_potential_signatures :

get_potential_signatures

get_promoted :

Get promoted posts

get_reblogged_by :

get_reblogged_by

get_recent_trades :

Returns the N most recent trades for the internal SBD:STEEM market.

get_recovery_request :

get_recovery_request

get_replies :

Get replies for an author

        :param str author: Show replies for this author
        :param bool skip_own: Do not show my own replies

get_replies_by_last_update :

get_replies_by_last_update

get_required_signatures :

get_required_signatures

get_reward_fund :

Get details for a reward fund.

    Right now the only pool available is 'post'.

    Example:

        .. code-block:: python

            s.get_reward_fund('post')

        ::

            {'content_constant': '2000000000000',
             'id': 0,
             'last_update': '2017-04-09T19:18:57',
             'name': 'post',
             'percent_content_rewards': 10000,
             'percent_curation_rewards': 2500,
             'recent_claims': '10971122501158586840771928156084',
             'reward_balance': '555660.895 STEEM'}

get_savings_withdraw_from :

get_savings_withdraw_from

get_savings_withdraw_to :

get_savings_withdraw_to

get_state :

get_state

get_tags_used_by_author :

get_tags_used_by_author

get_ticker :

Returns the market ticker for the internal SBD:STEEM market.

get_trade_history :

Returns the trade history for the internal SBD:STEEM market.

get_transaction :

get_transaction

get_transaction_hex :

get_transaction_hex

get_trending_tags :

get_trending_tags

get_version :

Get steemd version of the node currently connected to.

get_vesting_delegations :

get_vesting_delegations

get_volume :

Returns the market volume for the past 24 hours.

get_withdraw_routes :

get_withdraw_routes

get_witness_by_account :

get_witness_by_account

get_witness_count :

get_witness_count

get_witness_schedule :

get_witness_schedule

get_witnesses :

get_witnesses

get_witnesses_by_vote :

get_witnesses_by_vote

head_block_number :

int(x=0) -> integer
int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments
are given. If x is a number, return x.int(). For floating point
numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string,
bytes, or bytearray instance representing an integer literal in the
given base. The literal can be preceded by '+' or '-' and be surrounded
by whitespace. The base defaults to 10. Valid bases are 0 and 2-36.
Base 0 means to interpret the base from the string as an integer literal.

int('0b100', base=0)
4

hostname :

str(object='') -> str
str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or
errors is specified, then the object must expose a data buffer
that will be decoded using the given encoding and error handler.
Otherwise, returns the result of object.str() (if defined)
or repr(object).
encoding defaults to sys.getdefaultencoding().
errors defaults to 'strict'.

http :

Allows for arbitrary requests while transparently keeping track of
necessary connection pools for you.

:param num_pools:
    Number of connection pools to cache before discarding the least
    recently used pool.

:param headers:
    Headers to include with all requests, unless other headers are given
    explicitly.

:param \**connection_pool_kw:
    Additional parameters are used to create fresh
    :class:`urllib3.connectionpool.ConnectionPool` instances.

Example::

    >>> manager = PoolManager(num_pools=2)
    >>> r = manager.request('GET', 'http://google.com/')
    >>> r = manager.request('GET', 'http://google.com/mail')
    >>> r = manager.request('GET', 'http://yahoo.com/')
    >>> len(manager.pools)
    2

json_rpc_body :

Build request body for steemd RPC requests.

    Args:
        name (str): Name of a method we are trying to call. (ie: `get_accounts`)
        args: A list of arguments belonging to the calling method.
        api (None, str): If api is provided (ie: `follow_api`),
         we generate a body that uses `call` method appropriately.
        as_json (bool): Should this function return json as dictionary or string.
        _id (int): This is an arbitrary number that can be used for request/response tracking in multi-threaded
         scenarios.

    Returns:
        (dict,str): If `as_json` is set to `True`, we get json formatted as a string.
        Otherwise, a Python dictionary is returned.

last_irreversible_block_num :

int(x=0) -> integer
int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments
are given. If x is a number, return x.int(). For floating point
numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string,
bytes, or bytearray instance representing an integer literal in the
given base. The literal can be preceded by '+' or '-' and be surrounded
by whitespace. The base defaults to 10. Valid bases are 0 and 2-36.
Base 0 means to interpret the base from the string as an integer literal.

int('0b100', base=0)
4

login :

login

lookup_account_names :

lookup_account_names

lookup_accounts :

Get a list of usernames from all registered accounts.

    Args:
        after (str, int): Username to start with. If '', 0 or -1, it will start at beginning.
        limit (int): How many results to return.

    Returns:
        list: List of usernames in requested chunk.

lookup_witness_accounts :

lookup_witness_accounts

max_workers :

None

next_node :

Switch to the next available node.

    This method will change base URL of our requests.
    Use it when the current node goes down to change to a fallback node. 

nodes :

cycle(iterable) --> cycle object

Return elements from the iterable until it is exhausted.
Then repeat the sequence indefinitely.

re_raise :

bool(x) -> bool

Returns True when the argument x is true, False otherwise.
The builtins True and False are the only two instances of the class bool.
The class bool is a subclass of the class int, and cannot be subclassed.

request :

partial(func, *args, **keywords) - new function with partial application
of the given arguments and keywords.

return_with_args :

bool(x) -> bool

Returns True when the argument x is true, False otherwise.
The builtins True and False are the only two instances of the class bool.
The class bool is a subclass of the class int, and cannot be subclassed.

set_max_block_age :

set_max_block_age

set_node :

Change current node to provided node URL.

stream_comments :

Generator that yields posts when they come in

        To be used in a for loop that returns an instance of `Post()`.

url :

str(object='') -> str
str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or
errors is specified, then the object must expose a data buffer
that will be decoded using the given encoding and error handler.
Otherwise, returns the result of object.str() (if defined)
or repr(object).
encoding defaults to sys.getdefaultencoding().
errors defaults to 'strict'.

verify_account_authority :

verify_account_authority

verify_authority :

verify_authority

References

Sort:  

Wow esta muy interesante. Lo voy a probar. Gracias por la info @jesuscirino

Good, I'm test. Are you write with Vim ;)?