Ipfs class

IPFS HTTP RPC service implementation.

This is a singleton class, and the instance is initialized with it's url attribute set to "http://127.0.0.1:5001/api/v0". It can be changed directly or by calling the factory constructor.

Responses are like the following:

{
  // Allways present (assuming successful connection or no
  // Dio-related problems).
  "StatusCode": "<statusCode>",
  "StatusMessage": "<statusMessage>",

  // If 'text/plain' response is expected, i.e. ipfs cat
  // (see: https://docs.ipfs.io/reference/http/api/#api-v0-cat)
  "Text": "<response.data>",

  // Otherwise, insert response.data contiguously if the
  // response body is "map-like" (see examples below).
  "<response.data key>": "<response.data value>",
  "...",

  // Sometimes, IPFS returns a list of objects (without a
  // given key). This is stored in "Data" as follows (see examples below):
  "Data": ["..."]
}

Examples:

  • ipfs files ls returns an object with "Entries" key. Append returned keys to the response:
print( await ipfs.files.ls() );
// {
//   StatusCode: 200,
//   StatusMessage: OK,
//   Entries: [...],
// }
  • ipfs cid bases returns a list object. Add list to a key named "Data" in the response:
print( await ipfs.cid.bases() );
// {
//   StatusCode: 200,
//   StatusMessage: OK,
//   Data: [
//       {Code: 109, Name: base64}, ...
//   ],
// }

Constructors

Ipfs({String? url})
Get the global instance of this class.
factory

Properties

bitswap IpfsBitswapCommand
Interact with the bitswap agent.
final
block IpfsBlockCommand
Interact with raw IPFS blocks.
final
bootstrap IpfsBootstrapCommand
Show or edit the list of bootstrap peers.
final
cid IpfsCidCommand
Convert and discover properties of CIDs.
final
commands IpfsCommandsCommand
List all available commands.
final
config IpfsConfigCommand
Get and set IPFS config values. 'ipfs config' controls configuration variables. It works much like 'git config'. The configuration values are stored in a config file inside your IPFS repository (IPFS_PATH).
final
dag IpfsDagCommand
Interact with IPLD DAG objects.
final
dht IpfsDhtCommand
Issue commands directly through the DHT.
final
diag IpfsDiagCommand
Generate diagnostic reports.
final
files IpfsFilesCommand
Files is an API for manipulating IPFS objects as if they were a Unix filesystem.
final
filestore IpfsFilestoreCommand
Interact with filestore objects.
final
hashCode int
The hash code for this object.
no setterinherited
key IpfsKeyCommand
Create and list IPNS name keypairs
final
log IpfsLogCommand
Interact with the daemon log output.
final
multibase IpfsMultibaseCommand
Encode and decode files or stdin with multibase format
final
name IpfsNameCommand
Publish and resolve IPNS names.
final
pin IpfsPinCommand
Pin (and unpin) objects to local storage, remote or remote services.
final
refs IpfsRefsCommand
List links (references) from an object.
final
repo IpfsRepoCommand
Manipulate the IPFS repo.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stats IpfsStatsCommand
Interact with the swarm. Query IPFS statistics.
final
swarm IpfsSwarmCommand
'ipfs swarm' is a tool to manipulate the network swarm. The swarm is the component that opens, listens for, and maintains connections to other ipfs peers in the internet.
final
version IpfsVersionCommand
Show IPFS version information.
final

Methods

add({required String path, String? ipfsPath, bool? quiet, bool? quieter, bool? silent, bool? progress, bool? trickle, bool? onlyHash, bool? wrapWithDirectory, String? chunker, bool? pin, bool? rawLeaves, int? cidVersion}) Future<Map<String, dynamic>>
Add a file or directory to IPFS. /api/v0/add
cat({required String path, int? offset, int? length, bool? progress}) Future<Map<String, dynamic>>
Show IPFS object data. /api/v0/cat
get({required String path, String? output, bool? archive, bool? compress, int? compressionLevel, bool? progress}) Future<Map<String, dynamic>>
Download IPFS objects. /api/v0/get
id({String? peerId, String? format, String? peerIdBase}) Future<Map<String, dynamic>>
Show IPFS node id info. /api/v0/id
ls({required String path, bool? headers, bool? resolveType, bool? size, bool? stream}) Future<Map<String, dynamic>>
List directory contents for Unix filesystem objects. /api/v0/ls
mount({String? ipfsPath, String? ipnsPath}) Future<Map<String, dynamic>>
EXPERIMENTAL
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
ping({required String peerId, int? count}) Future<Map<String, dynamic>>
Send echo request packets to IPFS hosts. /api/v0/ping
resolve({required String path, bool? recursive, int? dhtRecordCount, String? dhtTimeout}) Future<Map<String, dynamic>>
Resolve the value of names to IPFS or DAG path. /api/v0/resolve
shutdown() Future<Map<String, dynamic>>
Shut down the IPFS daemon. /api/v0/shutdown
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

dio → Dio
final
url String
getter/setter pair