Show / Hide Table of Contents

Class IpfsClient

A client that allows access to the InterPlanetary File System (IPFS).

Inheritance
Object
IpfsClient
Implements
IGenericApi
ICoreApi
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: Ipfs.Http
Assembly: Ipfs.Http.Client.dll
Syntax
public class IpfsClient : IGenericApi, ICoreApi
Remarks

The API is based on the IPFS commands.

Constructors

| Improve this Doc View Source

IpfsClient()

Creates a new instance of the IpfsClient class and sets the default values.

Declaration
public IpfsClient()
Remarks

All methods of IpfsClient are thread safe. Typically, only one instance is required for an application.

| Improve this Doc View Source

IpfsClient(String)

Creates a new instance of the IpfsClient class and specifies the ApiUri. default values

Declaration
public IpfsClient(string host)
Parameters
Type Name Description
String host

The URL of the API host. For example "http://localhost:5001" or "http://ipv4.fiddler:5001".

Fields

| Improve this Doc View Source

DefaultApiUri

The default URL to the IPFS HTTP API server.

Declaration
public static Uri DefaultApiUri
Field Value
Type Description
Uri

The default is "http://localhost:5001".

Remarks

The environment variable "IpfsHttpApi" overrides this value.

Properties

| Improve this Doc View Source

ApiUri

The URL to the IPFS API server. The default is "http://localhost:5001".

Declaration
public Uri ApiUri { get; set; }
Property Value
Type Description
Uri
| Improve this Doc View Source

Bitswap

Declaration
public IBitswapApi Bitswap { get; }
Property Value
Type Description
IBitswapApi
| Improve this Doc View Source

Block

Declaration
public IBlockApi Block { get; }
Property Value
Type Description
IBlockApi
| Improve this Doc View Source

BlockRepository

Declaration
public IBlockRepositoryApi BlockRepository { get; }
Property Value
Type Description
IBlockRepositoryApi
| Improve this Doc View Source

Bootstrap

Declaration
public IBootstrapApi Bootstrap { get; }
Property Value
Type Description
IBootstrapApi
| Improve this Doc View Source

Config

Declaration
public IConfigApi Config { get; }
Property Value
Type Description
IConfigApi
| Improve this Doc View Source

Dag

Declaration
public IDagApi Dag { get; }
Property Value
Type Description
IDagApi
| Improve this Doc View Source

Dht

Declaration
public IDhtApi Dht { get; }
Property Value
Type Description
IDhtApi
| Improve this Doc View Source

Dns

Declaration
public IDnsApi Dns { get; }
Property Value
Type Description
IDnsApi
| Improve this Doc View Source

FileSystem

Declaration
public IFileSystemApi FileSystem { get; }
Property Value
Type Description
IFileSystemApi
| Improve this Doc View Source

Generic

Declaration
public IGenericApi Generic { get; }
Property Value
Type Description
IGenericApi
| Improve this Doc View Source

Key

Declaration
public IKeyApi Key { get; }
Property Value
Type Description
IKeyApi
| Improve this Doc View Source

Name

Declaration
public INameApi Name { get; }
Property Value
Type Description
INameApi
| Improve this Doc View Source

Object

Declaration
public IObjectApi Object { get; }
Property Value
Type Description
IObjectApi
| Improve this Doc View Source

Pin

Declaration
public IPinApi Pin { get; }
Property Value
Type Description
IPinApi
| Improve this Doc View Source

PubSub

Declaration
public IPubSubApi PubSub { get; }
Property Value
Type Description
IPubSubApi
| Improve this Doc View Source

Stats

Declaration
public IStatsApi Stats { get; }
Property Value
Type Description
IStatsApi
| Improve this Doc View Source

Swarm

Declaration
public ISwarmApi Swarm { get; }
Property Value
Type Description
ISwarmApi
| Improve this Doc View Source

TrustedPeers

The list of peers that are initially trusted by IPFS.

Declaration
public TrustedPeerCollection TrustedPeers { get; }
Property Value
Type Description
TrustedPeerCollection
Remarks

This is equilivent to ipfs bootstrap list.

| Improve this Doc View Source

UserAgent

The value of HTTP User-Agent header sent to the API server.

Declaration
public string UserAgent { get; set; }
Property Value
Type Description
String

The default value is "net-ipfs/M.N", where M is the major and N is minor version numbers of the assembly.

Methods

| Improve this Doc View Source

DoCommandAsync(String, CancellationToken, String, String[])

Perform an IPFS API command returning a string.

Declaration
public Task<string> DoCommandAsync(string command, CancellationToken cancel, string arg = null, params string[] options)
Parameters
Type Name Description
String command

The IPFS API command, such as "file/ls".

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

String arg

The optional argument to the command.

String[] options

The optional flags to the command.

Returns
Type Description
Task<String>

A string representation of the command's result.

Exceptions
Type Condition
HttpRequestException

When the IPFS server indicates an error.

| Improve this Doc View Source

DoCommandAsync<T>(String, CancellationToken, String, String[])

Perform an IPFS API command returning a specific Type.

Declaration
public Task<T> DoCommandAsync<T>(string command, CancellationToken cancel, string arg = null, params string[] options)
Parameters
Type Name Description
String command

The IPFS API command, such as "file/ls".

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

String arg

The optional argument to the command.

String[] options

The optional flags to the command.

Returns
Type Description
Task<T>

A T.

