JSON Entries#

Use create_json_entry() to upload JSON and add a rich-text preview to the same page.

How JSON Entries Are Stored#

When you create a JSON entry with labapi, the library creates two related entries:

  • A JSON attachment that stores the JSON-serialized data.

  • A rich-text preview entry that shows a formatted, human-readable version in the notebook page.

Create a JSON Entry#

Use create_json_entry() on page.entries:

from labapi import JsonData

page = user.notebooks["My Notebook"].traverse("My Json Data/Page 1")

my_data: JsonData = {
    "name": "Experiment 1",
    "date": "2024-01-01",
    "readings": [
        {"time": "10:00", "value": 1.23},
        {"time": "11:00", "value": 4.56},
    ],
    "completed": True,
}

attachment_entry, text_entry = page.entries.create_json_entry(my_data)

print(f"Created attachment entry (ID: {attachment_entry.id})")
print(f"Created text preview (ID: {text_entry.id})")