Skip to main content

rspace-client-python

PyPI version Python versions License: Apache 2.0

The official Python client for the RSpace ELN and Inventory APIs. It wraps the raw REST endpoints in a Pythonic interface so you can create and search documents, manage Inventory samples and containers, export your work, and read/write Gallery and Inventory files — from a script, a Jupyter notebook, or your own application.

Don't have an RSpace account? Sign up for free at community.researchspace.com, or run RSpace locally in Docker. You'll need an API key from your profile page to use this client. This client is especially easy to use from Jupyter notebooks — see the round-trip data analysis video for a walkthrough.

Quick start

pip install rspace-client
import os
from rspace_client.inv import inv
from rspace_client.eln import eln

inv_cli = inv.InventoryClient(os.getenv("RSPACE_URL"), os.getenv("RSPACE_API_KEY"))
eln_cli = eln.ELNClient(os.getenv("RSPACE_URL"), os.getenv("RSPACE_API_KEY"))

samples = inv_cli.list_samples()
print(f"There are {samples['totalHits']} samples")

print(eln_cli.get_status())

Set RSPACE_URL and RSPACE_API_KEY as environment variables first:

bash> export RSPACE_URL=https://myrspace.com
bash> export RSPACE_API_KEY=abcdefgh...

Full REST API reference is served by your own RSpace instance at https://<YOUR_RSPACE_DOMAIN>/public/apiDocs (e.g. https://community.researchspace.com/public/apiDocs).

Core features

Feature What it does
Documents & basic/advanced search Create, read, and update documents; search by tag, name, form, or date; page through results
Inventory: samples, subsamples, containers Create and manage samples, split/duplicate subsamples, organise items into containers
Instruments & Instrument Templates (new in 2.7.0, RSpace 2.24) Create, update, and manage Inventory instruments and instrument templates
Export Async export of a user's or group's work (or specific documents/notebooks/folders) to HTML or XML, with progress polling
PyFilesystem access GalleryFilesystem and InventoryAttachmentFilesystem implement the PyFilesystem API for Gallery files and Inventory attachments
Notebook / Jupyter / R interop (notebook_sync) Helpers for round-tripping data between RSpace notebook entries and Jupyter or R workflows
Activity / audit trail Query "who did what, when" for a record or across a date range
Forms Create, publish, share, and list custom forms; create documents from them

Full worked examples for every feature above are in the Usage Guide.

Compatibility & limitations

Python 3.9 or later (see pyproject.toml)
RSpace ELN API 1.69 or later
RSpace Inventory API 1.73  or later

This client doesn't cover 100% of the REST API. It's a convenience layer, and some capabilities are only exposed through the web application or the raw REST endpoints — for example, sharing a notebook into the Shared Folder currently has to be done in the UI (see Creating a Folder / Notebook). If something you need isn't covered here, check the full REST API docs at <YOUR_RSPACE_DOMAIN>/public/apiDocs before assuming it isn't possible.

Examples & notebooks

Runnable scripts in examples/ (run with python3 examples/<script>.py $RSPACE_URL $RSPACE_API_KEY from that folder):

Script What it demonstrates
status.py Check RSpace server status and API version
create_document.py Create a document, upload a file, and link the file into it
create_folder_and_notebook.py Create, retrieve, and delete folders and notebooks
create_form.py Create a custom form and list/page through published forms
create_sample.py Create an Inventory sample, including one with barcodes
download_attachments.py Download file attachments from a document
export_records.py Export a selection of documents/notebooks/folders
freezer.py Build a freezer → shelf → rack → tray → box container hierarchy in Inventory
get_activity.py Query the audit trail for a document, or for recent create/edit activity
import_directory.py Import a local directory of files into RSpace
import_word_file.py Import a Word (.docx) file as an RSpace document
paging_through_results.py Page through document search results via HATEOAS links
paging_through_users.py Page through users and batch-process accounts (admin use case)
search_documents_by_form.py Find and export documents created from a specific form
share_documents.py Share a newly created document with a group
tree_upload.py Bulk-import a converted eCAT export (folders of .docx/images) with resume/log support

