View Categories

How to Expose a Microsoft SQL Server Database as a Secure REST API

13 min read

Microsoft SQL Server logo MICROSOFT SQL SERVER REST API

Turn a Microsoft SQL Server query into a secure REST API — no Data API Builder, no server to host.

Save a T-SQL query against your SQL Server database, mint a per-recipient API key, and hand a partner a live JSON endpoint. No Data API Builder to deploy, no open 1433 port, no shared login — just a governed, read-only SQL Server REST API in minutes.

No inbound ports Per-recipient keys Read-only enforced Nothing to deploy

Query Streams is a secure, real-time database integration platform that turns any saved SQL Server query into a partner-ready REST API endpoint — with per-recipient keys, read-only enforcement, and a full audit trail. You get a live SQL Server REST API (a clean REST API for SQL Server) without deploying Data API Builder, opening a database port, or hosting a gateway. Learn more at QueryStreams.com and sign up for free to publish your first SQL Server endpoint in minutes.

Why expose a Microsoft SQL Server database as a REST API?

Sooner or later, someone outside your team needs data that lives in Microsoft SQL Server — a client wants their numbers in a dashboard, a vendor wants a live feed instead of a nightly export, a partner’s app needs to read a slice of your tables. The usual answers all leak something. You email exports that are stale on arrival, you hand out a read-only SQL login that outlives the engagement, or you stand up Data API Builder or an ASP.NET Web API and inherit its auth, TLS, and patching forever. To expose a SQL Server database as a REST service the clean way, the partner gets a URL and a token, not your database. The hard part has always been building and operating that API safely. Query Streams makes it a saved query plus a key.

No open SQL Server port

You never expose 1433 to the internet or poke a hole in your firewall. The Network Agent dials out; inbound calls ride back down that one outbound connection.

Per-recipient API keys

Every recipient gets their own qsapi_* key. Revoke one without touching the others, and without rotating your SQL Server login.

Read-only by design

A read-only validator rejects any non-SELECT statement before it reaches SQL Server. There is no accidental UPDATE, MERGE, or DROP path through the API.

Your T-SQL stays private

The recipient sees the endpoint URL, the JSON response, and any filters you exposed — never your T-SQL, schema, instance name, or connection string.

Nothing to host or patch

No Data API Builder container, no ASP.NET app, no reverse proxy. The endpoint runs as a managed feature, so there is no deploy pipeline or TLS rotation to own.

Permanent, expiring, or self-destructing

Make an endpoint permanent, set it to expire on a date, or give it a fixed call budget that self-destructs after a set number of requests.

The usual ways to put a REST API on SQL Server — and why they hurt

There are well-known tools for building a SQL Server web API, and they are good at what they do. The catch is that every one of them leaves you owning infrastructure, a network exposure, or both. Here is how the common approaches compare to a Query Streams shared endpoint when the goal is simply “let a specific partner read a specific result set.”

Concern Microsoft Data API Builder DIY ASP.NET Web API Query Streams
Database reachable from the API Host must reach SQL Server Must reach SQL Server Outbound-only Agent — no inbound port
What the recipient holds A URL into your exposed entities A URL into your service A single-purpose key for one query
Schema exposure Each configured entity is reachable Whatever you hand-code One saved query, nothing else
Per-recipient keys + revoke Wire up your own auth Build it yourself Built in
Audit log of every call Add it yourself Add it yourself Built in
You operate / patch / rotate TLS Yes, forever Yes, forever Managed for you
Time to first endpoint Hours to days Days Minutes

Looking for a Data API Builder alternative for partner sharing?

Microsoft Data API Builder is excellent when you want a full, self-hosted REST and GraphQL surface over your own entities. If instead you want to hand a named partner one governed, read-only result set — with its own key, an audit trail, and no host to run — that is exactly the gap Query Streams fills. The two can coexist: Data API Builder for your internal app, Query Streams for outbound sharing.

How Query Streams turns a SQL Server query into a REST API

Once the Network Agent is installed and your SQL Server connector is configured, promoting a saved query to a shared REST endpoint takes about three steps. If you already use Query Streams for Excel, Google Sheets, or the MCP Server, your Agent and connector are already in place — you start at step two.

