Skip to content

IDX SDK Reference

Installation

npm install @ceramicstudio/idx

IDX class

constructor

Arguments:

  1. options: IDXOptions

.authenticated

Returns whether a DID is currently authenticated.

Returns: boolean

.ceramic

Returns: CeramicApi

.id

Returns the DID of the currently authenticated user.

Accessing this property will throw an error if the instance is not authenticated.

Returns: string

.has()

Returns whether a record exists in the index for a given DID.

Arguments:

  1. name: string (alias or IndexKey)
  2. did?: string = this.id

Returns: Promise<boolean>

.get()

Returns a record in the index for a given DID or Blockchain Account ID .

Arguments:

  1. name: string (alias or IndexKey)
  2. did?: string = this.id

Returns: Promise<unknown>

.set()

Sets or modifies a record in the index of the authenticated DID.

Arguments:

  1. name: string (alias or IndexKey)
  2. content: unknown
  3. options?: CreateOptions (only applied if the record is being created, if it already exists they are ignored)

Returns: Promise<StreamID> the recordID of the created record

.merge()

Performs a shallow (one level) merge to a record in the index of the authenticated DID.

Arguments:

  1. name: string (alias or IndexKey)
  2. content: unknown
  3. options?: CreateOptions (only applied if the record is being created, if it already exists they are ignored)

Returns: Promise<StreamID> the recordID of the created record

.setAll()

Similar to the .set() method but for setting multiple records at once in a more efficient way.

The index will only get updated if all records are successfully set.

Arguments:

  1. contents: Record<string, unknown>
  2. options?: CreateOptions (only applied if the record is being created, if it already exists they are ignored)

Returns: Promise<Record<string, string>> the recordIDs of the created records

.setDefaults()

Similar to the .setAll() method but only sets records for keys that are not already present in the index.

  1. contents: Record<string, unknown>
  2. options?: CreateOptions (only applied if the record is being created, if it already exists they are ignored)

Returns: Promise<Record<string, string>> the recordIDs of the created records

.remove()

Removes a definitionID:recordID pair from the index of the authenticated DID.

Arguments:

  1. name: string (alias or IndexKey)

Returns: Promise<void>

.getIndex()

Returns the index for the given DID.

This method can be used to get the full definitionID:recordID mapping at once

Arguments:

  1. did?: string = this.id

Returns: Promise<Index | null>

.iterator()

Returns an async iterator of Entry for the given DID.

This method can be used to iteratively load all the records in the index

Arguments: å

  1. did?: string = this.id

Returns: AsyncIterableIterator<Entry>

.getDefinition()

Loads a definition.

Arguments:

  1. id: StreamID | IndexKey (StreamID or IndexKey)

Returns: Promise<DefinitionWithID>

getLegacy3BoxProfileAsBasicProfile()

This function is exposed to help projects transition from 3Box to IDX as a temporary solution. It will be removed from IDX in the future.

Returns a BasicProfile object converted from a 3Box profile if existing for the given Ethereum address, or null if unavailable.

Arguments:

  1. address: string: Ethereum address starting with 0x

Returns: Promise<BasicProfile | null>