<commit_before># net-ipfs-api v0.3.11
.NET portable class library (PCL) for the InterPlanetary File System (IPFS) API.

_Currently a work in progress_

This library should be easy to use if you're familiar with the IPFS cli. Top level commands (eg. `ipfs cat`, `ipfs add`) are methods in `IpfsClient`. Subcommands are methods in the IPFS client's properties named after the subcommands.

ie. `ipfs swarm peers` becomes `ipfs.Swarm.Peers()` and `ipfs add <file>` becomes `ipfs.Add("file")`. Easy!

The only exception is if a valid 'top level' command has subcommands, since C# can't have methods and properties with the same name. ie. `ipfs config` and `ipfs config edit` becomes `ipfs.ConfigCommand()` and `ipfs.Config.Edit()`

## Examples
### Disconnect from all peers
    using (var ipfs = new IpfsClient())
    {
        var peers = await ipfs.Swarm.Peers();
        await ipfs.Swarm.Disconnect(peers);
    }

## TODO
* Serialize to types from JSON
* Base58 tests
* MultiHash/Address tests<commit_msg>Added example to README<commit_after># net-ipfs-api v0.3.11 beta
.NET portable class library (PCL) for the InterPlanetary File System (IPFS) API. _Currently a work in progress_

This library should be easy to use if you're familiar with the IPFS CLI. Top level commands (eg. `ipfs cat`, `ipfs add`) are methods in `IpfsClient`. Subcommands are methods in the IPFS client's properties named after the subcommands.

ie. `ipfs swarm peers` becomes `ipfs.Swarm.Peers()` and `ipfs add <file>` becomes `ipfs.Add("file")`. Easy!

The only exception is if a valid 'top level' command has subcommands, since C# can't have methods and properties with the same name. ie. `ipfs config` and `ipfs config edit` becomes `ipfs.ConfigCommand()` and `ipfs.Config.Edit()`.

CLI arguments are method parameters, and options are optional parameters.

## Examples

### Adding & reading a file:

Since net-ipfs-api is a PCL, we have to do our file IO with streams.

    using (var ipfs = new IpfsClient())
    {
      //Name of the file to add
      string fileName = "test.txt";

      using(Stream inputStream = File.OpenRead(fileName))
      {
        //Wrap our stream in an IpfsStream, so it has a file name.
        MerkleNode node = await ipfs.Add(new IpfsStream(fileName, inputStream));

        Stream outputStream = await ipfs.Cat(MerkleNode.Hash);

        using(StreamReader sr = new StreamReader(outputStream));
        {
          string contents = sr.ReadToEnd();

          Console.WriteLine(contents); //Contents of test.txt are printed here!
        }
      }
    }


### Disconnect from all peers:
    using (var ipfs = new IpfsClient())
    {
        var peers = await ipfs.Swarm.Peers();
        await ipfs.Swarm.Disconnect(peers);
    }
{'fraction_non_alphanumeric': 0.09930631617378605, 'fraction_numerical': 0.0036509675063891934, 'mean_word_length': 3.405144694533762, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '695967', 'n_tokens_mistral': 839, 'n_tokens_neox': 814, 'n_words': 336}