Kwil v2
Search…
⌃K

Getting Started

The Kwil-JS SDK supports creating and interacting with Kwil databases in Node.js and browser.
Kwil-JS is a JavaScript/Typescript SDK for building web and Node.js applications to interact with the Kwil network.
A sample repository for using the Kwil-JS SDK in Node and Browser can be found here.

Installation

npm i kwil

NodeJS Initialization

import ethers.js and kwil.js, and initialize the Kwil client.
const { ethers } = require('ethers');
const kwiljs = require('kwil');
// instead of a provider, nodeJS requires a wallet
const wallet = new ethers.Wallet("my_ethereum_private_key")
// create a new Kwil web client
const kwil = new kwiljs.NodeKwil({
kwilProvider: "kwil_provider_endpoint",
});
kwil_provider_endpoint can be found here.

Web Initialization

In browser, all imports must be destructured. There is no default value to import from the Kwil SDK.
Import ethers.js and kwil.js.
import { ethers } from 'ethers';
import { WebKwil } from 'kwil';
const provider = new ethers.providers.Web3Provider(window.ethereum)
await provider._ready()
await ethereum.request({ method: 'eth_requestAccounts' });
const kwil = new WebKwil({
kwilProvider: "kwil_provider_endpoint"
});

The Kwil Object

The initialized "kwil" object-given from either the NodeKwil or WebKwil provider as shown above-is used in the next examples that show how to read and write data, build databases, and query for important metadata.