Accessing IPFS
IPFS is a distributed peer to peer system. There is no central server! Typically, each machine (peer) runs a daemon that communicates with other peers.
The IpfsClient provides a simple way for your program to access the daemon via the IPFS HTTP API protocol. The client should be used as a shared object in your program, much like HttpClient. It is thread safe (re-entrant) and conserves sockets and TCP connections when only one instance is used.
public class Program
{
static readonly IpfsClient ipfs = new IpfsClient();
public async Task Main(string[] args)
{
// Get the Peer info of the daemon
var peer = await ipfs.IdAsync();
}
}
Core API
The Core API is a set of interfaces to IPFS features and is implemented by the client. The FileSystem and PubSub features are most often used.
const string filename = "QmXarR6rgkQ2fDSHjSY5nM2kuCXKYGViky5nohtwgF65Ec/about";
string text = await ipfs.FileSystem.ReadAllTextAsync(filename);
Features
Feature | Purpose |
---|---|
Bitswap | Data trading module for IPFS; requests blocks from and sends blocks to other peers |
Block | Manages the blocks |
BlockRepository | Manages the repository of blocks |
Bootstrap | Trusted peers |
Config | Manages the configuration of the local peer |
Dag | Manages the IPLD (linked data) Directed Acrylic Graph |
Dht | Manages the Distributed Hash Table |
Dns | DNS mapping to IPFS |
Misc | Some miscellaneous methods |
FileSystem | Manages the files/directories in IPFS |
Key | Manages the cryptographic keys |
Name | Manages the Interplanetary Name Space (IPNS) |
Object | Manages the IPFS Directed Acrylic Graph |
Pin | Manage objects that are locally stored and permanent |
PubSub | Publish and subscribe to topic messages |
Swarm | Get statistics on IPFS components |
Swarm | Manages the swarm of peers |