This package is a simple Python wrapper for the HTTP API of SampleDB, a web-based sample and measurement metadata database developed at PGI and JCNS.
This Python wrapper may also be used e.g. in Matlab and Julia.
User installation using pip:
pip install --upgrade --user sampledbapi
System installation using pip:
pip install --upgrade sampledbapi
from sampledbapi import *
server_address = ...
api_key = ...
# Authentication
authenticate(server_address, api_key)
# Simple queries
print(actions.get_list())
print(objects.get(123))
print(instruments.get_list())
# Advanced search
print(objects.get_list("material == \"Sb\""))
More examples for usage in Python can be found here.
You need a working installation of Python and sampledbapi
installed for this to work.
Some type conversions are needed (e.g. to pass integers).
% Authentication
py.sampledbapi.authenticate("https://...", "your_api_key")
% Simple queries
print(instruments.get_list())
py.sampledbapi.objects.get(py.int(123))
py.sampledbapi.instruments.get_list())
% Advanced search
l = py.sampledbapi.objects.get_list('material == "Sb"')
obj = l{1}
obj.data
In an analogous way, the Python examples shown here can be used in Matlab.
The current API documentation can be found here. Further details on the input and output of each function (usually JSON) can be found in the documentation of the HTTP API.
The full HTTP API of SampleDB is supported. This includes
- Authentication
- Objects
- Reading a list of all objects
- Getting the current object version
- Reading an object version
- Creating a new object
- Updating an object / Creating a new object version
- Getting related objects
- Object permissions
- Reading whether an object is public
- Setting whether an object is public
- Reading all users' permissions
- Reading a user's permissions
- Setting a user's permissions
- Reading all groups' permissions
- Reading a group's permissions
- Setting a group's permissions
- Reading all project groups' permissions
- Reading a project group's permissions
- Setting a project group's permissions
- Instruments
- Reading a list of all instruments
- Reading an instrument
- Instrument log entries
- Reading a list of all log entries for an instrument
- Reading an instrument log entry
- Reading a list of all log categories for an instrument
- Reading an instrument log category
- Reading a list of all file attachments for a log entry
- Reading a file attachment for a log entry
- Reading a list of all object attachments for a log entry
- Reading an object attachment for a log entry
- Creating an instrument log entry
- Actions
- Reading a list of all actions
- Reading an action
- Action types
- Reading a list of all action types
- Reading an action type
- Users
- Reading a list of all users
- Reading a user
- Reading the current user
- Locations
- Reading a list of all locations
- Reading a location
- Reading a list of an object's locations
- Reading an object's location
- Location types
- Reading a list of all location types
- Reading a location type
- Files
- Reading a list of an object's files
- Reading information for a file
- Uploading a file
- Posting a link
- Comments
- Reading a list of an object’s comments
- Reading information for a comment
- Posting a comment