# reylo.dev playground API

Reylo infers a SQL query's TypeScript types from the database. The playground's API returns them as JSON, analyzed against the playground's sample schema of users, posts and events; nothing is run.

## GET /play?q=<sql>

The playground's own link, asked for JSON, answers with the query's types, so a link you share works for an agent too.

```sh
curl -H 'accept: application/json' 'https://reylo.dev/play?q=select+name+from+users+where+id+%3D+%3Aid'
```

## GET /play/api/analyze?q=<sql>

A query's params, return type, row type, cardinality and errors, analyzed against the playground's sample schema of users, posts and events and never run.

```sh
curl 'https://reylo.dev/play/api/analyze?q=select+name+from+users+where+id+%3D+%3Aid'
```

```json
{
  "params": "{ id: number }",
  "returns": "{ name: string } | null",
  "element": "{ name: string }",
  "cardinality": "maybeOne",
  "diagnostics": []
}
```

## GET /play/api/schema

The tables with their columns and types, and the functions and type names the editor completes.

```sh
curl 'https://reylo.dev/play/api/schema'
```
