0.0.10 • Published 14 days ago

@indexnetwork/sdk v0.0.10

Weekly downloads
-
License
-
Repository
-
Last release
14 days ago

Quick start

Index Network API allows you to interact with our platform and build products leveraging our services. Below, you will find detailed information about the available endpoints, their purposes, and how to use them.

You can either use the API directly or the client available. Here is a quick start to discover it.

Using Index Client SDK

The Index Network offers an SDK to facilitate various operations on our platform. In this example, we'll demonstrate how to authenticate, create an Index, and add an Item to it.

Index is a fundamental component of the Index Network, designed to facilitate context management and enable semantic interoperability within your system. It serves as a structured way to organize and store data related to specific contexts.

Item represents a graph node within an Index. It provides a standardized approach to representing and managing various types of data.

First, install the index-client via your preferred package manager:

yarn add @indexnetwork/sdk

Next, import it in your project:

import IndexClient from "@indexnetwork/sdk";

Create an instance of IndexClient:

const indexClient = new IndexClient({
  privateKey: "0xc45...a5",
  domain: "index.network",
  network: "ethereum", // provide your network
});

For authentication, you need a DIDSession. You can either sign in using a wallet or pass an existing session. Check Authentication for details explanation on how to initiate a session.

indexClient.authenticate();

We're almost ready. Now, let's create an Index, with a title.

const indexId = await indexClient.createIndex({
  title: "Future of publishing",
});

Voilà, now you have a truly decentralized index to interact with! Though it's empty, which means we need to create and add an Item into it so we can interact. Let's do that.

const webPageId = await indexClient.createWebPage({
  title: "Post medium publishing",
  url: "http://www.paulgraham.com/publishing.html",
});

await indexClient.addIndexItem(indexId, webPageId);

Your index is now ready for interaction! Querying the index is straightforward:

const queryResponse = await indexClient.query({
  query: "summarize",
  indexes: [indexId], // you can add all the indexes of a user as well
});

console.log("Query response:", queryResponse);

The response should look something like this:

{
  "response": "This article discusses the intricacies and challenges of publishing ... strategies for successful online publishing."
  "sources": [
    {
      "itemId": "kjzl6kcy...ii7z1anybovo",
      "indexId": "rt38xm13...b2ca76w5ky27",
    }
  ]
}
0.0.10

14 days ago

0.0.9

21 days ago

0.0.8

22 days ago

0.0.7

24 days ago

0.0.6

27 days ago

0.0.5

1 month ago

0.0.4

1 month ago

0.0.3

2 months ago

0.0.2

2 months ago

0.0.1

2 months ago