# AI Studio API Support

Overview

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.<br>

### Visit AI Studio [here](https://dapplooker.com/ai-studio?protocol=ethereum).

#### Prerequisites:

* You must have a valid DappLooker API Key. Sign up at [DappLooker](https://dapplooker.com) or Get API key from [here](/api-guides/get-api-key.md).
* Node.js environment installed.

***

### 1. **Install SDK**

You can install the DappLooker SDK in your project using `npm`.

```bash
npm install dapplooker-sdk
```

***

### 2. **Get the Details of a Project**

The following code retrieves the schema details of projects available in DappLooker.

```typescript
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();
```

#### Sample Response:

```json
{
   "success": true,
   "data": {
      "projects": [
         {
            "projectName": "Aave V3 Ethereum",
            "schemaName": "aave_v3_ethereum",
            "networkName": "MAINNET"
         },
         {
            "projectName": "Gooddollar Celo",
            "schemaName": "gooddollar_celo",
            "networkName": "OFFCHAIN"
         }
         // More projects...
      ]
   }
}
```

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.

```typescript
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();
```

#### Sample Response:

```json
{
  "success": true,
  "data": {
    "msg": "Visualization Result",
    "vizualizationData": {
      "rows": [
        ["<timestamp>", "<average_value>", "<low_value>"]
        // More rows...
      ],
      "cols": [
        {
          "display_name": "Hour",
          "source": "native",
          "name": "Hour",
          "base_type": "type/DateTime",
          "effective_type": "type/DateTime"
        }
        // More columns...
      ],
      "native_form": {
        "query": "<SQL_QUERY>",
        "params": null
      },
      "results_timezone": "GMT",
      "results_metadata": {
        "columns": [
          {
            "display_name": "Hour",
            "name": "Hour",
            "base_type": "type/DateTime",
            "effective_type": "type/DateTime"
          }
          // More metadata...
        ]
      }
    },
    "questionId": "<question_id>",
    "answerId": "<answer_id>",
    "entityId": "<entity_id>",
    "entityType": "CHART"
  },
  "nlqLogId": "<nlq_log_id>"
}
```

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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.dapplooker.com/dapplooker-analytics/products/ai-studio/ai-studio-api-support.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
