#ipfs #api #p2p

ipfsapi

Crate for interfacing with the IPFS api

13 releases

Uses new Rust 2021

0.4.0 Oct 1, 2022
0.3.0 Aug 4, 2019
0.2.2 May 11, 2018
0.2.1 Mar 12, 2018
0.1.5 Oct 18, 2017

#1440 in Network programming

Download history 52/week @ 2022-10-05 14/week @ 2022-10-12 8/week @ 2022-10-19 36/week @ 2022-10-26 43/week @ 2022-11-02 28/week @ 2022-11-09 37/week @ 2022-11-16 15/week @ 2022-11-23 16/week @ 2022-11-30 50/week @ 2022-12-07 16/week @ 2022-12-14 31/week @ 2022-12-21 21/week @ 2022-12-28 1/week @ 2023-01-04 22/week @ 2023-01-11 13/week @ 2023-01-18

58 downloads per month

MIT license

23KB
490 lines

Rust IPFS API Client

Crates.io Docs.rs

A client library for the IPFS API.

This library allows you to use the local IPFS daemon from Rust.

Usage

[dependencies]
ipfsapi = "0.4"

Examples

Reading a file from IPFS

Here's an example that gets the contents of a file from IPFS and displays it.

let api = IpfsApi::new("127.0.0.1", 5001);

let bytes = api.cat("QmWATWQ7fVPP2EFGu71UkfnqhYXDYH566qy47CnJDgvs8u").unwrap();
let data = String::from_utf8(bytes.collect()).unwrap();

println!("{}", data);

The code gets the content of the IPFS hash and displays "Hello World".

Subsribing to messages on IPFS Pubsub

let api = IpfsApi::new("127.0.0.1", 5001);

let messages = api.pubsub_subscribe("chat").unwrap();

for message in messages {
    println!("{:?}", message);
}

Implemented Functionality

  • Getting file contents from IPFS (cat)
  • Pubsub
  • IPNS publish and resolve
  • Object/Hash stats (size, etc.)
  • Version information of the daemon
  • Pinning and unpinning files
  • Shut down IPFS daemon
  • Get and put blocks

Dependencies

~3MB
~86K SLoC