Asynchronous IPFS client library (Privex Fork)
Project description
- info:
Asynchronous IPFS client library
aioipfs is a python3 library providing an asynchronous API for IPFS. Supported python versions: 3.6, 3.7, 3.8, 3.9
NOTE: This is a separate fork of the Original created by @pinnaculum (formerly cipres). This fork is maintained by Privex Inc. (primarily by @someguy123) - a Belizean server hosting + technology company.
Installation
pip3 install privex-aioipfs
# Or if you use pipenv
pipenv install privex-aioipfs
Usage examples
Get an IPFS resource
import sys
import asyncio
import aioipfs
async def get(ipfshash):
client = aioipfs.AsyncIPFS()
await client.get(ipfshash, dstdir='.')
await client.close()
loop = asyncio.get_event_loop()
loop.run_until_complete(get(sys.argv[1]))
loop.close()
Add some files
This example will import all files and directories specified on the command line. Note that the add API function is an asynchronous generator and therefore needs to be used with the async for syntax.
import sys
import asyncio
import aioipfs
async def add_files(files):
client = aioipfs.AsyncIPFS()
async for added_file in client.add(*files, recursive=True):
print('Imported file {0}, CID: {1}'.format(
added_file['Name'], added_file['Hash']))
await client.close()
loop = asyncio.get_event_loop()
loop.run_until_complete(add_files(sys.argv[1:]))
loop.close()
Pubsub service
async def pubsub_serve(topic):
async with aioipfs.AsyncIPFS() as cli:
async for message in cli.pubsub.sub(topic):
print('Received message from', message['from'])
await cli.pubsub.pub(topic, message['data'])
Features
Async file writing on get operations
The aiofiles library is used to asynchronously write data retrieved from the IPFS daemon when using the /api/v0/get API call, to avoid blocking the event loop. TAR extraction is done in asyncio’s threadpool.
Requirements
License
aioipfs is offered under the GNU Lesser GPL3 (LGPL3) license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file privex_aioipfs-0.5.8.tar.gz
.
File metadata
- Download URL: privex_aioipfs-0.5.8.tar.gz
- Upload date:
- Size: 26.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e04d4710bb8bb8043935f4d8bcf0394ec5a93ca069586334bc2fe820f852225 |
|
MD5 | 57a496e66cec9ef13399c9892bb0fb11 |
|
BLAKE2b-256 | cb1367061f549146800bdd9c5d2d7554edb63bfb146113c6dac02dc72fcccd88 |
File details
Details for the file privex_aioipfs-0.5.8-py3-none-any.whl
.
File metadata
- Download URL: privex_aioipfs-0.5.8-py3-none-any.whl
- Upload date:
- Size: 30.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bdf443b69238a2cca1d11a23b65e6b91c34b395480791382ac421d7f1a707d16 |
|
MD5 | 9b14e153501ae9f63664d4e10a19b1f0 |
|
BLAKE2b-256 | 8697288d2519d73193699cd3c6e871853d280d1708515c27daf4d580c22bce95 |