1

Connect SQL Server through the Agent

Install the Network Agent next to your database and add a SQL Server connector with a standard read-only login. The Agent makes an outbound TLS connection to Query Streams — your database is never exposed to the internet.

2

Save a T-SQL query

Write the SELECT in the Query Builder against your SQL Server connection — JOINs, CTEs, window functions, and parameters all welcome. Name it and save. Anything you can SELECT can become an endpoint.

3

Promote it and share a key

Open the Install tab, choose the endpoint type (permanent, expiring, or call-budget) and output format, then invite a recipient by email. They get a magic-link claim and their own qsapi_* key.

One saved query, many surfaces

The same saved SQL Server query can drive an Excel refresh, a Google Sheets sidebar, a Claude or Cursor conversation through the MCP Server, and a partner-facing REST endpoint at the same time. You build the query once; Query Streams handles the surfaces.

No open SQL Server port, no shared credentials

The security model is the reason teams reach for this instead of a public database port. Your SQL Server login lives only inside the Agent’s encrypted credential store on your network; it is never transmitted to our cloud and never visible to a recipient. On top of that, every endpoint gives you per-recipient controls you can tighten before you share.

Outbound-only Agent

The Agent connects out on port 443 — normal outgoing HTTPS, no inbound ports, VPN, or tunnel. why no inbound exposure is needed →

Read-only enforcement

A validator runs in the Agent, on your network, before any statement reaches SQL Server. Non-SELECT statements are rejected with READONLY_VIOLATION.

IP + CORS allowlists

Pin a recipient’s key to specific IPs or CIDR ranges, and restrict which browser origins may call each endpoint. Off-list calls are refused before any SQL runs.

Rate limits + byte quotas

Two-tier rate limits (per key and per endpoint) plus an optional monthly byte cap keep a noisy or runaway recipient inside a safe blast radius.

Call your SQL Server REST API

Recipients call the endpoint like any other REST API: a bearer token and a URL. Any saved-query parameter you exposed can be set per call — on the querystring for GET or in a JSON body for POST. The Agent binds those values as proper parameterized-query parameters, never string concatenation, so a recipient cannot break out of a filter to inject SQL.

GET with a filter parameter
# Recipient call against your SQL Server-backed endpoint curl -H “Authorization: Bearer qsapi_K7…ZmQ” \ “https://api.querystreams.com/v1/endpoints/sales-by-rep?region=West&since=2026-01-01”

Pick the output format per call with the Accept header (or a ?format= query parameter): JSON for a single array, CSV for spreadsheets and pandas, or, on a streaming endpoint, NDJSON (one JSON row per line) for parse-as-you-go pipelines. For bandwidth-sensitive consumers, opt into LZ4 payload compression with Accept-Encoding: lz4; uncompressed responses also get standard gzip on the wire automatically. For the full breakdown of static vs streaming modes, the four wire combinations, and OpenAPI 3.1 generation, see the Instant REST API for SQL databases guide.

How usage is billed

The API Platform is included in every plan and draws on the same monthly byte allowance as Excel, Sheets, and MCP — lz4 calls bill on compressed bytes moved, otherwise on uncompressed bytes. how byte-based billing works across surfaces →

Plug it into Power BI, Tableau, and anything that reads JSON

Because every endpoint returns standard JSON — with CSV and streaming NDJSON on tap — any tool that can read a REST feed consumes your SQL Server data directly, with nothing to install on their side and no SQL driver required. Power Query is the easiest bridge into the Microsoft BI stack: in Power BI choose Get Data → From Web, paste the endpoint URL, add your Authorization header, and Power Query parses the JSON into a refreshable table that feeds your data model. (For live data inside a spreadsheet, the native Query Streams Excel add-on is the simpler path — Power Query is there when you want the data in the Power BI model itself.)

Microsoft Power Query logo Power Query Get Data → From Web, paste the URL and bearer token, expand the JSON to a refreshable table
Microsoft Power BI logo Power BI Same Power Query engine — load the endpoint straight into your model and schedule refresh
Tableau logo Tableau Point a Web Data Connector or JSON source at the endpoint for live dashboards
Postman logo Postman Import the OpenAPI 3.1 spec, then send, inspect, and share requests in one click

