apex/ipfs-api

A minimal implementation of IPFS API

0.1 2022-02-21 07:52 UTC

This package is auto-updated.

Last update: 2024-04-21 12:32:22 UTC


README

Installation

You can install the package via composer:

composer require openwse/ipfs-api

Usage

$client = new Ipfs\Ipfs(
    new Ipfs\Drivers\HttpClient('https://ipfs-host', 5001)
);

// add a single file (and pin it)
$client->add('/path/to/the/file', true);

// add a file from content
$client->add([
    ['/desired-path-on-ipfs/filename.txt', null, 'my text content', 'text/plain']
]);

// add a nested structure
$client->add([
    ['/path/to/local/file', '/path/on/ipfs'],
    'my-custom-dir',
    ['/path/to/local/file', '/my-custom-dir/filename'],
]);

// list all files
$client->files()->ls();

// get the version
$client->version();

// publish
$client->key()->gen('mykeyname');
$client->name()->publish('/path/hash', '48h', 'mykeyname');


// some other examples...
$client->cat('/path/hash');

$client->config()->set('key', 'value');

$client->pin()->add('/path/hash');

$client->pin()->verify();

$client->stats()->bw();

$client->key()->rm('mykeyname');

Lint

Run PHPMD, PHPStan, and PHP-CS-Fixer

composer lint

Testing

composer tests

TODOS:

  • Complete async/streams requests
  • Implement the following endpoints:
    • P2P
    • Pubsub (with name/pubsub/{cancel,state,subs})
  • Missing tests:
    • Block > put
    • Filestore
    • Dht

License

The MIT License (MIT). Please see License File for more information.