Skip to main content

Kubo Python Library

A Python wrapper for the Kubo (Go-IPFS) library.

Overview

This library provides Python bindings for Kubo, the Go implementation of IPFS, allowing you to:

  • Spawn an in-process IPFS node
  • Add and retrieve files/directories from IPFS
  • Connect to the IPFS network
  • Manage IPFS repositories
  • Publish and subscribe to IPFS PubSub topics
  • Mount and connect to remote TCP services via libp2p

Project Status

This library is very early in its development, and is published as a proof-of-concept that it is feasible to write a python wrapper around kubo (Go-IPFS) to run IPFS nodes from within python. Much of the code is LLM-generated, and code coverage is poor.

The API structure of this library WILL CHANGE in the near future!

So far this library has been tested on Linux x86 64-bit and Android ARM 64-bit (in Termux & in Kivy). Assuming that it proves to be a reliable way of working in python, this library will be developed to maturity and maintained.

Installation

pip install ipfs_node

Dev Requirements

  • Go 1.19+
  • Python 3.7+
  • IPFS Kubo dependencies

Basic Usage

Working with Files

from ipfs_node import IpfsNode

# Create a new node with a temporary repository
with IpfsNode.ephemeral() as node:
    # Add a file to IPFS
    cid = node.files.add_file("README.md")
    print(f"Added file with CID: {cid}")

    # Retrieve a file from IPFS
    node.files.download(cid, "/path/to/destination.txt")

Using PubSub

from ipfs_node import IpfsNode

with IpfsNode.ephemeral() as node:
    # Subscribe to a topic
    with node.pubsub.subscribe("my-topic") as subscription:
        # Publish a message
        node.pubsub.publish("my-topic", "Hello, IPFS world!")

        # Receive messages
        message = subscription.next_message(timeout=2.0)
        if message:
            print(f"Received: {message.data.decode('utf-8')}")

        # Or use a callback
        def on_message(msg):
            print(f"Received via callback: {msg.data.decode('utf-8')}")

        subscription.subscribe(on_message)

Using P2P Stream Mounting

from ipfs_node import IpfsNode

# Create an IPFS node
with IpfsNode.ephemeral() as node:

    # Example 1: Listen for connections on a protocol and forward them to a local service
    node.tunnels.open_listener("my-service", "127.0.0.1:8080")

    # Example 2: Forward local connections to a remote peer
    node.tunnels.open_sender("their-service", "127.0.0.1:9090", "QmPeerID...")

    # List active listeners and streams
    listeners, streams = node.tunnels.list_listeners()

    # Close specific connections when done
    node.tunnels.close_listener("my-service")
    node.tunnels.close_sender("their-service")

Documentation

Examples

License

MIT License

Metadata

Release files for kubo-python 0.1.5

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

Source distribution (sdist)

Source distribution for kubo-python 0.1.5
File Size Uploaded Provenance Actions
kubo_python-0.1.5.tar.gz 32.3 MB Without provenance Details for kubo_python-0.1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kubo-python 0.1.5
File Interpreter ABI Platform Actions
kubo_python-0.1.5-py3-none-any.whl Python 3 none any Details for kubo_python-0.1.5-py3-none-any.whl

Total release size: 64.8 MB

Release files / kubo_python-0.1.5.tar.gz

Download URL kubo_python-0.1.5.tar.gz
Size 32.3 MB
Tags Source
SHA-256 checksum
How to use checksums
c1e3c527e2a2301e795d48c440612f031770ac3376c8a7adbc398b271e9bc5d6
BLAKE2b-256 checksum
How to use checksums
4e31fadc3c20cd99d3ae0695aa471268cb5c4b61cec74bbbe04c28c2c0088f67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release files / kubo_python-0.1.5-py3-none-any.whl

Download URL kubo_python-0.1.5-py3-none-any.whl
Size 32.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
dd9a258bcec3d439ccd74a46fe77c6448cc432aabd3b380e35a3ad4e5341b0bd
BLAKE2b-256 checksum
How to use checksums
8920ee74a14776e9d7cd81de29aa6cf5e50d3aff348c8ff5ca026b04ee8ba143
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Security for kubo-python 0.1.5

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