Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface API<OptionExtension>

Type parameters

  • OptionExtension = {}

Hierarchy

  • API

Index

Methods

  • export(root: CID, options?: ExportOptions & OptionExtension): AsyncIterable<Uint8Array>
  • Exports a CAR for the entire DAG available from the given root CID. The CAR will have a single root and IPFS will attempt to fetch and bundle all blocks that are linked within the connected DAG.

    Parameters

    Returns AsyncIterable<Uint8Array>

  • Retrieve an IPLD format node

    example
    // example obj
    const obj = {
    a: 1,
    b: [1, 2, 3],
    c: {
    ca: [5, 6, 7],
    cb: 'foo'
    }
    }

    const cid = await ipfs.dag.put(obj, { storeCodec: 'dag-cbor', hashAlg: 'sha2-256' })
    console.log(cid.toString())
    // zdpuAmtur968yprkhG9N5Zxn6MFVoqAWBbhUAkNLJs2UtkTq5

    async function getAndLog(cid, path) {
    const result = await ipfs.dag.get(cid, { path })
    console.log(result.value)
    }

    await getAndLog(cid, '/a')
    // Logs:
    // 1

    await getAndLog(cid, '/b')
    // Logs:
    // [1, 2, 3]

    await getAndLog(cid, '/c')
    // Logs:
    // {
    // ca: [5, 6, 7],
    // cb: 'foo'
    // }

    await getAndLog(cid, '/c/ca/1')
    // Logs:
    // 6

    Parameters

    • cid: CID
    • Optional options: GetOptions & OptionExtension

    Returns Promise<GetResult>

  • import(sources: Iterable<Uint8Array> | AsyncIterable<Uint8Array> | AsyncIterable<AsyncIterable<Uint8Array>> | Iterable<AsyncIterable<Uint8Array>>, options?: ImportOptions & OptionExtension): AsyncIterable<ImportResult>
  • Import all blocks from one or more CARs and optionally recursively pin the roots identified within the CARs.

    Parameters

    • sources: Iterable<Uint8Array> | AsyncIterable<Uint8Array> | AsyncIterable<AsyncIterable<Uint8Array>> | Iterable<AsyncIterable<Uint8Array>>
    • Optional options: ImportOptions & OptionExtension

    Returns AsyncIterable<ImportResult>

  • put(node: any, options?: PutOptions & OptionExtension): Promise<CID>
  • Store an IPLD format node

    example
    const obj = { simple: 'object' }
    const cid = await ipfs.dag.put(obj, { storeCodec: 'dag-cbor', hashAlg: 'sha2-512' })

    console.log(cid.toString())
    // zBwWX9ecx5F4X54WAjmFLErnBT6ByfNxStr5ovowTL7AhaUR98RWvXPS1V3HqV1qs3r5Ec5ocv7eCdbqYQREXNUfYNuKG

    Parameters

    • node: any
    • Optional options: PutOptions & OptionExtension

    Returns Promise<CID>

  • Returns the CID and remaining path of the node at the end of the passed IPFS path

    example
    // example obj
    const obj = {
    a: 1,
    b: [1, 2, 3],
    c: {
    ca: [5, 6, 7],
    cb: 'foo'
    }
    }

    const cid = await ipfs.dag.put(obj, { storeCodec: 'dag-cbor', hashAlg: 'sha2-256' })
    console.log(cid.toString())
    // bafyreicyer3d34cutdzlsbe2nqu5ye62mesuhwkcnl2ypdwpccrsecfmjq

    const result = await ipfs.dag.resolve(`${cid}/c/cb`)
    console.log(result)
    // Logs:
    // {
    // cid: CID(bafyreicyer3d34cutdzlsbe2nqu5ye62mesuhwkcnl2ypdwpccrsecfmjq),
    // remainderPath: 'c/cb'
    // }

    Parameters

    Returns Promise<ResolveResult>

Generated using TypeDoc