This documentation provides details on how to use the DappLooker SDK to interact with AI Studio API. It explains how to install the SDK, retrieve schema details of projects, and query data using Natural Language Query (NLQ). The API Key is required for accessing the data securely.
Visit AI Studio .
Prerequisites:
You must have a valid DappLooker API Key. Sign up at or Get API key from .
Node.js environment installed.
1. Install SDK
You can install the DappLooker SDK in your project using npm.
npm install dapplooker-sdk
2. Get the Details of a Project
The following code retrieves the schema details of projects available in DappLooker.
import { DappLookerNlqAPI } from "dapplooker-sdk";
// Function to get schema details
async function getSchemaDetails(): Promise<any> {
let response = await DappLookerNlqAPI.getSchemaName("");
console.log("API Response Data: ", JSON.stringify(response));
};
getSchemaDetails();
This response provides the projectName, schemaName, and the networkName for different projects that are supported by DappLooker.
3. Query Data Using Natural Language (NLQ)
DappLooker supports querying data using simple natural language queries. You will need to pass your API Key and the query string to retrieve data.
import { DappLookerNlqAPI } from "dapplooker-sdk";
// Function to get data using NLQ
async function getNlqData(): Promise<any> {
let apiKey = "YOUR_DAPPLOOKER_API_KEY"; // Replace with your API key
let response = await DappLookerNlqAPI.getNlqData(apiKey, 'What is the current gas price per hour on the Ethereum network?', 'ethereum');
console.log("API Response Data: ", JSON.stringify(response));
};
getNlqData();
This response contains the visualized data with columns such as Hour, average_value, and low_value. Additionally, it includes metadata such as the query used and the time zone.
4. Important Notes:
Always ensure your API Key is securely stored and not hardcoded in production environments.
Modify NLQ queries according to your data needs, and you can interact with multiple blockchain networks and schemas through the SDK.