Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

labapi

A Python client for the LabArchives API.

Python Version Tests DOI License: MIT

labapi authenticates with LabArchives, navigates notebook trees, and creates or updates notebook content from Python.

Source | Docs | Issues

Start Here

Install

Requirements:

  • Python 3.10+
  • uv (recommended) or pip

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:

  • dotenv loads API_URL, ACCESS_KEYID, and ACCESS_PWD from a local .env file.
  • builtin-auth enables default_authenticate() to open the LabArchives login flow in a local browser.

Configure Credentials

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_password

Or 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"

.env files are only auto-loaded when python-dotenv is installed, such as with labapi[dotenv].

Quick Start

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>")

Common Tasks

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")

Documentation Map

  • 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.

Development

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-push

Common checks:

uv run pytest
uv run ruff check --fix .
uv run ruff format .
uv run pyright

Integration tests are opt-in and require live credentials. See CONTRIBUTING.md for the full setup, including AUTH_EMAIL and AUTH_KEY.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

labapi-1.2.0rc3.tar.gz (380.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

labapi-1.2.0rc3-py3-none-any.whl (60.9 kB view details)

Uploaded Python 3

File details

Details for the file labapi-1.2.0rc3.tar.gz.

File metadata

  • Download URL: labapi-1.2.0rc3.tar.gz
  • Upload date:
  • Size: 380.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for labapi-1.2.0rc3.tar.gz
Algorithm Hash digest
SHA256 f0025cfebf405fa4d89874220d79d7452e19f667d8a7acd93a8e6cc2bdcd7d29
MD5 4b3a3219e305a3bd8e8f92ab95ab75c6
BLAKE2b-256 d406093a244c87522d728684988bdab1e9235fd4801ae0e365e883911878bbd2

See more details on using hashes here.

File details

Details for the file labapi-1.2.0rc3-py3-none-any.whl.

File metadata

  • Download URL: labapi-1.2.0rc3-py3-none-any.whl
  • Upload date:
  • Size: 60.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for labapi-1.2.0rc3-py3-none-any.whl
Algorithm Hash digest
SHA256 1438f19a43fd8fea240964b8052b30ae2ed85e83b50d55310e1072d828e74444
MD5 0d481ecdad8166c9070adbcadb27426b
BLAKE2b-256 681be7840dbc5c0849a6219369fea2951b535d564c6a72fb6361490e2b8453b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page