Skip to content

Read-only schema inference from notes' front matter.

POST
/datanotes/operations/infer_table/
curl --request POST \
--url https://example.com/datanotes/operations/infer_table/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "folder": null, "paths": null, "table": null, "name": null, "max_enum_values": null }'

Read-only schema inference from notes’ front matter.

  • folder (recursive; “” = whole vault) and/or paths: notes not yet in a table. Returns columns (type, enum values, link ref to the table most targets belong to, required, unique, dense, from when the front matter key is not a valid column name, stats), proposal, the create_table arguments (name, description, filename or time_column, columns), and adopt ready for adopt_rows (paths, rename, relocate: false), plus hints to read. The notes cannot say what the table and its columns mean: description is null on the proposal and on every column. Write each one (ask the user when unsure), and review the names, enums and required columns, before you pass the proposal to create_table, which refuses null descriptions.
  • table: keys the table’s rows use but the table does not declare (candidates for add_column, each with a description to write, or keys to drop from rows). A string column becomes an enum when its values repeat: at least 3 notes, at most max_enum_values distinct values (default 12), each used twice on average, short texts.
Media typeapplication/json
object
folder
Any of:
string
paths
Any of:
Array<string>
table
Any of:
string
name
Any of:
string
max_enum_values
Any of:
integer

Done.

Media typeapplication/json
object
files
required

Notes examined.

integer
paths
required

Their paths.

Array<string>
skipped
required

Notes left out, and why.

Array<object>
object
path
required
string
reason
required
string
columns
required

Inferred columns.

Array<object>
object
name
required
string
from

Original front matter key when it is not a valid column name.

string
type
required
string
description
required

What the column holds: null, for the caller to write (create_table and add_column refuse a column without one).

null
items
string
values
Array<string>
ref
string
required
boolean
unique
boolean
dense
boolean
stats
required
object
present
required
integer
filled
required
integer
distinct
required
integer
types
required
object
key
additional properties
integer
examples
required
Array
proposal

The arguments of create_table (folder/paths mode), once the caller writes the descriptions left null.

object
name
required
string
description
required

What a row of the table records: null, for the caller to write (each column’s description too).

null
time_column
string
filename

The notes’ name template, when their names follow one.

string
columns
required
Array<object>

A column spec.

object
key
additional properties
any
adopt

Ready for adopt_rows once the table exists (folder/paths mode).

object
paths
required
Array<string>
rename
object
key
additional properties
string
relocate
required
boolean
hints
required

Remarks for the caller.

Array<string>

Example generated

{
"files": 1,
"paths": [
"example"
],
"skipped": [
{
"path": "example",
"reason": "example"
}
],
"columns": [
{
"name": "example",
"from": "example",
"type": "example",
"description": "example",
"items": "example",
"values": [
"example"
],
"ref": "example",
"required": true,
"unique": true,
"dense": true,
"stats": {
"present": 1,
"filled": 1,
"distinct": 1,
"types": {
"additionalProperty": 1
},
"examples": [
"example"
]
}
}
],
"proposal": {
"name": "example",
"description": "example",
"time_column": "example",
"filename": "example",
"columns": [
{}
]
},
"adopt": {
"paths": [
"example"
],
"rename": {
"additionalProperty": "example"
},
"relocate": true
},
"hints": [
"example"
]
}

Bad input: the body is not a JSON object, or an argument is unknown, missing or of the wrong type.

Media typeapplication/json
object
error
required

What went wrong, for a person or an agent.

string

Example generated

{
"error": "example"
}

Missing or wrong bearer token.

Media typeapplication/json
object
error
required

What went wrong, for a person or an agent.

string

Example generated

{
"error": "example"
}

Unknown table, view, migration, note or folder.

Media typeapplication/json
object
error
required

What went wrong, for a person or an agent.

string

Example generated

{
"error": "example"
}

Ambiguous table name: it matches several tables (paths or tables lists them).

Media typeapplication/json
object
error
required
string
paths

The tables’ folders the name matches.

Array<string>
tables

The qualified tables the name matches.

Array<string>

Example generated

{
"error": "example",
"paths": [
"example"
],
"tables": [
"example"
]
}

Unexpected error.

Media typeapplication/json
object
error
required

What went wrong, for a person or an agent.

string

Example generated

{
"error": "example"
}