A Python client for the LabArchives API.
Project description
labapi
A Python client for the LabArchives API.
labapi helps you authenticate with LabArchives, navigate notebook trees, and create or update notebook content from Python.
Start Here
- New to
labapi? Follow the First Success Tutorial for the fastest path from install to a visible change in LabArchives. - Already using
labapi? Jump to the Quick Start, User Guide, Examples, or FAQ. - Working on the package itself? Start with CONTRIBUTING.md.
Install
Requirements:
- Python 3.12+
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.
Configure Credentials
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>")
This is the recommended local workflow:
- Install
labapi[dotenv,builtin-auth]. - Set
API_URL,ACCESS_KEYID, andACCESS_PWD. - Call
default_authenticate()once the client is open. - Start creating or updating notebooks, folders, pages, and entries through the object model.
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: shortest path from install to a successful write.
- Quick Start: setup, navigation, page creation, uploads, and basic write operations.
- Authentication Guide: local browser auth, manual flows, and callback-based integration patterns.
- User Guide: paths, entries, API behavior, exceptions, limits, and architecture notes.
- Examples: end-to-end scripts for real workflows.
- FAQ: troubleshooting and environment questions.
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 CC0 1.0 Universal License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file labapi-1.0.3.tar.gz.
File metadata
- Download URL: labapi-1.0.3.tar.gz
- Upload date:
- Size: 256.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87be2e5ef42040370856c9789f628f1dd0da46cce304f7a7fe0c9c293578ba84
|
|
| MD5 |
ff609c86325451df09c457c32dadadf6
|
|
| BLAKE2b-256 |
fa4c8be931362851fbd2a284c6ca7c442a4086cb301282b86c374c088f3b29a5
|
File details
Details for the file labapi-1.0.3-py3-none-any.whl.
File metadata
- Download URL: labapi-1.0.3-py3-none-any.whl
- Upload date:
- Size: 53.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36e2a1ecb8763a8cb69e23b1715500c5c5437bedba549e3195caf639acebfddd
|
|
| MD5 |
ea2696f5ab2b2325e3949741522242e9
|
|
| BLAKE2b-256 |
55fd21dd2241448bd3a60fef96cbc4efeed4d883fe7353406124544dcbfeb447
|