Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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 EXPERIMENTAL

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

Compatibility

  • linux x86-64 (tested on Ubuntu)
  • linux arm-64 (tested on Ubuntu on a raspberry pi 5)

Roadmap

py_ipfs_node, will be incorporated into ipfs_toolkit when py_ipfs_node's API has stabilised.

ipfs_toolkit will become a multimodal IPFS library with a unified API for alternative modes of using IPFS:

  • running an embedded IPFS node
  • interacting with a separate IPFS node via its HTTP RPC

You can check out a prototype version of the combination of these two libraries under the kubo_python branch of the IPFS-Toolkit repo: https://github.com/emendir/IPFS-Toolkit-Python/tree/kubo_python

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.publish("README.md")
    print(f"Added file with CID: {cid}")
    
    # Retrieve a file from IPFS
    node.files.download(cid, "download.md")

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 TCP Tunnels (LibP2P 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", 8888)
    
    # Example 2: Forward local connections to a remote peer
    node.tunnels.open_sender("their-service", 8889, node.peer_id)
    
    # List active listeners and streams
    tunnels = node.tunnels.get_tunnels()
    print(tunnels.listeners)
    print(tunnels.senders)
    
    # Close specific connections when done
    node.tunnels.close_listener("my-service")
    node.tunnels.close_sender("their-service")

Documentation

Examples

Contributing

Get Involved

  • GitHub Discussions: if you want to share ideas
  • GitHub Issues: if you find bugs, other issues, or would like to submit feature requests
  • GitHub Merge Requests: if you think you know what you're doing, you're very welcome!

Donations

To support me in my work on this and other projects, you can make donations with the following currencies:

Donations help me:

  • dedicate more time to developing and maintaining open-source projects
  • cover costs for IT infrastructure
  • finance projects requiring additional hardware & compute

About the Developer

This project is developed by a human one-man team, publishing under the name Emendir.
I build open technologies trying to improve our world; learning, working and sharing under the principle:

Freely I have received, freely I give.

Feel welcome to join in with code contributions, discussions, ideas and more!

Open-Source in the Public Domain

I dedicate this project to the public domain. It is open source and free to use, share, modify, and build upon without restrictions or conditions.

I make no patent or trademark claims over this project.

Formally, you may use this project under either the:

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ipfs_node-0.1.12rc9-py3-none-win_amd64.whl (24.6 MB view details)

Uploaded Python 3Windows x86-64

ipfs_node-0.1.12rc9-py3-none-manylinux_2_17_x86_64.whl (32.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

ipfs_node-0.1.12rc9-py3-none-manylinux_2_17_aarch64.whl (32.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

ipfs_node-0.1.12rc9-py3-none-macosx_10_9_x86_64.whl (29.6 MB view details)

Uploaded Python 3macOS 10.9+ x86-64

ipfs_node-0.1.12rc9-py3-none-macosx_10_9_universal2.whl (57.2 MB view details)

Uploaded Python 3macOS 10.9+ universal2 (ARM64, x86-64)

ipfs_node-0.1.12rc9-py3-none-macosx_10_9_arm64.whl (27.6 MB view details)

Uploaded Python 3macOS 10.9+ ARM64

ipfs_node-0.1.12rc9-py3-none-android_28_arm64_v8a.whl (32.2 MB view details)

Uploaded Android API level 28+ ARM64 v8aPython 3

File details

Details for the file ipfs_node-0.1.12rc9-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for ipfs_node-0.1.12rc9-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 4c281d7c00bdb27e54c5a277be90670fd77188fa335aea0ed55f62986cb23e60
MD5 4d917cf145e3d5af80a5d017f15a1e83
BLAKE2b-256 566706b4098f6edfbd6e4c8f9a1d3d8b35f1838595398b2541b9aa199a08c1b4

See more details on using hashes here.

File details

Details for the file ipfs_node-0.1.12rc9-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for ipfs_node-0.1.12rc9-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 6e7357b626f83891756d14c608bc8d02930155bdd459023d9d6fc894499e373c
MD5 24e2032bcd34d54ced2b8b155fa52c78
BLAKE2b-256 3118caae081a49df81e94b3bf85e4bf35d509aced87aa74f057a7193b3a40f87

See more details on using hashes here.

File details

Details for the file ipfs_node-0.1.12rc9-py3-none-manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for ipfs_node-0.1.12rc9-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 4a2ca20fe4d94c4e9c5b550eb0ad8135e882e701301455c5c8d8e52fca2a8f88
MD5 bdd882cec3a68cce180254ad3d686556
BLAKE2b-256 cb135a1dd3144e9c475b544f50adf041e96ad31dc10b1803247610e722a5c5b2

See more details on using hashes here.

File details

Details for the file ipfs_node-0.1.12rc9-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for ipfs_node-0.1.12rc9-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7bbb6cb21c856a446fd7bdb9028d1f138a2625205d30db79de434f1c68559453
MD5 33edd092f15c21e6b9156a3da30757af
BLAKE2b-256 c62afa371d31b8cc5f716741529d2ad4640734be4c0b4a32c19c63221aad2a25

See more details on using hashes here.

File details

Details for the file ipfs_node-0.1.12rc9-py3-none-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for ipfs_node-0.1.12rc9-py3-none-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 d6930eadd2fdfbc0152d88eb66c4e61c620cb7562bdc3e6df876411c67bc05ab
MD5 c3f0ef0250c5bd7140bcd7042a22ed39
BLAKE2b-256 b4315f450008bdc09252ea7d6513ef0899063cd820c9aa92c9882034014ce609

See more details on using hashes here.

File details

Details for the file ipfs_node-0.1.12rc9-py3-none-macosx_10_9_arm64.whl.

File metadata

File hashes

Hashes for ipfs_node-0.1.12rc9-py3-none-macosx_10_9_arm64.whl
Algorithm Hash digest
SHA256 9e18518cdcf0878033e7b3288b4f6f2c7d47bdd7dacb40b8115f68b7caccb051
MD5 493f8e83c7a54758ae88cab4d709bfb8
BLAKE2b-256 56c3d7a4f87e98ee7246eb28ec9ed5d610d985aa4f53e220ee00bedf8c819454

See more details on using hashes here.

File details

Details for the file ipfs_node-0.1.12rc9-py3-none-android_28_arm64_v8a.whl.

File metadata

File hashes

Hashes for ipfs_node-0.1.12rc9-py3-none-android_28_arm64_v8a.whl
Algorithm Hash digest
SHA256 6cfda34000b96ba8cd02255e71935014a33b6a93aade411faf048ff18c166a12
MD5 ba583a10b4b21a01e413c24de18adac4
BLAKE2b-256 4227049d9f94680b0c41e96cbefa63b13e346034360dea4c60fd55edd71fe9f5

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.12rc9 This release

7 files

0.1.11

2 files

0.1.10

2 files

0.1.9

1 file

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

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