Skip to content

Commit

Permalink
Feature/improvements1 (#7)
Browse files Browse the repository at this point in the history
* update api url; add blocks tx index feature; add downloads

* add block txid index test

* update pepy url

* update issued assets docs

* bump version
  • Loading branch information
valinsky authored Sep 14, 2019
1 parent b649435 commit 25d440b
Show file tree
Hide file tree
Showing 17 changed files with 210 additions and 25 deletions.
11 changes: 7 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Bloxplorer
==========

|circle| |version| |MIT license|
|circle| |version| |license| |downloads|

**Bloxplorer** is a simple yet very effective Bitcoin and Liquid blockchain explorer.

It allows developers to make use of the full power of the `Blockstream Esplora HTTP API
<https://github.com/Blockstream/esplora>`_ through a clean Python interface.
<https://github.com/Blockstream/esplora/blob/master/API.md>`_ through a clean Python interface.

Usage
-----
Expand Down Expand Up @@ -51,8 +51,11 @@ Thank you!!
.. |circle| image:: https://circleci.com/gh/valinsky/bloxplorer/tree/master.svg?style=shield
:target: https://circleci.com/gh/valinsky/bloxplorer/tree/master

.. |version| image:: https://img.shields.io/badge/version-0.1.2-blue
.. |version| image:: https://img.shields.io/badge/version-0.1.3-blue
:target: https://pypi.org/project/bloxplorer/

.. |MIT license| image:: https://img.shields.io/badge/license-MIT-orange
.. |license| image:: https://img.shields.io/badge/license-MIT-orange
:target: https://github.com/valinsky/bloxplorer/blob/master/LICENSE

.. |downloads| image:: https://pepy.tech/badge/bloxplorer
:target: https://pepy.tech/project/bloxplorer/
7 changes: 5 additions & 2 deletions bloxplorer/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,20 @@ def get_txs(self, hash, start_index=None, **kwargs):
path += f'/{start_index}'
return self.make_request('GET', path, **kwargs)

def get_txids(self, hash, **kwargs):
def get_txids(self, hash, index=None, **kwargs):
r"""
Returns a list of all txids in the block.
If `index` is present, return the transaction at index `index` within the specified block.
The response from this endpoint can be cached indefinitely.
:param hash: String representing the block hash.
:param index: (Optional) Integer representing the index within a block.
:param \*\*kwargs: (Optional) Arguments that `Requests` takes.
:return: :class: `Response` object.
"""
return self.make_request('GET', f'block/{hash}/txids', **kwargs)
path = f'block/{hash}/txid/{index}' if index is not None else f'block/{hash}/txids'
return self.make_request('GET', path, **kwargs)

def get_height(self, height, **kwargs):
r"""
Expand Down
2 changes: 1 addition & 1 deletion bloxplorer/issued_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, *args, **kwargs):

def get(self, asset_id, **kwargs):
r"""
Get information about an issued assets.
Get information about an issued asset.
:param asset_id: String representing the issued asset hash.
:param \*\*kwargs: (Optional) Arguments that `Requests` takes.
Expand Down
Binary file modified docs/_build/doctrees/api/blocks.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/api/issued_assets.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/_build/doctrees/index.doctree
Binary file not shown.
58 changes: 57 additions & 1 deletion docs/_build/html/_sources/api/issued_assets.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,64 @@ Usage
from bloxplorer import liquid_explorer as explorer
result = explorer.assets.get('issued_assets_hash')
result = explorer.assets.get('aa775044c32a7df391902b3659f46dfe004ccb2644ce2ddc7dba31e889391caf')
print(result.data)
"""
{
'asset_id': 'aa775044c32a7df391902b3659f46dfe004ccb2644ce2ddc7dba31e889391caf',
'issuance_txin': {
'txid': '421dd5195c9f36bd56a79e3b0581620b11804ec9fbc9d03b36102c27781536c8',
'vin': 0
},
'issuance_prevout': {
'txid': '7ead93672f90b8eb6ccdc73ffe0cf0e1381023bd72ecdcbc73a33e9e6e9fcc1f',
'vout': 0
},
'reissuance_token': 'fe9ae6c5dad9de797edeb0327f637920798134c428c3ac781f5267d063e34eca',
'contract_hash': 'ea0777a80ef195009d487ae3eb49bb6d82fbc8d8064c81d7cfb515a3d3fe5438',
'status': {
'confirmed': True,
'block_height': 470055,
'block_hash': '7596b3dcfae149c29f558af284fb89e8fb635541db700aa22634a5f03a5623ce',
'block_time': 1568422618
},
'chain_stats': {
'tx_count': 1,
'issuance_count': 1,
'issued_amount': 1000000,
'burned_amount': 0,
'has_blinded_issuances': False,
'reissuance_tokens': 5,
'burned_reissuance_tokens': 0
},
'mempool_stats': {
'tx_count': 0,
'issuance_count': 0,
'issued_amount': 0,
'burned_amount': 0,
'has_blinded_issuances': False,
'reissuance_tokens': None,
'burned_reissuance_tokens': 0
},
'contract': {
'entity': {
'domain': 'amole.org'
},
'issuer_pubkey': '03c5f0236f8f0b865d961ea22817621a3f645b39d1a38107255a74ec93b249f21b',
'name': 'Ethiopian, Birr',
'precision': 2,
'ticker': 'ETB',
'version': 0
},
'entity': {
'domain': 'amole.org'
},
'precision': 2,
'name': 'Ethiopian, Birr',
'ticker': 'ETB'
}
"""
.. autoclass:: bloxplorer.issued_assets.IssuedAssets
:members:
8 changes: 5 additions & 3 deletions docs/_build/html/_sources/index.rst.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Bloxplorer - Bitcoin and Liquid Blockchain Explorer
===================================================

|circle| |version| |license|
|circle| |version| |license| |downloads|

:ref:`Quickstart <quickstart>`


**Bloxplorer** is a simple yet very effective Bitcoin and Liquid blockchain explorer.

It allows developers to make use of the full power of the `Blockstream Esplora HTTP API
<https://github.com/Blockstream/esplora>`_ through a clean Python interface.
<https://github.com/Blockstream/esplora/blob/master/API.md>`_ through a clean Python interface.

.. code-block:: python
Expand All @@ -23,12 +23,14 @@ It allows developers to make use of the full power of the `Blockstream Esplora H
.. |circle| image:: https://circleci.com/gh/valinsky/bloxplorer/tree/master.svg?style=shield
:target: https://circleci.com/gh/valinsky/bloxplorer/tree/master

.. |version| image:: https://img.shields.io/badge/version-0.1.2-blue
.. |version| image:: https://img.shields.io/badge/version-0.1.3-blue
:target: https://pypi.org/project/bloxplorer/

.. |license| image:: https://img.shields.io/badge/license-MIT-orange
:target: https://github.com/valinsky/bloxplorer/blob/master/LICENSE

.. |downloads| image:: https://pepy.tech/badge/bloxplorer
:target: https://pepy.tech/project/bloxplorer/

.. toctree::
:maxdepth: 2
Expand Down
4 changes: 3 additions & 1 deletion docs/_build/html/api/blocks.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,15 @@ <h2>2.2.1. Usage<a class="headerlink" href="#usage" title="Permalink to this hea

<dl class="method">
<dt id="bloxplorer.blocks.Blocks.get_txids">
<code class="sig-name descname">get_txids</code><span class="sig-paren">(</span><em class="sig-param">hash</em>, <em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#bloxplorer.blocks.Blocks.get_txids" title="Permalink to this definition"></a></dt>
<code class="sig-name descname">get_txids</code><span class="sig-paren">(</span><em class="sig-param">hash</em>, <em class="sig-param">index=None</em>, <em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#bloxplorer.blocks.Blocks.get_txids" title="Permalink to this definition"></a></dt>
<dd><p>Returns a list of all txids in the block.
If <cite>index</cite> is present, return the transaction at index <cite>index</cite> within the specified block.
The response from this endpoint can be cached indefinitely.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>hash</strong> – String representing the block hash.</p></li>
<li><p><strong>index</strong> – (Optional) Integer representing the index within a block.</p></li>
<li><p><strong>**kwargs</strong> – (Optional) Arguments that <cite>Requests</cite> takes.</p></li>
</ul>
</dd>
Expand Down
60 changes: 58 additions & 2 deletions docs/_build/html/api/issued_assets.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,64 @@
<h2>2.6.1. Usage<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h2>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">bloxplorer</span> <span class="kn">import</span> <span class="n">liquid_explorer</span> <span class="k">as</span> <span class="n">explorer</span>

<span class="n">result</span> <span class="o">=</span> <span class="n">explorer</span><span class="o">.</span><span class="n">assets</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;issued_assets_hash&#39;</span><span class="p">)</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">explorer</span><span class="o">.</span><span class="n">assets</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;aa775044c32a7df391902b3659f46dfe004ccb2644ce2ddc7dba31e889391caf&#39;</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="n">result</span><span class="o">.</span><span class="n">data</span><span class="p">)</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">{</span>
<span class="sd"> &#39;asset_id&#39;: &#39;aa775044c32a7df391902b3659f46dfe004ccb2644ce2ddc7dba31e889391caf&#39;,</span>
<span class="sd"> &#39;issuance_txin&#39;: {</span>
<span class="sd"> &#39;txid&#39;: &#39;421dd5195c9f36bd56a79e3b0581620b11804ec9fbc9d03b36102c27781536c8&#39;,</span>
<span class="sd"> &#39;vin&#39;: 0</span>
<span class="sd"> },</span>
<span class="sd"> &#39;issuance_prevout&#39;: {</span>
<span class="sd"> &#39;txid&#39;: &#39;7ead93672f90b8eb6ccdc73ffe0cf0e1381023bd72ecdcbc73a33e9e6e9fcc1f&#39;,</span>
<span class="sd"> &#39;vout&#39;: 0</span>
<span class="sd"> },</span>
<span class="sd"> &#39;reissuance_token&#39;: &#39;fe9ae6c5dad9de797edeb0327f637920798134c428c3ac781f5267d063e34eca&#39;,</span>
<span class="sd"> &#39;contract_hash&#39;: &#39;ea0777a80ef195009d487ae3eb49bb6d82fbc8d8064c81d7cfb515a3d3fe5438&#39;,</span>
<span class="sd"> &#39;status&#39;: {</span>
<span class="sd"> &#39;confirmed&#39;: True,</span>
<span class="sd"> &#39;block_height&#39;: 470055,</span>
<span class="sd"> &#39;block_hash&#39;: &#39;7596b3dcfae149c29f558af284fb89e8fb635541db700aa22634a5f03a5623ce&#39;,</span>
<span class="sd"> &#39;block_time&#39;: 1568422618</span>
<span class="sd"> },</span>
<span class="sd"> &#39;chain_stats&#39;: {</span>
<span class="sd"> &#39;tx_count&#39;: 1,</span>
<span class="sd"> &#39;issuance_count&#39;: 1,</span>
<span class="sd"> &#39;issued_amount&#39;: 1000000,</span>
<span class="sd"> &#39;burned_amount&#39;: 0,</span>
<span class="sd"> &#39;has_blinded_issuances&#39;: False,</span>
<span class="sd"> &#39;reissuance_tokens&#39;: 5,</span>
<span class="sd"> &#39;burned_reissuance_tokens&#39;: 0</span>
<span class="sd"> },</span>
<span class="sd"> &#39;mempool_stats&#39;: {</span>
<span class="sd"> &#39;tx_count&#39;: 0,</span>
<span class="sd"> &#39;issuance_count&#39;: 0,</span>
<span class="sd"> &#39;issued_amount&#39;: 0,</span>
<span class="sd"> &#39;burned_amount&#39;: 0,</span>
<span class="sd"> &#39;has_blinded_issuances&#39;: False,</span>
<span class="sd"> &#39;reissuance_tokens&#39;: None,</span>
<span class="sd"> &#39;burned_reissuance_tokens&#39;: 0</span>
<span class="sd"> },</span>
<span class="sd"> &#39;contract&#39;: {</span>
<span class="sd"> &#39;entity&#39;: {</span>
<span class="sd"> &#39;domain&#39;: &#39;amole.org&#39;</span>
<span class="sd"> },</span>
<span class="sd"> &#39;issuer_pubkey&#39;: &#39;03c5f0236f8f0b865d961ea22817621a3f645b39d1a38107255a74ec93b249f21b&#39;,</span>
<span class="sd"> &#39;name&#39;: &#39;Ethiopian, Birr&#39;,</span>
<span class="sd"> &#39;precision&#39;: 2,</span>
<span class="sd"> &#39;ticker&#39;: &#39;ETB&#39;,</span>
<span class="sd"> &#39;version&#39;: 0</span>
<span class="sd"> },</span>
<span class="sd"> &#39;entity&#39;: {</span>
<span class="sd"> &#39;domain&#39;: &#39;amole.org&#39;</span>
<span class="sd"> },</span>
<span class="sd"> &#39;precision&#39;: 2,</span>
<span class="sd"> &#39;name&#39;: &#39;Ethiopian, Birr&#39;,</span>
<span class="sd"> &#39;ticker&#39;: &#39;ETB&#39;</span>
<span class="sd">}</span>
<span class="sd">&quot;&quot;&quot;</span>
</pre></div>
</div>
<dl class="class">
Expand All @@ -51,7 +107,7 @@ <h2>2.6.1. Usage<a class="headerlink" href="#usage" title="Permalink to this hea
<dl class="method">
<dt id="bloxplorer.issued_assets.IssuedAssets.get">
<code class="sig-name descname">get</code><span class="sig-paren">(</span><em class="sig-param">asset_id</em>, <em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#bloxplorer.issued_assets.IssuedAssets.get" title="Permalink to this definition"></a></dt>
<dd><p>Get information about an issued assets.</p>
<dd><p>Get information about an issued asset.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
Expand Down
4 changes: 2 additions & 2 deletions docs/_build/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@

<div class="section" id="bloxplorer-bitcoin-and-liquid-blockchain-explorer">
<h1>Bloxplorer - Bitcoin and Liquid Blockchain Explorer<a class="headerlink" href="#bloxplorer-bitcoin-and-liquid-blockchain-explorer" title="Permalink to this headline"></a></h1>
<p><a class="reference external" href="https://circleci.com/gh/valinsky/bloxplorer/tree/master"><img alt="circle" src="https://circleci.com/gh/valinsky/bloxplorer/tree/master.svg?style=shield" /></a> <a class="reference external" href="https://pypi.org/project/bloxplorer/"><img alt="version" src="https://img.shields.io/badge/version-0.1.2-blue" /></a> <a class="reference external" href="https://github.com/valinsky/bloxplorer/blob/master/LICENSE"><img alt="license" src="https://img.shields.io/badge/license-MIT-orange" /></a></p>
<p><a class="reference external" href="https://circleci.com/gh/valinsky/bloxplorer/tree/master"><img alt="circle" src="https://circleci.com/gh/valinsky/bloxplorer/tree/master.svg?style=shield" /></a> <a class="reference external" href="https://pypi.org/project/bloxplorer/"><img alt="version" src="https://img.shields.io/badge/version-0.1.3-blue" /></a> <a class="reference external" href="https://github.com/valinsky/bloxplorer/blob/master/LICENSE"><img alt="license" src="https://img.shields.io/badge/license-MIT-orange" /></a> <a class="reference external" href="https://pepy.tech/project/bloxplorer/"><img alt="downloads" src="https://pepy.tech/badge/bloxplorer" /></a></p>
<p><a class="reference internal" href="quickstart.html#quickstart"><span class="std std-ref">Quickstart</span></a></p>
<p><strong>Bloxplorer</strong> is a simple yet very effective Bitcoin and Liquid blockchain explorer.</p>
<p>It allows developers to make use of the full power of the <a class="reference external" href="https://github.com/Blockstream/esplora">Blockstream Esplora HTTP API</a> through a clean Python interface.</p>
<p>It allows developers to make use of the full power of the <a class="reference external" href="https://github.com/Blockstream/esplora/blob/master/API.md">Blockstream Esplora HTTP API</a> through a clean Python interface.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">bloxplorer</span> <span class="kn">import</span> <span class="n">bitcoin_explorer</span>

<span class="n">response</span> <span class="o">=</span> <span class="n">bitcoin_explorer</span><span class="o">.</span><span class="n">blocks</span><span class="o">.</span><span class="n">get_last_height</span><span class="p">()</span>
Expand Down
Loading

0 comments on commit 25d440b

Please sign in to comment.