= IPFSApi() api
Changed to local node
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
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.
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
dask
, pandas
and xarray
uses fsspec for path and file handlingSince many data science use fsspec, by implementing ipfsspec, fsspec supports IPFS.
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
Install an editable version of the repo pip install -e .[dev]
submit PR
Extend the IPFSApi
Change to other nodes like below. You can choose one of local
infura
or public
To add a file to IPFS,
[{'Name': 'test.txt', 'Bytes': 20},
{'Name': 'test.txt',
'Hash': 'QmbwFKzLj9m2qwBFYTVrBotf4QujvzTb1GBV9wFcNPMctm',
'Size': '28'}]
To retrieve a file from IPFS
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
Add a file to IPFS using fsspec-like api
'QmbwFKzLj9m2qwBFYTVrBotf4QujvzTb1GBV9wFcNPMctm'
Retrieve a file from IPFs using fsspec-like api