IPFS Cluster HTTP API
This is a python package to interact with the HTTP REST API of the IPFS cluster. Full API documentation is available on gitlab pages.
Installation
ipfscluster is available from the PyPI repository:
pip install ipfscluster
Getting an IPFS Cluster Running
To try the API out, you need to have a running IPFS cluster. The easiest way to get one of those is to use docker. In the docker-compose.yml file shown below, you will need to adjust the volumes tags to reference actual folders on your host machine. The change in environment variables for ipfs_cluster service makes use the docker network DNS resolution by service name. Since our docker agent is called ipfs, we can get its IP address in the internal, backend network by using ipfs as its DNS name.
Copy this YML into a docker-compose.yml file in some folder and then run docker-compose up.
version: "3.7"
services:
ipfs:
image: ipfs/go-ipfs:latest
ports:
- "4001:4001"
- "5001:5001"
networks:
- backend
volumes:
- ~/ipfs/ipfs:/data/ipfs
ipfs_cluster:
image: ipfs/ipfs-cluster:latest
ports:
- "9094:9094"
- "9095:9094"
- "9096:9096"
volumes:
- ~/ipfs/ipfs-cluster:/data/ipfs-cluster
networks:
- backend
depends_on:
- ipfs
environment:
- CLUSTER_IPFSHTTP_NODEMULTIADDRESS=/dns4/ipfs/tcp/5001
- CLUSTER_IPFSPROXY_NODEMULTIADDRESS=/dns4/ipfs/tcp/5001
networks:
backend:
Try out the API
Now that you have a cluster running, you can try the API out. Open a python CLI and try:
client = connect()
m = {'name': 'bytes',
'cid': {'/': 'QmZfF6C9j4VtoCsTp4KSrhYH47QMd3DNXVZBKaxJdhaPab'},
'size': 30}
with client:
r = client.add_bytes(b"Mary had a little lamb")
assert r == m
Running Unit Tests
Running unit tests can prove to be a massive pain because the gitlab CI runner runs on docker. For a project like this that uses docker-compose, we have to use docker-in-docker according to their instructions. However, the documentation is sparse and there are lots of dead-ends… Here are the steps to get the docker-compose.yml file to work:
Install a local gitlab-runner using brew install gitlab-runner.
gitlab-runner exec docker --docker-privileged test. Notice that there is a --docker-privileged argument. Without that, the docker-in-docker won’t work.
Make sure all the multiaddr reference the docker service (which hosts all the other containers using dind).
tox should work, but for some reason: running the tests using tox produces connection refused errors, whereas running straight with pytest does not. Something about the tox environment screws things up.
Metadata
Release files for ipfscluster 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ipfscluster-0.2.0.tar.gz | 11.4 kB | Without provenance | Details for ipfscluster-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ipfscluster-0.2.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for ipfscluster-0.2.0-py2.py3-none-any.whl |
Total release size: 35.1 kB
Release files / ipfscluster-0.2.0.tar.gz
| Download URL | ipfscluster-0.2.0.tar.gz |
|---|---|
| Size | 11.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
596b20d1c18844aee41860a59fb5bbfb5e771a3b4ca37d7123366f5a9761a325
|
|
BLAKE2b-256 checksum How to use checksums |
bb969de7d042c4334de5e83ea25894a78b11b4cf2038ac6deb400ea41319bcdb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15
|
Release files / ipfscluster-0.2.0-py2.py3-none-any.whl
| Download URL | ipfscluster-0.2.0-py2.py3-none-any.whl |
|---|---|
| Size | 23.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
fbd1561c8571876b37ef73786c94278ff5589c3ec929a4d5d464a5a5ec2b0ed7
|
|
BLAKE2b-256 checksum How to use checksums |
c7724b1800c2ae91136ef5bed29710b5e9015cfbb499e759f51ef3513793145f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15
|
Security for ipfscluster 0.2.0
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.