Options
All
  • Public
  • Public/Protected
  • All
Menu

Class IPFS

IPFS is an API module for working with an underlying IPFS peer

extends

API

Hierarchy

  • API
    • IPFS

Index

Constructors

constructor

Methods

cat

  • cat(path: string, key?: undefined | string): Promise<Blob>
  • Retrieves the data behind an IPFS CID path

    Parameters

    • path: string

      IPFS/IPNS CID path

    • Optional key: undefined | string

      Key to decrypt the underlying data on-the-fly

    Returns Promise<Blob>

    The underlying data behind the given IPFS CID path

connect

  • connect(addr: string): Promise<boolean>
  • Opens a new direct connection to a peer using an IPFS multiaddr

    Parameters

    • addr: string

      Peer IPFS multiaddr

    Returns Promise<boolean>

    Whether the peer swarm connect was successfull

id

  • id(): Promise<string>
  • Retrieves underlying IPFS peer ID

    Returns Promise<string>

    The underlying IPFS peer ID

peers

  • peers(verbose?: undefined | false | true, latency?: undefined | false | true, streams?: undefined | false | true, direction?: undefined | false | true): Promise<any>
  • Lists the set of peers to which this node is connected

    Parameters

    • Optional verbose: undefined | false | true

      Display all extra information

    • Optional latency: undefined | false | true

      Also list information about latency to each peer

    • Optional streams: undefined | false | true

      Also list information about open streams for each peer

    • Optional direction: undefined | false | true

      Also list information about the direction of connection

    Returns Promise<any>

pubsubPub

  • pubsubPub(topic: string, data: string | object): Promise<boolean>
  • Publishes a message to a given pubsub topic

    Parameters

    • topic: string

      The topic to publish to

    • data: string | object

      The payload of message to publish

    Returns Promise<boolean>

    Whether the publish was successfull

pubsubSub

  • pubsubSub(topic: string, useEventSource?: undefined | false | true): Promise<object>
  • Subscribes to messages on a given topic with EventSource or GET

    Parameters

    • topic: string

      The ipfs pubsub sub topic

    • Optional useEventSource: undefined | false | true

      Whether to use EventSource or GET

    Returns Promise<object>

    An object with queryId and EventSource or a ReadableStream of ArrayBuffer

pubsubSubGet

  • pubsubSubGet(topic: string, queryId: string): Promise<ReadableStream<ArrayBuffer>>
  • Subscribes to messages on a given topic with GET

    Parameters

    • topic: string

      The ipfs pubsub sub topic

    • queryId: string

    Returns Promise<ReadableStream<ArrayBuffer>>

    A ReadableStream of ArrayBuffer