Overview
JSON Lines is the simplest way to query data from Amp, ideal for:- Ad-hoc queries and data exploration
- Integration with tools that support HTTP
- Quick prototyping and testing
- Applications that need JSON output
Key Features
- HTTP-based - Standard POST requests with any HTTP client
- Plain text SQL - No special encoding required
- NDJSON format - One JSON object per line for streaming-friendly output
- Synchronous - Results returned after full query execution
Server Configuration
The JSON Lines endpoint runs on port 1603 by default.Default Setup
Custom Port Configuration
.amp/config.toml
JSONL-Only Mode
Run only the JSON Lines endpoint:API Reference
POST /
Execute a SQL query. Request:- Method:
POST - Path:
/ - Content-Type:
text/plain - Body: SQL query string
- Content-Type:
application/x-ndjson - Body: Newline-delimited JSON records
- Status Codes:
200 OK- Query executed successfully400 Bad Request- Invalid SQL or unsupported operation500 Internal Server Error- Server error during execution
GET /health
Health check endpoint. Request:- Method:
GET - Path:
/health
- Status:
200 OK
Basic Usage
curl Examples
Simple Query
Query with WHERE Clause
Multi-line Query
Query with Namespace
Response Format
Successful queries return NDJSON (Newline-Delimited JSON), where each line is a complete JSON object representing one result row:- Streaming-friendly - Parse line-by-line without loading entire response
- Simple - Each line is valid JSON
- Efficient - No array wrapper overhead
Processing NDJSON
With jq
With Python
With Node.js
UDF Examples
JSON Lines supports all SQL UDFs:Hex Decoding
Unit Conversion
Error Handling
Errors return JSON witherror_code and error_message fields.
Invalid SQL String
Request:SQL Parse Error
Request:Streaming Not Supported
Request:Verifying Connection
Check if the JSON Lines server is running:200 OK.
Limitations
- Batch queries only - Streaming queries (
SETTINGS stream = true) are rejected - Single statements only - Multiple SQL statements per request are not supported
- JSON output only - Results are always NDJSON format
- No Arrow benefits - No zero-copy reads or columnar processing
When to Use JSON Lines
Best For:
- Quick data exploration with curl
- Integration with JSON-based systems
- Simple scripts and automation
- Ad-hoc queries and debugging
Not Ideal For:
- High-throughput production workloads (use Arrow Flight)
- Streaming queries (use Arrow Flight)
- Large result sets (use Arrow Flight for better memory efficiency)
- Applications that can use Arrow format natively
Python Client Library
While curl works great, you can create a simple Python wrapper:Next Steps
SQL Basics
Learn SQL syntax and query patterns
Arrow Flight
High-performance gRPC interface for production
Streaming
Set up real-time streaming queries (requires Arrow Flight)