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.12rc7-py3-none-win_amd64.whl (24.6 MB view details)

Uploaded Python 3Windows x86-64

ipfs_node-0.1.12rc7-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.12rc7-py3-none-manylinux_2_17_aarch64.whl (32.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 10.9+ x86-64

ipfs_node-0.1.12rc7-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.12rc7-py3-none-macosx_10_9_arm64.whl (27.6 MB view details)

Uploaded Python 3macOS 10.9+ ARM64

ipfs_node-0.1.12rc7-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.12rc7-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for ipfs_node-0.1.12rc7-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 b9c864f8435a61173d476fa58d01c418a8eff56e37e737c0895b8b826d0130cb
MD5 70ef7d250d5dcf9de57df675ec76961f
BLAKE2b-256 72e08e178f28c16a3858aea53d67cc3e854898de63170e4299e521074c7fbdcb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ipfs_node-0.1.12rc7-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 d7b22f995f1368c8656fe8cbe1345c249b8906bdebff18da5ba47d3362409c05
MD5 c5680c4817dea192d289d0a67a17444f
BLAKE2b-256 7f7a5de70f260c18391983a8f2ea666d93c54203a887565f429fba04892b12ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ipfs_node-0.1.12rc7-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 10d728414b493ad25443dbb60b415ee870a44adbb8f1d69322f7e5d10b64ab1d
MD5 980e56b8b8f90694ad3847ec2dd00c62
BLAKE2b-256 1389dabc6208166c9b404fe0cb85b0939a2bf33f4fee652002638995db69d612

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ipfs_node-0.1.12rc7-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f61452ac1f5d0762b5ffebf911cabb3eaa97b921a951a723e6154909e816cd79
MD5 57dc6e610036431a977f81492429751b
BLAKE2b-256 1168d6eb726fd19416f018bbe30cafef7333d72ba7eec129823773b5d5095112

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ipfs_node-0.1.12rc7-py3-none-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 3564ea62e27daaed2d0a1d0914f86135482fcd435422367805cc15df0db6423c
MD5 fb5cec871da3a55fdf2f3d614e462f1f
BLAKE2b-256 066479875a86998dfeda075cfd594f8ad6e1cd5eed5818445ee7fd7a25e710d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ipfs_node-0.1.12rc7-py3-none-macosx_10_9_arm64.whl
Algorithm Hash digest
SHA256 abd6afabfd4a35584a7663e678aac3300ec03e28bd4ec1a9c34ee900e751c6e3
MD5 247806bb80ce9878a65868f8dfdaa327
BLAKE2b-256 6a97e8c38dabdee1f1ef7f27f1dc2f5b23dccf20d09cc804f4df8c67615a1057

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ipfs_node-0.1.12rc7-py3-none-android_28_arm64_v8a.whl
Algorithm Hash digest
SHA256 4d6871be510820c333997672d8fba4024c3b9d11bd772f18d6b2d1222cb4184b
MD5 a334839f37f0aee23558ed31aadf0b35
BLAKE2b-256 f7ae5792a75e3728f156e67804bbaee2ec1b304876d031a4c3e24506c5bef828

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.12rc7 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