query Endpoints
All endpoints for the query API group. Great for feeding into an LLM context.
/v1/query
Sql Query Route
Description SQL Query Engine for Valstorm API Args: query (str): SQL query string current_user (User, optional): Current authenticated user. Defaults to Depends(get_current_user). Returns: dict: Dictionary containing records and headers Examples -------- Select All Fields And Records SELECT * FROM contact Select Specific Fields SELECT name, phone FROM Contact Where Field Equals SELECT name, phone FROM Contact WHERE name = 'Jared Simpson' Where LIKE Starts With SELECT name, phone, email FROM Contact WHERE name LIKE 'Unk%' Where LIKE Ends With SELECT name, phone, email FROM Contact WHERE name LIKE '%n' Where LIKE Contains SELECT name, phone, email FROM Contact WHERE name LIKE '%j%' WHERE IN SELECT name, phone, email FROM Contact WHERE name IN ['Jared', 'John'] WHERE OR SELECT name, phone, email FROM Contact WHERE name = 'Jared' OR phone = '555-555-5555' WHERE AND SELECT name, phone, email FROM Contact WHERE name = 'Jared' AND phone = '555-555-5555' WHERE LIMIT SELECT name, phone, email FROM Contact WHERE name = 'Jared' LIMIT 10 WHERE ORDER BY DESC SELECT name, phone, email FROM Contact WHERE name = 'Jared' ORDER BY phone DESC WHERE ORDER BY ASC SELECT name, phone, email FROM Contact WHERE name = 'Jared' ORDER BY phone ASC ORDER BY MULTIPLE SELECT name, phone, email FROM Contact WHERE name = 'Jared' ORDER BY phone ASC, email DESC OFFSET SELECT name, phone, email FROM Contact WHERE name = 'Jared' OFFSET 10 Parent to Child JOIN Query SELECT first_name, last_name, twilio_message.body, twilio_message.id, twilio_message.direction FROM contact JOIN twilio_message ON contact.id = twilio_message.contact WHERE first_name = 'Jared' ORDER BY twilio_message.created_date DESC LIMIT 10 Child to Parent Join SELECT id, disposition, name, contact.name FROM call JOIN contact ON call.contact = contact.id Multi Join SELECT id, name, phone, call.*, twilio_message.* FROM contact JOIN call ON contact.id = call.contact JOIN twilio_message ON contact.id = twilio_message.contact WHERE contact.name LIKE '%Jared%' ORDER BY contact.created_at DESC LIMIT 50 OFFSET 0
Parameters
q*
bypass_cache
Responses
200Successful Response
{}404Not found
422Validation Error
{
"$ref": "#/components/schemas/HTTPValidationError"
}/v1/query
Sql Query Post Route
Request Body
{
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SqlPostQueryRequest"
}
}
}
}Responses
200Successful Response
{}404Not found
422Validation Error
{
"$ref": "#/components/schemas/HTTPValidationError"
}/v1/query/mongo
Mongo Query Route V2
Direct MongoDB Aggregation Endpoint (V2) - Async Returns records in body and Pagination Metadata in Headers.
Request Body
{
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MongoQueryRequest"
}
}
},
"required": true
}Responses
200Successful Response
{}404Not found
422Validation Error
{
"$ref": "#/components/schemas/HTTPValidationError"
}