Labarchive Integration

Sync laboratory data and research notes with automated LabArchives electronic notebook integration

Labarchive Integration is a community skill for automating electronic laboratory notebook operations through the LabArchives platform, covering notebook creation, entry management, file attachment, data export, and collaboration configuration for research data management.

What Is This?

Overview

Labarchive Integration provides tools for programmatic interaction with LabArchives electronic lab notebook systems. It covers notebook creation that sets up structured research notebooks with configurable sections, folders, and access permissions, entry management that creates, edits, and retrieves notebook entries with rich text content and metadata tags, file attachment that uploads experimental data files, images, and instrument outputs to specific notebook entries, data export that extracts notebook content in structured formats for analysis pipelines and archival, and collaboration configuration that manages sharing permissions and reviewer access across research teams. The skill enables researchers to integrate lab notebook operations into automated research workflows.

Who Should Use This

This skill serves research scientists automating lab notebook documentation, laboratory informatics teams building data management pipelines, and research administrators configuring notebook structures for compliance.

Why Use It?

Problems It Solves

Manual entry of experimental results into electronic lab notebooks is time-consuming and error-prone when handling high-throughput experiments. File attachments from instruments require manual upload and association with the correct notebook entries. Notebook structures vary across researchers when setup is not automated with standardized templates. Data export for analysis requires manual copy from notebook entries into computational tools.

Core Highlights

Notebook builder creates structured notebooks with predefined sections and folder hierarchies. Entry writer creates and updates notebook entries with formatted content and metadata. File uploader attaches experimental data to specific entries with automatic naming. Data exporter extracts notebook content into structured formats for downstream processing.

How to Use It?

Basic Usage

import requests
import hashlib
import time

class LabArchivesClient:
  BASE = (
    'https://api'
    '.labarchives.com')

  def __init__(
    self,
    access_key: str,
    secret_key: str
  ):
    self.access = (
      access_key)
    self.secret = (
      secret_key)

  def _sign(
    self,
    params: dict
  ) -> str:
    params['akid'] = (
      self.access)
    params['ts'] = str(
      int(time.time()))
    msg = '&'.join(
      f'{k}={v}'
      for k, v
      in sorted(
        params.items()))
    sig = hashlib.hmac(
      self.secret
        .encode(),
      msg.encode(),
      hashlib.sha1
    ).hexdigest()
    return sig

  def list_notebooks(
    self
  ) -> list[dict]:
    params = {
      'action':
        'list_notebooks'}
    params['sig'] = (
      self._sign(params))
    resp = requests.get(
      self.BASE,
      params=params)
    resp.raise_for_status()
    return resp.json()

  def create_entry(
    self,
    notebook_id: str,
    folder_id: str,
    title: str,
    content: str
  ) -> dict:
    params = {
      'action':
        'create_entry',
      'nbid': notebook_id,
      'fid': folder_id,
      'title': title,
      'content': content}
    params['sig'] = (
      self._sign(params))
    resp = requests.post(
      self.BASE,
      data=params)
    resp.raise_for_status()
    return resp.json()

Real-World Examples

class ExperimentLogger:
  def __init__(
    self,
    client:
      LabArchivesClient,
    notebook_id: str
  ):
    self.client = client
    self.nb_id = (
      notebook_id)

  def log_experiment(
    self,
    folder_id: str,
    title: str,
    protocol: str,
    results: dict,
    notes: str = ''
  ) -> dict:
    content = (
      f'<h2>Protocol</h2>'
      f'<p>{protocol}</p>'
      f'<h2>Results</h2>'
      f'<table>')
    for key, val\
        in results.items():
      content += (
        f'<tr><td>{key}'
        f'</td><td>{val}'
        f'</td></tr>')
    content += '</table>'
    if notes:
      content += (
        f'<h2>Notes</h2>'
        f'<p>{notes}</p>')
    return self.client\
      .create_entry(
        self.nb_id,
        folder_id,
        title,
        content)

  def log_batch(
    self,
    folder_id: str,
    experiments:
      list[dict]
  ) -> list[dict]:
    entries = []
    for exp\
        in experiments:
      entry = (
        self.log_experiment(
          folder_id,
          exp['title'],
          exp['protocol'],
          exp['results'],
          exp.get(
            'notes', '')))
      entries.append(entry)
    return entries

Advanced Tips

Create notebook templates that mirror standard experimental protocols so new experiments start with pre-structured sections reducing setup time. Implement automated file attachment pipelines that watch instrument output directories and upload results to the correct notebook entries. Use entry metadata tags consistently to enable structured search and filtering across notebooks.

When to Use It?

Use Cases

Automate creation of experiment entries from instrument output data in a standardized format. Set up structured notebook templates for a research group with consistent folder organization. Export notebook entries to feed analysis pipelines with structured experimental results.

Related Topics

Electronic lab notebooks, research data management, laboratory informatics, experiment documentation, LabArchives API, and research compliance.

Important Notes

Requirements

LabArchives account with API access credentials. Python requests library for HTTP communication. Appropriate institutional licensing for API usage.

Usage Recommendations

Do: use standardized entry templates to ensure consistent documentation across researchers. Validate uploaded file integrity with checksums before confirming attachment. Configure appropriate sharing permissions to comply with data governance policies.

Don't: store API credentials in notebook entries or unprotected configuration files. Delete notebook entries programmatically without confirmation since lab notebooks may have regulatory retention requirements. Assume API changes are backward compatible without checking version documentation.

Limitations

API availability and rate limits depend on institutional LabArchives licensing tier. File attachment size limits may prevent uploading large instrument data files directly. Rich text formatting in programmatic entries is limited to HTML subset supported by the platform.