A high-level Python interface to LabArchives notebooks.
labapi represents LabArchives notebooks, folders, pages, and entries as
Python objects. You can navigate by path, work with attachments, search
notebook entries, and get or create pages and folders by path.
The library handles authentication, request signing, XML response parsing, search-result pagination, and entry-type decoding.
- If you are new to
labapi, follow the First Success Tutorial. - If you already use
labapi, go to the Quick Start, User Guide, Examples, or FAQ. - To work on the package itself, start with CONTRIBUTING.md.
Requirements:
- Python 3.11.5+
uv(recommended) orpip
Recommended install for local use:
uv add "labapi[dotenv,builtin-auth]"
# or
pip install "labapi[dotenv,builtin-auth]"Other install options:
# Minimal install
uv add labapi
# or
pip install labapi
# Minimal install plus .env loading
uv add "labapi[dotenv]"
# or
pip install "labapi[dotenv]"Extras:
dotenvloadsAPI_URL,ACCESS_KEYID, andACCESS_PWDfrom a local.envfile.builtin-authenablesdefault_authenticate()to open the LabArchives login flow in a local browser.exportletsNotebook.export()read native LabArchives backup archives.truststoreletsClient(ssl_host_bundle=True)verify TLS certificates against the operating system's trust store.
LabArchives issues API keys on request. Ask your institution's LabArchives site administrator or Enterprise Success Team contact to request API access, or contact support@labarchives.com. LabArchives provides the Access Key ID, Access Password, and the API base URL for your region.
Add your LabArchives API credentials to a .env file:
API_URL=https://api.labarchives.com
ACCESS_KEYID=your_access_key_id
ACCESS_PWD=your_access_passwordOr set them directly in your shell:
export API_URL=https://api.labarchives.com
export ACCESS_KEYID=your_access_key_id
export ACCESS_PWD=your_access_password$env:API_URL="https://api.labarchives.com"
$env:ACCESS_KEYID="your_access_key_id"
$env:ACCESS_PWD="your_access_password"from datetime import datetime
from labapi import Client, NotebookPage, TextEntry
with Client() as client:
user = client.default_authenticate()
notebook_name = next(iter(user.notebooks))
notebook = user.notebooks[notebook_name]
page = notebook.create(
NotebookPage,
f"API tutorial - {datetime.now():%Y-%m-%d %H:%M:%S}",
)
page.entries.create(TextEntry, "<p>Hello from labapi!</p>")Authenticate in a service or callback-based app:
from labapi import Client
with Client() as client:
auth_url = client.generate_auth_url(callback_url)
# Redirect the user to auth_url, then read email + auth_code
user = client.login(email, auth_code)Create different entry types:
from labapi import HeaderEntry, PlainTextEntry, TextEntry
page.entries.create(TextEntry, "<p>Rich text content</p>")
page.entries.create(HeaderEntry, "Final Conclusions")
page.entries.create(PlainTextEntry, "<p>Literal text</p>")
page.entries.create_json_entry({"yield": 0.85, "purity": "99%"})Browse notebooks by name and path:
for name in user.notebooks:
print(name)
notebook = user.notebooks["My Research Notebook"]
page = notebook.traverse("Experiments/2026/Results")- First Success Tutorial: install, authenticate, and create a first entry.
- Quick Start: setup, navigation, page creation, uploads, and basic write operations.
- Authentication Guide: browser authentication, terminal/manual authentication, and callback URL authentication.
- User Guide: paths, entries, API behavior, exceptions, limits, and architecture notes.
- Examples: scripts for JSON sync, folder export, and CSV table updates.
- FAQ: authentication, certificate, and environment troubleshooting.
Clone the repo and install development dependencies:
git clone https://github.com/nimh-dsst/labapi.git
cd labapi
uv sync --all-groups
pre-commit install --hook-type pre-commit --hook-type pre-pushCommon checks:
uv run pytest
uv run ruff check --fix .
uv run ruff format .
uv run pyrightIntegration tests are opt-in and require live credentials. See CONTRIBUTING.md for the full setup, including AUTH_EMAIL and AUTH_KEY.
The authors designed labapi's foundational architecture and implemented its core. Generative AI subsequently assisted with development, testing, maintenance, release work, and project documentation. The authors retain final control over the library's scope, behavior, and public interface and take responsibility for the software, reviewing and accepting AI-assisted changes through public pull requests. The tools used were Anthropic's Claude (Opus 4.6, Opus 4.8, Opus 5, Opus 5.5, Sonnet 4.6, Sonnet 5, Fable 5, Fable 5.1, and Fable 5.2) and OpenAI's Codex (GPT-5.4, GPT-5.5, and GPT-5.6 Luna, Sol, and Terra).
This project is licensed under the MIT License. See the LICENSE file for details.