POST
/
db
/
nl-query
JavaScript
const response = await fetch('https://api.worqhat.com/db/nl-query', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  body: JSON.stringify({
    question: "How many active users do we have?",
    table: "users"
  })
});
const data = await response.json();
console.log(data);
{
  "success": true,
  "data": [
    {}
  ],
  "sql": "SELECT COUNT(*) as count FROM users WHERE status = 'active'",
  "message": "Query processed successfully"
}

Authorizations

Authorization
string
header
required

API key authentication. Format - "Bearer YOUR_API_KEY"

Body

application/json
question
string
required

Natural language question

Example:

"How many active users do we have?"

table
string

Table name to query

Example:

"users"

Response

Query processed successfully

success
boolean
Example:

true

data
object[]
sql
string

The generated SQL query

Example:

"SELECT COUNT(*) as count FROM users WHERE status = 'active'"

message
string
Example:

"Query processed successfully"