It also feeds n8n, Qlik, curl, Python (requests or pandas.read_json), Insomnia, Hoppscotch — or any script or workflow that can send an HTTP request and read JSON.

Works with Azure SQL and managed SQL Server too

It does not matter where your SQL Server runs. The Agent connects the same way to an on-premise instance or a managed service — Azure SQL Database, Azure SQL Managed Instance, or Amazon RDS for SQL Server. For the lowest latency, deploy the Agent in the same network or region as the database; one Query Streams account can run multiple Agents across regions and clouds, and a single endpoint behaves identically regardless of which Agent serves it.

More than SQL Server

The same workflow promotes a saved query from PostgreSQL, MySQL, Oracle, Snowflake, BigQuery, DuckDB, and more to a REST endpoint — SQL Server is just a popular starting point. every database the API Platform supports →

Frequently Asked Questions

Do I need to open a port or expose SQL Server to the internet? +
No — the Network Agent dials out over HTTPS (port 443), so your SQL Server port (1433 by default) is never exposed and no inbound firewall rule is needed. how the outbound-only connection works →
Can the recipient see my T-SQL or my database credentials? +
Never — the recipient sees only the endpoint URL, the response body, and the filters you exposed; your T-SQL and SQL Server login stay inside Query Streams and the Agent’s on-network credential store. how per-recipient keys keep credentials private →
How is this different from Microsoft Data API Builder? +
Data API Builder generates a REST and GraphQL surface over the entities you configure and runs as a service you host, secure, and keep reachable from SQL Server. Query Streams takes the opposite, narrower angle for outbound sharing: you expose one saved query as one endpoint, each recipient gets their own revocable key, every call is audited, and there is nothing for you to deploy or patch. Many teams run both — Data API Builder for an internal app, Query Streams for sharing data outside the building.
What output formats can the API return? +
JSON (the default), CSV, and NDJSON on streaming endpoints, chosen per call with the Accept header or a ?format= parameter, with optional LZ4 payload compression. the output formats and wire combinations explained →
Can recipients filter the results, or do they get a fixed query? +
You decide — any parameter you expose becomes a per-call filter (querystring for GET, JSON body for POST), and the Agent binds every value as a real query parameter so filters can’t inject SQL. how exposed parameters and safe binding work →
Can an endpoint expire or self-destruct? +
Yes — an endpoint can be permanent, expire on a date, or self-destruct after a fixed call budget, and you can revoke any recipient’s key instantly without rotating your database password. endpoint lifecycle and key revocation →
Does it work with Azure SQL Database or Amazon RDS for SQL Server? +
Yes. The Agent connects to any reachable SQL Server, on-premise or managed — Azure SQL Database, Azure SQL Managed Instance, and Amazon RDS for SQL Server all work. For best latency, run the Agent in the same region as the database; one account can run multiple Agents across clouds and regions.
Does the recipient need a Query Streams account? +
No — share to a person by email (a magic-link claim auto-creates their Free-tier org and key) for traceability, or issue a service key for unattended machine-to-machine access. sharing by email vs. service keys →

Get Started

Publish your first SQL Server REST API for free.

Sign up, install the Network Agent next to your SQL Server database, save a T-SQL query, and email a recipient a magic-link claim. Per-recipient keys, read-only enforcement, and a full audit trail are on from the first call.

Related guides: Instant REST API for SQL databases | Database REST API platform | Expose PostgreSQL as a REST API | Connector Setup guides

Category: API Platform

Tags: sql-server-rest-api, mssql-rest-api, rest-api-for-sql-server, sql-server-web-api, data-api-builder-alternative, expose-sql-server-as-api, share-sql-server-data, per-recipient-keys, no-code-api, database-rest-api

Meta Description: Turn a SQL Server query into a secure, read-only REST API with per-recipient keys — no Data API Builder, no open port, no code.

Updated on June 16, 2026

Powered by BetterDocs