Run SQL Directly Over Any API: Meet Coral
Ever wished you could query a REST API like it's a SQL table? No more duct-taping together fetch() loops or writing a mini ETL pipeline just to join data from two endpoints. That's exactly what Coral does, and it's way simpler than it sounds.
Coral is an open source SQL runtime that runs right over any HTTP API. Think of it as a lightweight, embeddable query engine that lets you treat API responses as tables and write standard SQL against them—no server, no schema, no setup headaches.
What It Does
Coral takes a set of API endpoints you define, and exposes them as virtual SQL tables. You can then write queries like SELECT * FROM users WHERE name LIKE 'Alice%' and Coral handles the HTTP calls, response parsing, and filtering internally. Under the hood, it compiles SQL into API request plans and executes them efficiently.
It's not a full database—it's a runtime that translates SQL into API calls. The magic is that you don't need to learn a new DSL or write glue code. Just point Coral at your API, define a simple schema (or let it infer one), and start querying.
Why It's Cool
No extra infrastructure. Coral runs as a library. No server to deploy, no database to configure. You embed it in your application, CLI tool, or agent.
Great for AI agents. If you're building an agent that needs to pull data from multiple SaaS APIs (GitHub, Slack, Stripe, etc.), Coral lets you treat those APIs as a single queryable surface. Your agent just writes SQL.
Automatic pagination and rate limiting. Coral handles pagination from APIs that return next_page tokens or offset-based results. It also respects rate limits and can batch requests intelligently.
Composable. You can join data from multiple APIs in one query. For example, get all open issues from GitHub, merge with the assignee's Slack handle from a different API, all in a single SELECT.
Tiny footprint. The core is around 2MB compiled. Works in Node.js, Deno, and Bun.
How to Try It
Clone the repo or install via npm:
npm install @coral-xyz/coral
Then define an API source:
import { Coral } from '@coral-xyz/coral'
const coral = new Coral()
coral.addSource('github', {
baseUrl: 'https://api.github.com',
endpoints: {
repos: '/orgs/{org}/repos',
issues: '/repos/{owner}/{repo}/issues',
}
})
// Now just query like any database
const repos = await coral.query(`
SELECT name, stars FROM github.repos
WHERE org = 'vercel'
ORDER BY stars DESC
LIMIT 5
`)
There's also a REPL for quick experimentation:
npx coral repl
Check the GitHub repo for full docs, examples, and the API schema format.
Final Thoughts
Coral fills a niche that's been missing: a genuinely simple way to query APIs with SQL, without the overhead of a full ORM or a caching layer. If you've ever written a script that does for await (const page of paginate('/users')) { ... } and wished you could just SELECT * FROM users, this is for you.
It's especially handy for:
- Building internal dashboards across multiple tools
- Powering AI agents that need structured data from APIs
- Prototyping data pipelines without spinning up a database
- Quick ad-hoc queries in a terminal
The project is still early, but the core idea is solid. If you're tired of wrangling API responses by hand, give it a try.
Found this on @githubprojects
Repository: https://github.com/withcoral/coral