Skip to main content

Welcome to IPFSPy by Algovera

What is IPFSPy?

IPFSPy is a python library by Algovera to interact with IPFS and IPFS ecosystem such as the common pinning services. It is designed by data scientists for data scientists to interact with the IPFS ecosystem without leaving the comfort of python and jupyter notebook.

You can learn more about IPFS here.

IPFS is built using the go-lang or javascript. With IPFSPy, you can interact with IPFS using the exposed HTTP RPC API.

Ipfspy has two different implementations to interact with IPFS

  1. Access to most of what HTTP RPC API through ipfspy.ipfshttpapi

    With ipfspy.ipfshttpapi, you can either use local, infura or public nodes. In order to use local node, you will need a IPFS deamon running in the form of IPFS Desktop, IPFS Campanion or IPFS CLI. As an alternative, you can connect via the Infura’s dedicated IPFS gateway.

  2. fsspec-like implementation through ipfspy.ipfspec

    What is ipfsspec?

    ipfsspec is the fsspec-like implementation for IPFS. Through ipfspy.ipfsspec, you get access to both local and infura nodes but the public node is read-only. Local node offers both read and write. In order to use local node, you will need a local node running locally through IPFS Desktop or IPFS Companion or the IPFS CLI.

    Advantages of fsspec-like implementations

    • many data science libraries like dask, pandas and xarray uses fsspec for path and file handling
    • provides an uniform APIs

    Since many data science use fsspec, by implementing ipfsspec, fsspec supports IPFS.

Installing

You can install the library simply through

pip install ipfspy

If you plan to contribute to this library, 1. clone the repo locally git clone https://github.com/algoveraai/ipfspy

  1. Install an editable version of the repo pip install -e .[dev]

  2. submit PR

How to use

ipfshttpapi

Extend the IPFSApi

api = IPFSApi()
Changed to local node

Change to other nodes like below. You can choose one of local infura or public

api.change_gateway_type = 'infura'
Changed to infura node
api.change_gateway_type = 'local'
Changed to local node

To add a file to IPFS,

res, obj = api.add_items('output/test.txt'); obj
[{'Name': 'test.txt', 'Bytes': 20},
 {'Name': 'test.txt',
  'Hash': 'QmbwFKzLj9m2qwBFYTVrBotf4QujvzTb1GBV9wFcNPMctm',
  'Size': '28'}]

To retrieve a file from IPFS

response, content = api.cat_items(cid='QmbwFKzLj9m2qwBFYTVrBotf4QujvzTb1GBV9wFcNPMctm'); content
"\n'''\nFirst file\n'''\n"

ipfsspec

import fsspec, io, os, asyncio
from ipfspy.ipfsspec.asyn import AsyncIPFSFileSystem
from fsspec import register_implementation

Register the ipfsspec to fsspec

register_implementation(AsyncIPFSFileSystem.protocol, AsyncIPFSFileSystem)
class fs:
    ipfs = fsspec.filesystem("ipfs")
    file = fsspec.filesystem("file")
Changed to local node

Like ipfspy.ipfshttpapi, you can change the node as such

fs.ipfs.change_gateway_type = 'public'
Changed to public node
fs.ipfs.change_gateway_type = 'local'
Changed to local node

Add a file to IPFS using fsspec-like api

put_file_res = fs.ipfs.put(path='output/test.txt', rpath='/test_put_file'); put_file_res
'QmbwFKzLj9m2qwBFYTVrBotf4QujvzTb1GBV9wFcNPMctm'

Retrieve a file from IPFs using fsspec-like api

fs.ipfs.cat('QmbwFKzLj9m2qwBFYTVrBotf4QujvzTb1GBV9wFcNPMctm')
b"\n'''\nFirst file\n'''\n"

Metadata

Release files for ipfspy 0.0.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ipfspy 0.0.15
File Size Uploaded Provenance Actions
ipfspy-0.0.15.tar.gz 35.6 kB Without provenance Details for ipfspy-0.0.15.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ipfspy 0.0.15
File Interpreter ABI Platform Actions
ipfspy-0.0.15-py3-none-any.whl Python 3 none any Details for ipfspy-0.0.15-py3-none-any.whl

Total release size: 71.2 kB

Release files / ipfspy-0.0.15.tar.gz

Download URL ipfspy-0.0.15.tar.gz
Size 35.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7263861d60352e4e68c3f43e74b7a1aab2586aef6d1ec09699488aac67fc303d
BLAKE2b-256 checksum
How to use checksums
f2945cd785be11989b48d414ce73f33ce436f00d3a4b14f0d52c035c33619956
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Release files / ipfspy-0.0.15-py3-none-any.whl

Download URL ipfspy-0.0.15-py3-none-any.whl
Size 35.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
11358e5d615a397c188453561b8b5270b6b1b2bee5c100f213597d55ba939de8
BLAKE2b-256 checksum
How to use checksums
f6f2e64803afa3cdcf2676e7a33f434b79b32a992ef1b2a5dd3f31358c4fd68c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Security for ipfspy 0.0.15

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page