Skip to main content

Asynchronous IPFS client library

Project description

info:

Asynchronous client library for IPFS

The aioipfs Python package provides asynchronous access to the IPFS API, using Python 3.5’s async/await mechanism.

Installation

PIP package coming soon, for now install with setup.py:

python setup.py install

Usage examples

Get an IPFS resource

import sys
import asyncio

import aioipfs

async def get(ipfshash):
    client = aioipfs.AsyncIPFS()
    await client.get(ipfshash)
    await client.close()

loop = asyncio.get_event_loop()
loop.run_until_complete(get(sys.argv[1]))
loop.close()

Included tools

asyncipfs

The asyncipfs program implements a few IPFS basic functions (add, get, pin, log etc..) with aioipfs. You can give multiple hashes parameters and they will be processed concurrently, for example:

asyncipfs get hash1 hash2 hash3

ipfs-find

ipfs-find allows you to search for content on any IPFS node you have access to. It can be useful to recover the hashes of something you’ve added a while ago. Usage:

usage: ipfs-find [-h] [--apihost str] [--apiport str] [-j] [-i] [--name NAME]
                 [--type TYPE] [--contains CONTAINS]

optional arguments:
  -h, --help           show this help message and exit
  --apihost str        IPFS API host
  --apiport str        IPFS API port
  -j                   JSON output
  -i                   Case-insensitive match
  --name NAME          Match object name
  --type TYPE          Match object type ('d' for directory, 'f' for file)
  --contains CONTAINS  Match object content

Example: search for files whose name matches ‘dmenu.*.c’ and which contains ‘size_t’, with output in JSON:

ipfs-find  --type f --name 'dmenu.*.c$' --contains 'size_t' -j
[
    {
        "Name": "dmenu.c",
        "Hash": "Qmb7MGgtGzWn2NQ1PbxhXjZCwNxxuJUSRfMfSL1ZFW2Fwk",
        "Size": 16926,
        "Type": 2
    }
]

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 GPL3 license.

Authors

David Ferlier

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aioipfs-0.3.tar.gz (17.3 kB view hashes)

Uploaded Source

Built Distributions

aioipfs-0.3-py3.6.egg (35.6 kB view hashes)

Uploaded Source

aioipfs-0.3-py3-none-any.whl (15.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page