Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here

swift-ipfs-api

A Swift client library for the IPFS API.

Subscribe to updates I use swift-ipfs-api


Statistics on swift-ipfs-api

Number of watchers on Github 81
Number of open issues 0
Average time to close an issue 2 days
Main language Swift
Average time to merge a PR 5 days
Open pull requests 0+
Closed pull requests 0+
Last commit over 1 year ago
Repo Created about 4 years ago
Repo Last Updated over 1 year ago
Size 148 KB
Organization / Authoripfs
Contributors1
Page Updated
Do you use swift-ipfs-api? Leave a review!
View swift-ipfs-api activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating swift-ipfs-api for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

swift-ipfs-api

standard-readme compliant

A Swift client library for the IPFS API.

For more information about IPFS or the API commands click the links.

The Swift IPFS API shell/client is an asynchronous library that provides native calls to an IPFS node.

Table of Contents

Install

In the root of your project:

  • Add a Cartfile (or use an existing one) with the following: github "ipfs/swift-ipfs-api" "master"
  • To fetch and build the dependencies, type:

carthage update --platform Mac

or

carthage update --platform iOS

or

carthage update

if you want both platforms.

For more information on how to install via Carthage see the README

Usage

Add the required frameworks to your project in Xcode:

  • In your target's build phases tab.

  • Click the + in the upper left corner and pick the New Copy Files Phase from the drop-down.

  • Select the Destination Frameworks and click the + to Add Other... buttons.

  • Navigate to the Carthage/Build/Mac directory in your project root and select all the frameworks in the folder.

Examples

In your code:

import SwiftIpfsApi

/// For brevity we are not catching failed try's. You should.
let api = try! SwiftIpfsApi("127.0.0.1", "5001") 

try! api.id() {
    (idData : JsonType) in

    print("Yay, I've got an id: "+ idData.object?["ID"]?.string)
}

The Swift IPFS API client is asynchronous, but if you want to use a command synchronously (eg. if you run it in its own thread) you can always use dispatch groups:

let group = dispatch_group_create()
dispatch_group_enter(group)

let multihash = try! fromB58String("QmXsnbVWHNnLk3QGfzGCMy1J9GReWN7crPvY1DKmFdyypK") 

try! api.refs(multihash, recursive: false) {
    result in
    for mh in result {
        print(b58String(mh))
    }

    dispatch_group_leave(group)
}

dispatch_group_wait(group, DISPATCH_TIME_FOREVER)

Requirements

Swift 3

Contribute

Feel free to join in. All welcome. Open an issue!

This repository falls under the IPFS Code of Conduct.

License

MIT

swift-ipfs-api list of languages used
Other projects in Swift