CARV
CARVPlayPortalProtocol
  • Overview
    • Introducing CARV
  • SVM - AI AGENTIC CHAIN
    • Introduction
      • Architecture
      • AI Agent in TEE environment
      • CARV Verifier Nodes
    • Quick Start
      • Bridge Token
      • Explorer
      • Command line tool
      • Reading from CARV SVM Network
      • Writing to the Network
      • Network Info
  • D.A.T.A. - AI FRAMEWORK
    • Introduction
      • DeepSeek Integration
      • D.A.T.A's Core Features
      • How It Empowers AI Agents
      • Driving the Future of AI and Blockchain
      • Leveraging CARV SVM Chain for Privacy and Trustless Data Sharing
    • Quick Start Guide
    • Architecture
    • ERC-7231 (CARV ID)
    • Examples
      • On-Chain Insights
    • Getting Started
      • D.A.T.A Framework Plugin for Eliza
    • Use Cases and Implementation
      • Getting On-Chain Data for AI Agents
      • What's Coming with the D.A.T.A Framework
    • API Documentation
      • News
      • On-chain Data SQL Query
        • Ethereum Schema
        • Bitcoin Schema
        • Base Schema
        • Solana Schema
      • On-chain Data SQL Query by LLM
      • Token Info and Price
      • User Balance by Twitter ID
      • User Balance by Discord ID
  • CARV Ecosystem
    • CARV Play
      • Portal Access
      • Integration Guide
        • .Play Name Service Integration
        • API-Verified Quest (RESTFUL)
        • API-Verified Quest (GraphQL)
        • CARV ID OAuth 2.0
        • CARV ID Telegram SDK
      • Smart Contracts & Security
    • MOFF Bot & Customer Data Platform
    • CARV Account
      • ERC 7231
    • Verifier Nodes
      • How to Purchase Nodes
      • Buyback Program
      • Why Verifier Nodes
      • How do Verifier Nodes Work
        • CARV/veCARV Token
        • CARV Vault
        • CARV NFT License
        • CARV Protocol Service
        • Trusted Execution Environment (TEE)
        • Verifier Node
        • Attestation
        • Delegation
        • Rewards
        • SGX Attestation Verification
      • Verifier Node Sale Dynamics
      • Smart Contract Addresses
      • License Key (NFT)
      • Delegation
      • Node Rewards
      • Join Mainnet Verifier Nodes
        • Prerequisites
        • Delegation Tutorial
        • Operating a Verifier Node
          • Running in VPS
          • Running in CLI
            • Using Source Code
            • Using Docker
            • Gasless Server API
          • Running in Desktop App
      • Explorer
      • FAQ
        • Node Sale
        • Node Operation
  • CARV LABS
    • Introduction
    • Working with CARV Labs
  • Tokenomics
    • Utility
      • veCARV(s)
    • Distribution & Vesting
  • DECENTRALIZED GOVERNANCE
    • ⚔️Universal Guardian Program
    • 📔DAO Governance
    • 🌏Community Programs & Activities
  • Resources
    • 🗜️Writings
    • 🗞️CARV in the News
    • 🫶Social & Community Links
    • 🅰️Brand Guideline
    • 💰Job Openings
Powered by GitBook
On this page
  • Schema
  • POST /ai-agent-backend/sql_query
  1. D.A.T.A. - AI FRAMEWORK
  2. API Documentation

On-chain Data SQL Query

PreviousNewsNextEthereum Schema

Last updated 3 months ago

Schema

If you want to leverage LLM to generate sql queries, you can refer to below schemas as prompt to the LLM:

POST /ai-agent-backend/sql_query

This endpoint allows you to send SQL queries to the CARV backend to fetch on-chain data.

Request Parameters

Name
Location
Type
Required
Description

sql_content

Body

string

Yes

The SQL query to be executed.

Example Request

curl -X POST https://interface.carv.io/ai-agent-backend/sql_query \
     -H "Content-Type: application/json" \
     -H "Authorization: <YOUR_AUTH_TOKEN>" \
     -d '{"sql_content":"WITH address_activity AS (SELECT from_address AS address, COUNT(*) AS tx_count FROM eth.transactions WHERE date_parse(date, '\''%Y-%m-%d'\'') >= date_add('\''month'\'', -3, current_date) GROUP BY from_address UNION ALL SELECT to_address AS address, COUNT(*) AS tx_count FROM eth.transactions WHERE date_parse(date, '\''%Y-%m-%d'\'') >= date_add('\''month'\'', -3, current_date) GROUP BY to_address) SELECT address, SUM(tx_count) AS total_transactions FROM address_activity GROUP BY address ORDER BY total_transactions DESC LIMIT 1;"}'

Example Response

200 OK Response

{
    "code": 0,
    "msg": "Success",
    "data": {
        "column_infos": [
            "address",
            "total_transactions"
        ],
        "rows": [
            {
                "items": [
                    "0xdac17f958d2ee523a2206206994597c13d831ec7",
                    "11021156"
                ]
            }
        ]
    }
}

400 Bad Request Response

{
  "error": "Invalid SQL query."
}

Response Status Codes

Status Code
Description
Data Model

200

OK

Inline

400

Bad Request

Inline

Response Data Structure

200 OK

Field
Type
Required
Constraints
Description

code

integer

Yes

None

Status code.

msg

string

Yes

None

Response message.

data

object

Yes

None

Data from the query.

column_infos

array

Yes

None

Column headers of data.

rows

array

Yes

None

Query result rows.

400 Bad Request

Field
Type
Required
Constraints
Description

error

string

Yes

None

Error message.

Ethereum Schema
BTC Schema
Base Schema
Solana Schema