# SQL API

- [Overview](https://docs-lunar.earthly.dev/sql-api/sql-api.md): Overview of Lunar's read-only SQL API for querying components, domains, policies, checks, and other Hub data via PostgreSQL clients.
- [Views](https://docs-lunar.earthly.dev/sql-api/views.md)
- [domains](https://docs-lunar.earthly.dev/sql-api/views/domains.md): Schema reference for the domains SQL view — one row per domain with its description, owner, and metadata for grouping components.
- [components](https://docs-lunar.earthly.dev/sql-api/views/components.md): Schema reference for the components and components\_latest SQL views — time series of tracked components with merged collector metadata per commit.
- [component\_deltas](https://docs-lunar.earthly.dev/sql-api/views/component-deltas.md): Schema reference for the component\_deltas SQL views — per-collector metadata deltas that merge into each component's full JSON over time.
- [initiatives](https://docs-lunar.earthly.dev/sql-api/views/initiatives.md): Schema reference for the initiatives SQL view — one row per initiative grouping policies around a shared goal or compliance requirement.
- [policies](https://docs-lunar.earthly.dev/sql-api/views/policies.md): Schema reference for the policies SQL view — one row per policy with its enforcement level and parent initiative.
- [checks](https://docs-lunar.earthly.dev/sql-api/views/checks.md): Schema reference for the checks and checks\_latest SQL views — every policy check evaluation with status, enforcement, component, and PR context.
- [prs](https://docs-lunar.earthly.dev/sql-api/views/prs.md): Schema reference for the prs SQL view — pull request metadata mirrored from GitHub including author, status, and latest commit details.
- [catalog](https://docs-lunar.earthly.dev/sql-api/views/catalog.md): Schema reference for the catalog and catalog\_latest SQL views — full catalog JSON snapshots produced by catalogers, with history over time.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-lunar.earthly.dev/sql-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
