IpfsApi

@interface IpfsApi : NodeDependant

Provides access to Textile IPFS related APIs

  • Fetch the IPFS peer id

    Declaration

    Objective-C

    - (nonnull NSString *)peerId:(NSError *_Nullable *_Nullable)error;

    Swift

    func peerId(_ error: NSErrorPointer) -> String

    Parameters

    error

    A reference to an error pointer that will be set in the case of an error

    Return Value

    The IPFS peer id of the local Textile node

  • Open a new direct connection to a peer using an IPFS multiaddr

    Declaration

    Objective-C

    - (BOOL)swarmConnect:(nonnull NSString *)multiaddr
                   error:(NSError *_Nullable *_Nullable)error;

    Swift

    func swarmConnect(_ multiaddr: String) throws

    Parameters

    multiaddr

    Peer IPFS multiaddr

    error

    A reference to an error pointer that will be set in the case of an error

    Return Value

    Whether the peer swarm connect was successfull

  • Get raw data stored at an IPFS path

    Declaration

    Objective-C

    - (void)dataAtPath:(nonnull NSString *)path
            completion:(nonnull void (^)(NSData *_Nullable, NSString *_Nullable,
                                         NSError *_Nonnull))completion;

    Swift

    func data(atPath path: String, completion: @escaping (Data?, String?, Error) -> Void)

    Parameters

    path

    The IPFS path for the data you want to retrieve

    completion

    A block that will get called with the results of the query

  • Publishes a message to a given pubsub topic

    Declaration

    Objective-C

    - (void)pubsubPub:(nonnull NSString *)topic
                 data:(nonnull NSString *)data
                error:(NSError *_Nullable *_Nullable)error;

    Swift

    func pubsubPub(_ topic: String, data: String, error: NSErrorPointer)

    Parameters

    topic

    The topic to publish to

    data

    The payload of message to publish

    error

    A reference to an error pointer that will be set in the case of an error

  • Subscribes to messages on a given topic

    Declaration

    Objective-C

    - (nonnull NSString *)pubsubSub:(nonnull NSString *)topic
                              error:(NSError *_Nullable *_Nullable)error;

    Swift

    func pubsubSub(_ topic: String, error: NSErrorPointer) -> String

    Parameters

    topic

    The ipfs pubsub sub topic

    error

    A reference to an error pointer that will be set in the case of an error

    Return Value

    A query ID that can be used to cancel the sub

  • Cancel subscribe to messages on a given topic

    Declaration

    Objective-C

    - (void)cancelPubsubSub:(nonnull NSString *)queryId;

    Swift

    func cancelPubsubSub(_ queryId: String)

    Parameters

    queryId

    The query ID that can be used to cancel the sub