Skip to main content

NL2SQL API

FastAPI REST service for the NL2SQL engine (nl2sql-engine). It builds one NL2SQL engine at startup, from the same env file and configs as the CLI, and serves it under /api/v1.

Running the API

pip install nl2sql-api
ENV=demo NL2SQL_API_ROLE=admin nl2sql-api --host 127.0.0.1 --port 8000 [--reload]
# or: python -m nl2sql_api.server ..., or: uvicorn nl2sql_api.main:app

Start it from the folder holding the env file and configs (the demo's use relative paths). Interactive docs: Swagger UI at /docs, ReDoc at /redoc, the schema at /openapi.json.

The API does not authenticate callers and never takes the RBAC role from the request body. Set one of: NL2SQL_API_ROLE_HEADER (a header a trusted proxy sets), NL2SQL_API_ROLE (one static role) or, for local testing only, NL2SQL_API_TRUST_BODY_ROLE=true (the body's user_context; logs a warning). With none, /api/v1/query and /api/v1/query/stream answer HTTP 401.

Endpoints

  • POST /api/v1/query - Ask a question as the configured role
  • POST /api/v1/query/stream - The same, as Server-Sent Events: each step as it runs, the result manifest, the answer as it is written, then the /query response
  • GET /api/v1/health - Liveness check
  • GET /api/v1/ready - Readiness check (does not yet check dependencies)
  • POST /api/v1/datasource - Register a datasource in the running process
  • GET /api/v1/datasource - List registered datasource ids
  • GET /api/v1/datasource/{datasource_id} - Check a datasource is registered
  • DELETE /api/v1/datasource/{datasource_id} - Not supported yet (answers success: false)
  • POST /api/v1/llm - Configure an LLM in the running process
  • GET /api/v1/llm - List configured LLMs
  • GET /api/v1/llm/{llm_name} - Get one configured LLM
  • POST /api/v1/index/{datasource_id} - Index one datasource's schema
  • POST /api/v1/index-all - Index every registered datasource
  • DELETE /api/v1/index - Clear the vector store
  • GET /api/v1/index/status - Index health (status, entries by type, embedding model, problems)

Reference: https://github.com/nadeem4/nl2sql/blob/main/docs/api/rest/index.md.

Metadata

Release files for nl2sql-api 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nl2sql-api 0.3.0
File Size Uploaded
nl2sql_api-0.3.0.tar.gz 22.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nl2sql-api 0.3.0
File Interpreter ABI Platform
nl2sql_api-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 40.4 kB

Release files / nl2sql_api-0.3.0.tar.gz

Download URL nl2sql_api-0.3.0.tar.gz
Size 22.4 kB
Tags Source
SHA-256 checksum
How to use checksums
394480bf49cd1be016d5bb2da1bddb36d0b215edd915a953b32d35ac5d4258df
BLAKE2b-256 checksum
How to use checksums
513ad999b2d472108b8d952325612e820b52806ce4656989b81ea6025afc8254
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / nl2sql_api-0.3.0-py3-none-any.whl

Download URL nl2sql_api-0.3.0-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4f7f2d805fd586f3777547e7de9b9170734cbbf912acf3e2a5e396b57c41493c
BLAKE2b-256 checksum
How to use checksums
ea8b8dd8fd728d635969d4ee750a13cbb6b6fe59e9b3bcead5181f296104d9f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

This release

0.3.0 This release

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page