npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dwagent-ai

v1.0.0

Published

AI-powered database assistant

Downloads

112

Readme

SQL Generation API

A powerful API service for converting natural language to SQL, validating SQL queries, and managing database schemas.

Use AI2SQL in Claude Code (MCP)

AI2SQL is available as an MCP server for Claude Code. Generate, explain, optimize and fix SQL queries without leaving your editor.

Quick Setup

Add to your Claude Code settings:

{
  "mcpServers": {
    "ai2sql": {
      "command": "npx",
      "args": ["-y", "ai2sql-mcp"]
    }
  }
}

Available Tools

| Tool | Description | |------|-------------| | generate_sql | Convert natural language to SQL | | explain_sql | Get plain English explanation of any query | | optimize_sql | Performance optimization suggestions | | fix_sql_error | Fix broken queries from error messages |

Supports PostgreSQL, MySQL, SQL Server, Snowflake, Oracle, and SQLite.

npm package | Read more


Features

Core API Services

  • Text-to-SQL Conversion: Convert natural language queries to SQL statements
  • SQL Validation: Validate SQL queries against your database schema
  • Schema Management: Store and reference your database schema for better SQL generation
  • Multiple SQL Dialects: Support for standard SQL, MySQL, PostgreSQL, SQL Server, and Snowflake

Authentication & Security

  • API Key Authentication: Simple and secure API key-based authentication
  • HTTPS-Only Access: All API endpoints are served over HTTPS
  • Key Management: Create, revoke, and manage API keys through the dashboard

Usage & Rate Limits

  • Flexible Plans: Different rate limits based on your subscription level
  • Usage Analytics: Monitor your API usage with a comprehensive dashboard
  • Clear Rate Limit Headers: X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset headers

Getting Started

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/dwagent-ai.git
  2. Install dependencies:

    npm install
  3. Set up your environment variables:

    cp .env.example .env

    Update the .env file with your database credentials and API keys.

  4. Run database migrations:

    npm run prisma:migrate
  5. Start the development server:

    npm run dev

Using the API

Authentication

All API requests require an API key to be included in the X-API-Key header:

const response = await fetch('https://api.example.com/api/sql/generate', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'your_api_key'
  },
  body: JSON.stringify({
    text: 'Find all users who signed up in the last month',
    dialect: 'mysql'
  })
});

Converting Text to SQL

// JavaScript Example
const response = await fetch('https://api.example.com/api/sql/generate', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'your_api_key'
  },
  body: JSON.stringify({
    text: 'Find all users who signed up in the last month',
    dialect: 'mysql',
    prettify: true
  })
});

const data = await response.json();
console.log(data.sql);
# Python Example
import requests

response = requests.post(
    'https://api.example.com/api/sql/generate',
    headers={
        'Content-Type': 'application/json',
        'X-API-Key': 'your_api_key'
    },
    json={
        'text': 'Find all users who signed up in the last month',
        'dialect': 'mysql',
        'prettify': True
    }
)

data = response.json()
print(data['sql'])
// PHP Example
$url = 'https://api.example.com/api/sql/generate';
$data = [
    'text' => 'Find all users who signed up in the last month',
    'dialect' => 'mysql',
    'prettify' => true
];

$options = [
    'http' => [
        'method' => 'POST',
        'header' => [
            'Content-Type: application/json',
            'X-API-Key: your_api_key'
        ],
        'content' => json_encode($data)
    ]
];

$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
$result = json_decode($response, true);
echo $result['sql'];

API Documentation

Interactive API documentation is available at /api-docs when running the server.

Key Endpoints

  • POST /api/sql/generate - Convert natural language to SQL
  • POST /api/sql/validate - Validate SQL query
  • POST /api/sql/schema - Create or update a schema
  • GET /api/sql/schema/:id - Get schema by ID
  • POST /api/sql/apikey - Generate a new API key
  • DELETE /api/sql/apikey/:id - Revoke an API key
  • GET /api/sql/usage - Get API usage statistics

Dashboard

Access the API usage dashboard at /api-dashboard.html to monitor:

  • Monthly API usage
  • Query type breakdown
  • API key management
  • Usage statistics by API key

Rate Limits

API calls are subject to rate limiting based on your subscription plan:

  • Free: 100 API calls per month
  • Start: 1,000 API calls per month
  • Pro: 5,000 API calls per month
  • Business: 20,000 API calls per month

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Your Name - @yourtwitter - [email protected]

Project Link: https://github.com/yourusername/dwagent-ai