Schema
The API is also described as JSON Schema (draft 2020-12), so a program in another language can generate its types instead of copying them from these pages. Get it from nerdr:
nerdr api --schema > nerdr-api.schema.jsonor from nerdr.app/api/schema.json,
which follows nerdr’s main branch and so may have what a release does
not yet. nerdr api --schema gives the schema of the nerdr you have,
and needs no nerdr running.
What it has
Section titled “What it has”Every type is in $defs:
| Definition | Is |
|---|---|
ClientLine |
A line a program sends: Hello, then a Request |
CoreLine |
A line nerdr sends: Welcome, an Answer, or an Event |
Request |
One of the requests, told apart by op: StateRequest, ReadRequest, NewTabRequest and so on |
Event |
One of the events, told apart by event: AgentEvent, TabOpenedEvent and so on |
State, Tab, Agent, Terminal, Branch, Question, Repo |
What state, repos and the events carry |
Answer.result is a different type for each request, which JSON Schema
cannot tie to the request. x-nerdr-ops does, for each op:
"x-nerdr-ops": { "read": {"request": {"$ref": "#/$defs/ReadRequest"}, "result": {"$ref": "#/$defs/ReadResult"}}, "repos": {"request": {"$ref": "#/$defs/ReposRequest"}, "result": {"type": "array", "items": {"$ref": "#/$defs/Repo"}}}, …}A request with nothing to give back has an empty object as its result.
Versions
Section titled “Versions”x-nerdr-api is the API version the schema
describes, the same number nerdr sends in the welcome. Within a version
the schema only grows: new fields, requests and events. No object in it
forbids properties it does not list, and a program should not either:
pass by fields, events and ops it does not know, so it keeps working
with a newer nerdr. Generate the types again to use what is new.