Type Parameters
Name Description
T

The Type of object to return.

Remarks

The command's response is converted to T using JsonConvert.

Exceptions
Type Condition
HttpRequestException

When the IPFS server indicates an error.

| Improve this Doc View Source

DownloadAsync(String, CancellationToken, String, String[])

Perform an IPFS API command returning a Stream.

Declaration
public Task<Stream> DownloadAsync(string command, CancellationToken cancel, string arg = null, params string[] options)
Parameters
Type Name Description
String command

The IPFS API command, such as "file/ls".

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

String arg

The optional argument to the command.

String[] options

The optional flags to the command.

Returns
Type Description
Task<Stream>

A Stream containing the command's result.

Exceptions
Type Condition
HttpRequestException

When the IPFS server indicates an error.

| Improve this Doc View Source

DownloadBytesAsync(String, CancellationToken, String, String[])

Perform an IPFS API command returning a a byte array.

Declaration
public Task<byte[]> DownloadBytesAsync(string command, CancellationToken cancel, string arg = null, params string[] options)
Parameters
Type Name Description
String command

The IPFS API command, such as "file/ls".

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

String arg

The optional argument to the command.

String[] options

The optional flags to the command.

Returns
Type Description
Task<Byte[]>

A byte array containing the command's result.

Exceptions
Type Condition
HttpRequestException

When the IPFS server indicates an error.

| Improve this Doc View Source

IdAsync(MultiHash, CancellationToken)

Declaration
public Task<Peer> IdAsync(MultiHash peer = null, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
MultiHash peer
CancellationToken cancel
Returns
Type Description
Task<Peer>
| Improve this Doc View Source

PingAsync(MultiAddress, Int32, CancellationToken)

Declaration
public Task<IEnumerable<PingResult>> PingAsync(MultiAddress address, int count = 10, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
MultiAddress address
Int32 count
CancellationToken cancel
Returns
Type Description
Task<IEnumerable<PingResult>>
| Improve this Doc View Source

PingAsync(MultiHash, Int32, CancellationToken)

Declaration
public Task<IEnumerable<PingResult>> PingAsync(MultiHash peer, int count = 10, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
MultiHash peer
Int32 count
CancellationToken cancel
Returns
Type Description
Task<IEnumerable<PingResult>>
| Improve this Doc View Source

PostDownloadAsync(String, CancellationToken, String, String[])

Post an IPFS API command returning a stream.

Declaration
public Task<Stream> PostDownloadAsync(string command, CancellationToken cancel, string arg = null, params string[] options)
Parameters
Type Name Description
String command

The IPFS API command, such as "file/ls".

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

String arg

The optional argument to the command.

String[] options

The optional flags to the command.

Returns
Type Description
Task<Stream>

A Stream containing the command's result.

Exceptions
Type Condition
HttpRequestException

When the IPFS server indicates an error.

| Improve this Doc View Source

ResolveAsync(String, Boolean, CancellationToken)

Declaration
public Task<string> ResolveAsync(string name, bool recursive = true, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
String name
Boolean recursive
CancellationToken cancel
Returns
Type Description
Task<String>
| Improve this Doc View Source

ShutdownAsync()

Declaration
public Task ShutdownAsync()
Returns
Type Description
Task
| Improve this Doc View Source

Upload2Async(String, CancellationToken, Stream, String, String[])

Perform an IPFS API command that requires uploading of a "file".

Declaration
public Task<Stream> Upload2Async(string command, CancellationToken cancel, Stream data, string name, params string[] options)
Parameters
Type Name Description
String command

The IPFS API command, such as "add".

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Stream data

A Stream containing the data to upload.

String name

The name associated with the data, can be null. Typically a filename, such as "hello.txt".

String[] options

The optional flags to the command.

Returns
Type Description
Task<Stream>

A task that represents the asynchronous operation. The task's value is the HTTP response as a Stream.

Exceptions
Type Condition
HttpRequestException

When the IPFS server indicates an error.

| Improve this Doc View Source

UploadAsync(String, CancellationToken, Byte[], String[])

TODO

Declaration
public Task<string> UploadAsync(string command, CancellationToken cancel, byte[] data, params string[] options)
Parameters
Type Name Description
String command
CancellationToken cancel
Byte[] data
String[] options
Returns
Type Description
Task<String>
| Improve this Doc View Source

UploadAsync(String, CancellationToken, Stream, String, String[])

Perform an IPFS API command that requires uploading of a "file".

Declaration
public Task<string> UploadAsync(string command, CancellationToken cancel, Stream data, string name, params string[] options)
Parameters
Type Name Description
String command

The IPFS API command, such as "add".

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Stream data

A Stream containing the data to upload.

String name

The name associated with the data, can be null. Typically a filename, such as "hello.txt".

String[] options

The optional flags to the command.

Returns
Type Description
Task<String>

A task that represents the asynchronous operation. The task's value is the HTTP response as a string.

Exceptions
Type Condition
HttpRequestException

When the IPFS server indicates an error.

| Improve this Doc View Source

VersionAsync(CancellationToken)

Declaration
public Task<Dictionary<string, string>> VersionAsync(CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
CancellationToken cancel
Returns
Type Description
Task<Dictionary<String, String>>

Implements

IGenericApi
ICoreApi

See Also

IPFS API
IPFS commands
  • Improve this Doc
  • View Source
Back to top Generated by DocFX