labapi
A Python client for the LabArchives API.
labapi authenticates with LabArchives, navigates notebook trees, and creates or updates notebook content from Python.
Start Here
- New to
labapi? Follow the First Success Tutorial to installlabapi, authenticate, and create your first LabArchives entry. - 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.10+
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
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.
Metadata
Release files for labapi 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| labapi-1.2.0.tar.gz | 383.9 kB | Without provenance | Details for labapi-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| labapi-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for labapi-1.2.0-py3-none-any.whl |
Total release size: 445.9 kB
Release files / labapi-1.2.0.tar.gz
| Download URL | labapi-1.2.0.tar.gz |
|---|---|
| Size | 383.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
280aaafd3aeffd9b18a115bcac245c313f10a10310c3f745e63ea0f5fc48af3f
|
|
BLAKE2b-256 checksum How to use checksums |
472b14059d9ec750f429efe32320d88cc9277ed4973f1cc590c0a1780037996d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}
|
Release files / labapi-1.2.0-py3-none-any.whl
| Download URL | labapi-1.2.0-py3-none-any.whl |
|---|---|
| Size | 62.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2fbfb7507b7e048c58b97d80279de52500e4e353c523c8b05bf156664646f983
|
|
BLAKE2b-256 checksum How to use checksums |
800c3c23f2f9a5adf5056e9d33b6827e6bf2b5808ff6b6596f60b411f3139844
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}
|
Security for labapi 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.