Interactive notebooks in jupyter_notebooks/:

Notebook What it demonstrates
rspace_demo.ipynb Full round-trip workflow: pull data from RSpace, analyse it, write results back
rspace-demo-kaggle-v11.ipynb The same round-trip workflow using a Kaggle dataset — matches the walkthrough video
samples_to_lom.ipynb Bulk-creates a notebook entry per sample assay, each with a List of Materials linking back to the sample's physical location

(proteins.csv and temp_data.csv in the same folder are sample data used by these notebooks.)

Testing

CI (.github/workflows/codeql-and-tests.yml) runs unit tests across supported Python versions, then integration tests against a real RSpace instance: it builds rspace-web from source and starts it with a freshly seeded database (no Docker image, no browser automation), logs in once to initialize the built-in test account, then runs the suite against it.

To run tests locally:

# unit tests only
poetry run pytest -m "not integration"

# integration tests, against your own RSpace instance
export RSPACE_URL=https://<your-rspace-domain>
export RSPACE_API_KEY=<your-api-key>
poetry run pytest -m integration

Community projects

See what others have built on top of RSpace and RSpace Python SDK on the Community Projects page. Built something with this client? Share it in an office hour or open a PR to add it.

Contributing

Contributions of all sizes are welcome — from a typo fix to a new feature. See CONTRIBUTING.md for how to get started, DEVELOPING.md for local setup and running tests, and the Guide to the RSpace Project for the project's wider vision and governance.

License & security

Apache 2.0 — see LICENSE. Security policy is maintained org-wide at rspace-os/.github.

Download files

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

Source Distribution

rspace_client-2.7.2.tar.gz (60.2 kB view details)

Uploaded Source

Built Distribution

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

rspace_client-2.7.2-py3-none-any.whl (65.6 kB view details)

Uploaded Python 3

File details

Details for the file rspace_client-2.7.2.tar.gz.

File metadata

  • Download URL: rspace_client-2.7.2.tar.gz
  • Upload date:
  • Size: 60.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for rspace_client-2.7.2.tar.gz
Algorithm Hash digest
SHA256 5268117a2c3e06bd14ef5beb46c2b4e7440f03a44063cb88391df1c5750a6255
MD5 608a36ec9f6461a6d20d9e18b0681d57
BLAKE2b-256 6e0764e74b7645e49b058bdeb12574bef74a7d2ae9257012448df06082e29d2b

See more details on using hashes here.

File details

Details for the file rspace_client-2.7.2-py3-none-any.whl.

File metadata

  • Download URL: rspace_client-2.7.2-py3-none-any.whl
  • Upload date:
  • Size: 65.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for rspace_client-2.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8d63f74604c9e6d430c259321b3c1f52cdf924a5d5233aa771d1e87783867aaf
MD5 e73afbf1517ea8be2278d61245709d70
BLAKE2b-256 5402f85db27fbc39d9f50d3c265be62f6a762d78aa2cdc188e4c351c4af95551

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.7.2 This release

2 files

2.7.0

2 files

2.6.2

2 files

2.6.1

2 files

2.6.0

2 files

2.5.0

2 files

2.4.1

2 files

2.4.0

2 files

2.3.3

2 files

2.3.2

2 files

2.3.1

2 files

2.3.0

2 files

2.2.2

2 files

2.2.1

2 files

2.2.0

2 files

2.1.0

2 files

2.0.2

2 files

2.0.1

2 files

2.0.0

2 files

1.6.0

2 files

1.5.0

2 files

1.4.0

3 files

1.3.2

3 files

1.3.1

3 files

1.2.0

3 files

0.0.2

1 file

0.0.1

1 file

Supported by

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