summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2023-06-20 10:06:42 +0000
committerCoprDistGit <infra@openeuler.org>2023-06-20 10:06:42 +0000
commitdfafbaf554beae14d5c82d387250b0785d4a4177 (patch)
tree14b0d81481cb960efb0e77b390cc05f940dc5187
parent0095ad97709b1258df33972aa3ec62f9861cfe3e (diff)
automatic import of python-blockfrost-pythonopeneuler20.03
-rw-r--r--.gitignore1
-rw-r--r--python-blockfrost-python.spec583
-rw-r--r--sources1
3 files changed, 585 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..7429e4b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/blockfrost-python-0.5.3.tar.gz
diff --git a/python-blockfrost-python.spec b/python-blockfrost-python.spec
new file mode 100644
index 0000000..4d21e4c
--- /dev/null
+++ b/python-blockfrost-python.spec
@@ -0,0 +1,583 @@
+%global _empty_manifest_terminate_build 0
+Name: python-blockfrost-python
+Version: 0.5.3
+Release: 1
+Summary: The official Python SDK for Blockfrost API v0.1.37
+License: Apache-2.0
+URL: https://github.com/blockfrost/blockfrost-python
+Source0: https://mirrors.aliyun.com/pypi/web/packages/a9/60/6701ac0588ba48dda821a1249aee447ceeb844601d00c509c17843a3af6e/blockfrost-python-0.5.3.tar.gz
+BuildArch: noarch
+
+Requires: python3-requests
+
+%description
+[![Package Test](https://img.shields.io/github/actions/workflow/status/blockfrost/blockfrost-python/package-test.yml?logo=GitHub&label=package%20test)](https://github.com/blockfrost/blockfrost-python/actions/workflows/package-test.yml)
+[![PyPI Latest Release](https://img.shields.io/pypi/v/blockfrost-python.svg?logo=pypi&label=pypi%20latest)](https://pypi.org/project/blockfrost-python/)
+[![PyPI - Downloads](https://img.shields.io/pypi/dm/blockfrost-python?logo=pypi&label=pypi%20downloads)](https://pypistats.org/packages/blockfrost-python)
+[![Package Status](https://img.shields.io/pypi/status/blockfrost-python.svg)](https://pypi.org/project/blockfrost-python/)
+[![License](https://img.shields.io/pypi/l/blockfrost-python.svg)](https://github.com/blockfrost/blockfrost-python/blob/master/LICENSE)
+[![Made by Five Binaries](https://img.shields.io/badge/made%20by-Five%20Binaries-darkviolet.svg)](https://fivebinaries.com/)
+[![Maintained by Mathias Frohlich](https://img.shields.io/badge/maintained%20by-Mathias%20Frohlich-blue.svg)](https://github.com/mathiasfrohlich)
+
+<img src="https://blockfrost.io/images/logo.svg" width="250" align="right" height="90">
+
+# blockfrost-python
+
+<br/>
+
+<p align="center">A Python SDK for Blockfrost.io API.</p>
+<p align="center">
+ <a href="#getting-started">Getting started</a> •
+ <a href="#installation">Installation</a> •
+ <a href="#usage">Usage</a>
+</p>
+<br>
+
+## Getting started
+
+To use this SDK, you first need login into to [blockfrost.io](https://blockfrost.io) create your project to retrieve
+your API key.
+
+<img src="https://i.imgur.com/smY12ro.png">
+
+<br/>
+
+## Installation
+
+[![PyPI Latest Release](https://img.shields.io/pypi/v/blockfrost-python.svg)](https://pypi.org/project/blockfrost-python/)
+
+```console
+$ pip install blockfrost-python
+```
+
+<br/>
+
+## Usage
+
+Using the SDK is pretty straight-forward as you can see from the following examples.
+
+### Cardano
+
+```python
+from blockfrost import BlockFrostApi, ApiError, ApiUrls
+
+api = BlockFrostApi(
+ project_id='YOUR API KEY HERE', # or export environment variable BLOCKFROST_PROJECT_ID
+ # optional: pass base_url or export BLOCKFROST_API_URL to use testnet, defaults to ApiUrls.mainnet.value
+ base_url=ApiUrls.testnet.value,
+)
+try:
+ health = api.health()
+ print(health) # prints object: HealthResponse(is_healthy=True)
+ health = api.health(return_type='json') # Can be useful if python wrapper is behind api version
+ print(health) # prints json: {"is_healthy":True}
+ health = api.health(return_type='pandas')
+ print(health) # prints Dataframe: is_healthy
+ # 0 True
+
+
+ account_rewards = api.account_rewards(
+ stake_address='stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7',
+ count=20,
+ )
+ print(account_rewards[0].epoch) # prints 221
+ print(len(account_rewards)) # prints 20
+
+ account_rewards = api.account_rewards(
+ stake_address='stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7',
+ count=20,
+ gather_pages=True, # will collect all pages
+ )
+ print(account_rewards[0].epoch) # prints 221
+ print(len(account_rewards)) # prints 57
+
+ address = api.address(
+ address='addr1qxqs59lphg8g6qndelq8xwqn60ag3aeyfcp33c2kdp46a09re5df3pzwwmyq946axfcejy5n4x0y99wqpgtp2gd0k09qsgy6pz')
+ print(address.type) # prints 'shelley'
+ for amount in address.amount:
+ print(amount.unit) # prints 'lovelace'
+
+except ApiError as e:
+ print(e)
+```
+
+### IPFS
+
+```python
+from blockfrost import BlockFrostIPFS, ApiError
+
+ipfs = BlockFrostIPFS(
+ project_id='YOUR API KEY HERE' # or export environment variable BLOCKFROST_PROJECT_ID
+)
+file_hash = None
+try:
+ ipfs_object = ipfs.add('./README.md')
+ file_hash = ipfs_object.ipfs_hash
+ print(file_hash)
+except ApiError as e:
+ print(e)
+
+try:
+ with open('./README_downloaded.md', 'w') as file:
+ file_data = ipfs.gateway(IPFS_path=file_hash).text
+ file.write(file_data)
+except ApiError as e:
+ print(e)
+```
+
+### Verifying Secure Webhook signature
+
+Webhooks enable Blockfrost to push real-time notifications to your application. In order to prevent malicious actor from pretending to be Blockfrost every webhook request is signed. The signature is included in a request's `Blockfrost-Signature` header. This allows you to verify that the events were sent by Blockfrost, not by a third party.
+To learn more about Secure Webhooks, see [Secure Webhooks Docs](https://blockfrost.dev/docs/start-building/webhooks/).
+
+You can verify the signature using `verifyWebhookSignature` function.
+
+Example:
+
+```python
+# Example of Python Flask app with /webhook endpoint
+# for processing events sent by Blockfrost Secure Webhooks
+from flask import Flask, request, json
+from blockfrost import verify_webhook_signature, SignatureVerificationError
+
+SECRET_AUTH_TOKEN = "SECRET-WEBHOOK-AUTH-TOKEN"
+
+app = Flask(__name__)
+
+@app.route('/webhook', methods=['POST'])
+def webhook():
+ if request.method == 'POST':
+ # Validate webhook signature
+ request_bytes = request.get_data()
+ try:
+ verify_webhook_signature(
+ request_bytes, request.headers['Blockfrost-Signature'], SECRET_AUTH_TOKEN)
+ except SignatureVerificationError as e:
+ # for easier debugging you can access passed header and request_body values (e.header, e.request_body)
+ print('Webhook signature is invalid.', e)
+ return 'Invalid signature', 403
+
+ # Get the payload as JSON
+ event = request.json
+
+ print('Received request id {}, webhook_id: {}'.format(
+ event['id'], event['webhook_id']))
+
+ if event['type'] == "block":
+ # process Block event
+ print('Received block hash {}'.format(event['payload']['hash']))
+ elif event['type'] == "...":
+ # truncated
+ else:
+ # Unexpected event type
+ print('Unexpected event type {}'.format(event['type']))
+
+ return 'Webhook received', 200
+ else:
+ return 'POST Method not supported', 405
+
+
+
+if __name__ == "__main__":
+ app.run(host='0.0.0.0', port=6666)
+```
+
+
+%package -n python3-blockfrost-python
+Summary: The official Python SDK for Blockfrost API v0.1.37
+Provides: python-blockfrost-python
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-blockfrost-python
+[![Package Test](https://img.shields.io/github/actions/workflow/status/blockfrost/blockfrost-python/package-test.yml?logo=GitHub&label=package%20test)](https://github.com/blockfrost/blockfrost-python/actions/workflows/package-test.yml)
+[![PyPI Latest Release](https://img.shields.io/pypi/v/blockfrost-python.svg?logo=pypi&label=pypi%20latest)](https://pypi.org/project/blockfrost-python/)
+[![PyPI - Downloads](https://img.shields.io/pypi/dm/blockfrost-python?logo=pypi&label=pypi%20downloads)](https://pypistats.org/packages/blockfrost-python)
+[![Package Status](https://img.shields.io/pypi/status/blockfrost-python.svg)](https://pypi.org/project/blockfrost-python/)
+[![License](https://img.shields.io/pypi/l/blockfrost-python.svg)](https://github.com/blockfrost/blockfrost-python/blob/master/LICENSE)
+[![Made by Five Binaries](https://img.shields.io/badge/made%20by-Five%20Binaries-darkviolet.svg)](https://fivebinaries.com/)
+[![Maintained by Mathias Frohlich](https://img.shields.io/badge/maintained%20by-Mathias%20Frohlich-blue.svg)](https://github.com/mathiasfrohlich)
+
+<img src="https://blockfrost.io/images/logo.svg" width="250" align="right" height="90">
+
+# blockfrost-python
+
+<br/>
+
+<p align="center">A Python SDK for Blockfrost.io API.</p>
+<p align="center">
+ <a href="#getting-started">Getting started</a> •
+ <a href="#installation">Installation</a> •
+ <a href="#usage">Usage</a>
+</p>
+<br>
+
+## Getting started
+
+To use this SDK, you first need login into to [blockfrost.io](https://blockfrost.io) create your project to retrieve
+your API key.
+
+<img src="https://i.imgur.com/smY12ro.png">
+
+<br/>
+
+## Installation
+
+[![PyPI Latest Release](https://img.shields.io/pypi/v/blockfrost-python.svg)](https://pypi.org/project/blockfrost-python/)
+
+```console
+$ pip install blockfrost-python
+```
+
+<br/>
+
+## Usage
+
+Using the SDK is pretty straight-forward as you can see from the following examples.
+
+### Cardano
+
+```python
+from blockfrost import BlockFrostApi, ApiError, ApiUrls
+
+api = BlockFrostApi(
+ project_id='YOUR API KEY HERE', # or export environment variable BLOCKFROST_PROJECT_ID
+ # optional: pass base_url or export BLOCKFROST_API_URL to use testnet, defaults to ApiUrls.mainnet.value
+ base_url=ApiUrls.testnet.value,
+)
+try:
+ health = api.health()
+ print(health) # prints object: HealthResponse(is_healthy=True)
+ health = api.health(return_type='json') # Can be useful if python wrapper is behind api version
+ print(health) # prints json: {"is_healthy":True}
+ health = api.health(return_type='pandas')
+ print(health) # prints Dataframe: is_healthy
+ # 0 True
+
+
+ account_rewards = api.account_rewards(
+ stake_address='stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7',
+ count=20,
+ )
+ print(account_rewards[0].epoch) # prints 221
+ print(len(account_rewards)) # prints 20
+
+ account_rewards = api.account_rewards(
+ stake_address='stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7',
+ count=20,
+ gather_pages=True, # will collect all pages
+ )
+ print(account_rewards[0].epoch) # prints 221
+ print(len(account_rewards)) # prints 57
+
+ address = api.address(
+ address='addr1qxqs59lphg8g6qndelq8xwqn60ag3aeyfcp33c2kdp46a09re5df3pzwwmyq946axfcejy5n4x0y99wqpgtp2gd0k09qsgy6pz')
+ print(address.type) # prints 'shelley'
+ for amount in address.amount:
+ print(amount.unit) # prints 'lovelace'
+
+except ApiError as e:
+ print(e)
+```
+
+### IPFS
+
+```python
+from blockfrost import BlockFrostIPFS, ApiError
+
+ipfs = BlockFrostIPFS(
+ project_id='YOUR API KEY HERE' # or export environment variable BLOCKFROST_PROJECT_ID
+)
+file_hash = None
+try:
+ ipfs_object = ipfs.add('./README.md')
+ file_hash = ipfs_object.ipfs_hash
+ print(file_hash)
+except ApiError as e:
+ print(e)
+
+try:
+ with open('./README_downloaded.md', 'w') as file:
+ file_data = ipfs.gateway(IPFS_path=file_hash).text
+ file.write(file_data)
+except ApiError as e:
+ print(e)
+```
+
+### Verifying Secure Webhook signature
+
+Webhooks enable Blockfrost to push real-time notifications to your application. In order to prevent malicious actor from pretending to be Blockfrost every webhook request is signed. The signature is included in a request's `Blockfrost-Signature` header. This allows you to verify that the events were sent by Blockfrost, not by a third party.
+To learn more about Secure Webhooks, see [Secure Webhooks Docs](https://blockfrost.dev/docs/start-building/webhooks/).
+
+You can verify the signature using `verifyWebhookSignature` function.
+
+Example:
+
+```python
+# Example of Python Flask app with /webhook endpoint
+# for processing events sent by Blockfrost Secure Webhooks
+from flask import Flask, request, json
+from blockfrost import verify_webhook_signature, SignatureVerificationError
+
+SECRET_AUTH_TOKEN = "SECRET-WEBHOOK-AUTH-TOKEN"
+
+app = Flask(__name__)
+
+@app.route('/webhook', methods=['POST'])
+def webhook():
+ if request.method == 'POST':
+ # Validate webhook signature
+ request_bytes = request.get_data()
+ try:
+ verify_webhook_signature(
+ request_bytes, request.headers['Blockfrost-Signature'], SECRET_AUTH_TOKEN)
+ except SignatureVerificationError as e:
+ # for easier debugging you can access passed header and request_body values (e.header, e.request_body)
+ print('Webhook signature is invalid.', e)
+ return 'Invalid signature', 403
+
+ # Get the payload as JSON
+ event = request.json
+
+ print('Received request id {}, webhook_id: {}'.format(
+ event['id'], event['webhook_id']))
+
+ if event['type'] == "block":
+ # process Block event
+ print('Received block hash {}'.format(event['payload']['hash']))
+ elif event['type'] == "...":
+ # truncated
+ else:
+ # Unexpected event type
+ print('Unexpected event type {}'.format(event['type']))
+
+ return 'Webhook received', 200
+ else:
+ return 'POST Method not supported', 405
+
+
+
+if __name__ == "__main__":
+ app.run(host='0.0.0.0', port=6666)
+```
+
+
+%package help
+Summary: Development documents and examples for blockfrost-python
+Provides: python3-blockfrost-python-doc
+%description help
+[![Package Test](https://img.shields.io/github/actions/workflow/status/blockfrost/blockfrost-python/package-test.yml?logo=GitHub&label=package%20test)](https://github.com/blockfrost/blockfrost-python/actions/workflows/package-test.yml)
+[![PyPI Latest Release](https://img.shields.io/pypi/v/blockfrost-python.svg?logo=pypi&label=pypi%20latest)](https://pypi.org/project/blockfrost-python/)
+[![PyPI - Downloads](https://img.shields.io/pypi/dm/blockfrost-python?logo=pypi&label=pypi%20downloads)](https://pypistats.org/packages/blockfrost-python)
+[![Package Status](https://img.shields.io/pypi/status/blockfrost-python.svg)](https://pypi.org/project/blockfrost-python/)
+[![License](https://img.shields.io/pypi/l/blockfrost-python.svg)](https://github.com/blockfrost/blockfrost-python/blob/master/LICENSE)
+[![Made by Five Binaries](https://img.shields.io/badge/made%20by-Five%20Binaries-darkviolet.svg)](https://fivebinaries.com/)
+[![Maintained by Mathias Frohlich](https://img.shields.io/badge/maintained%20by-Mathias%20Frohlich-blue.svg)](https://github.com/mathiasfrohlich)
+
+<img src="https://blockfrost.io/images/logo.svg" width="250" align="right" height="90">
+
+# blockfrost-python
+
+<br/>
+
+<p align="center">A Python SDK for Blockfrost.io API.</p>
+<p align="center">
+ <a href="#getting-started">Getting started</a> •
+ <a href="#installation">Installation</a> •
+ <a href="#usage">Usage</a>
+</p>
+<br>
+
+## Getting started
+
+To use this SDK, you first need login into to [blockfrost.io](https://blockfrost.io) create your project to retrieve
+your API key.
+
+<img src="https://i.imgur.com/smY12ro.png">
+
+<br/>
+
+## Installation
+
+[![PyPI Latest Release](https://img.shields.io/pypi/v/blockfrost-python.svg)](https://pypi.org/project/blockfrost-python/)
+
+```console
+$ pip install blockfrost-python
+```
+
+<br/>
+
+## Usage
+
+Using the SDK is pretty straight-forward as you can see from the following examples.
+
+### Cardano
+
+```python
+from blockfrost import BlockFrostApi, ApiError, ApiUrls
+
+api = BlockFrostApi(
+ project_id='YOUR API KEY HERE', # or export environment variable BLOCKFROST_PROJECT_ID
+ # optional: pass base_url or export BLOCKFROST_API_URL to use testnet, defaults to ApiUrls.mainnet.value
+ base_url=ApiUrls.testnet.value,
+)
+try:
+ health = api.health()
+ print(health) # prints object: HealthResponse(is_healthy=True)
+ health = api.health(return_type='json') # Can be useful if python wrapper is behind api version
+ print(health) # prints json: {"is_healthy":True}
+ health = api.health(return_type='pandas')
+ print(health) # prints Dataframe: is_healthy
+ # 0 True
+
+
+ account_rewards = api.account_rewards(
+ stake_address='stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7',
+ count=20,
+ )
+ print(account_rewards[0].epoch) # prints 221
+ print(len(account_rewards)) # prints 20
+
+ account_rewards = api.account_rewards(
+ stake_address='stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7',
+ count=20,
+ gather_pages=True, # will collect all pages
+ )
+ print(account_rewards[0].epoch) # prints 221
+ print(len(account_rewards)) # prints 57
+
+ address = api.address(
+ address='addr1qxqs59lphg8g6qndelq8xwqn60ag3aeyfcp33c2kdp46a09re5df3pzwwmyq946axfcejy5n4x0y99wqpgtp2gd0k09qsgy6pz')
+ print(address.type) # prints 'shelley'
+ for amount in address.amount:
+ print(amount.unit) # prints 'lovelace'
+
+except ApiError as e:
+ print(e)
+```
+
+### IPFS
+
+```python
+from blockfrost import BlockFrostIPFS, ApiError
+
+ipfs = BlockFrostIPFS(
+ project_id='YOUR API KEY HERE' # or export environment variable BLOCKFROST_PROJECT_ID
+)
+file_hash = None
+try:
+ ipfs_object = ipfs.add('./README.md')
+ file_hash = ipfs_object.ipfs_hash
+ print(file_hash)
+except ApiError as e:
+ print(e)
+
+try:
+ with open('./README_downloaded.md', 'w') as file:
+ file_data = ipfs.gateway(IPFS_path=file_hash).text
+ file.write(file_data)
+except ApiError as e:
+ print(e)
+```
+
+### Verifying Secure Webhook signature
+
+Webhooks enable Blockfrost to push real-time notifications to your application. In order to prevent malicious actor from pretending to be Blockfrost every webhook request is signed. The signature is included in a request's `Blockfrost-Signature` header. This allows you to verify that the events were sent by Blockfrost, not by a third party.
+To learn more about Secure Webhooks, see [Secure Webhooks Docs](https://blockfrost.dev/docs/start-building/webhooks/).
+
+You can verify the signature using `verifyWebhookSignature` function.
+
+Example:
+
+```python
+# Example of Python Flask app with /webhook endpoint
+# for processing events sent by Blockfrost Secure Webhooks
+from flask import Flask, request, json
+from blockfrost import verify_webhook_signature, SignatureVerificationError
+
+SECRET_AUTH_TOKEN = "SECRET-WEBHOOK-AUTH-TOKEN"
+
+app = Flask(__name__)
+
+@app.route('/webhook', methods=['POST'])
+def webhook():
+ if request.method == 'POST':
+ # Validate webhook signature
+ request_bytes = request.get_data()
+ try:
+ verify_webhook_signature(
+ request_bytes, request.headers['Blockfrost-Signature'], SECRET_AUTH_TOKEN)
+ except SignatureVerificationError as e:
+ # for easier debugging you can access passed header and request_body values (e.header, e.request_body)
+ print('Webhook signature is invalid.', e)
+ return 'Invalid signature', 403
+
+ # Get the payload as JSON
+ event = request.json
+
+ print('Received request id {}, webhook_id: {}'.format(
+ event['id'], event['webhook_id']))
+
+ if event['type'] == "block":
+ # process Block event
+ print('Received block hash {}'.format(event['payload']['hash']))
+ elif event['type'] == "...":
+ # truncated
+ else:
+ # Unexpected event type
+ print('Unexpected event type {}'.format(event['type']))
+
+ return 'Webhook received', 200
+ else:
+ return 'POST Method not supported', 405
+
+
+
+if __name__ == "__main__":
+ app.run(host='0.0.0.0', port=6666)
+```
+
+
+%prep
+%autosetup -n blockfrost-python-0.5.3
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "\"/%h/%f\"\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "\"/%h/%f\"\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "\"/%h/%f.gz\"\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-blockfrost-python -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Tue Jun 20 2023 Python_Bot <Python_Bot@openeuler.org> - 0.5.3-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..eeff1f2
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+2141ad50d95ef868da2ab311b81992c2 blockfrost-python-0.5.3.tar.gz