Links

15. AI2sql API Integration

Integrate SQL generation in your application with AI2sql's API, allowing you to transform natural language into SQL queries seamlessly. For information on API access and application, please visit the website for documentation and procedures.
Method: POST
Endpoint: https://app.ai2sql.io/api/1.1/wf/<BUSINESS_IDENTIFIER>
Authentication: Token <ACCESS_TOKEN>
Parameters:
prompt: A brief explanation of the data query you need.
model_version: Choose from sg-v1, sg-v2, sg-v3, sg-v4, or sg-v5. Default is sg-v1.
database_type: Supports one of these databases - MSSQL, MariaDB, Aurora, DynamoDB, or SQLite.
tables: An array of objects detailing your database schema.
Replace <BUSINESS_IDENTIFIER> with the unique ID found in your AI2sql account dashboard URL.
Your <ACCESS_TOKEN> is available under Account Settings > API Access.
Choose from our simple or detailed schema structures based on your requirement.
Example Use Case
Suppose you want to query data from a table named customers. With AI2sql, you can simply describe your query, like "Get all customers who joined in the last month", and AI2sql will convert it into a corresponding SQL query.
curl -X POST 'https://app.ai2sql.io/api/1.1/wf/<BUSINESS_IDENTIFIER>' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Authorization: Bearer YOUR_BEARER_TOKEN' \
-d 'user=YOUR_EMAIL_ADDRESS' \
-d 'prompt=Get all customers who joined in the last month' \
-d 'tables=customers(id, name, join_date)'

Utilizing AI2sql API After Adding Tables

After you have created and added tables to AI2sql, you can use the AI2sql API to interact with these tables efficiently. This powerful tool simplifies the process of querying and manipulating data in your database tables using natural language. For more detailed instructions on AI2sql tables and capabilities, refer to the AI2sql documentation

Schema Mapping

This section should detail the mapping of natural language terms to their corresponding SQL tables, columns, and relationships in the database. This template can be customized for any database by filling in specific details related to the database schema, business rules, and terminology.