Skip to main content

TypeScript API Reference

SolVec

new SolVec(options: SolVecConfig)
interface SolVecConfig {
  network: "mainnet-beta" | "devnet" | "localnet";
  walletPath?: string;
  rpcUrl?: string;
  shadowDrive?: boolean;
}

sv.collection(name)

Returns a Collection instance.
const index = sv.collection("my-index");

index.upsert(vectors)

await index.upsert([
  {
    id:        string,
    values:    number[],
    metadata?: object
  }
])

index.query(options)

const results = await index.query({
  vector:  number[],
  topK:    number,
  filter?: object
})
Returns: Array<{ id: string, score: number, metadata?: object }>

index.verify()

const proof = await index.verify();
// proof.merkleRoot        - 32-byte hex string
// proof.txSignature       - transaction signature
// proof.solanaExplorerUrl - explorer URL

index.restoreFromShadowDrive()

async restoreFromShadowDrive(): Promise<boolean>
// Returns true if restored, false if no backup found