Package: elapi
elAPIelAPI is a powerful, extensible API interface to eLabFTW. It supports serving almost all kinds of requests documented ineLabFTW API documentationwith ease. elAPI treats eLabFTW API endpoints as its
arguments.Example:Fromthe documentation:GET /users/{id}With elAPI you can do the following:$elapigetusers--id<id>InstallationSupport for installing packages withpip install --userhas been deprecated with the adoption ofPEP 688on many systems likeDebian 12.
We recommendpipxfor installing elAPI.$pipxinstallelapiOf course,pip install --user elapimight continue to work on some systems.ConfigurationelAPI needs to be configured first before we can do anything useful with it. elAPI supports a YAML configuration file in
the following locations.Current directory:./elapi.ymlUser directory:$HOME/.config/elapi.ymlRoot directory:/etc/elapi.ymlelAPI supports configuration overloading. I.e., a keyword set in root configuration file/etc/elapi.ymlcan be
overriden by setting a different value in user configuration file$HOME/.config/elapi.yml. In terms of precedence,
configuration file present in the currently active directory has the highest priority, and configuration in root
directory has the lowest.The following parameters are currently configurable, withhostandapi_tokenbeing the required fields. For testing
purposes it would be safe to store everything in the user configuration file.# elAPI configuration# Saved in `$HOME/.config/elapi.yml`host:<host API url># Example: https://demo.elabftw.net/api/v2/# Note the host URL ends with the API endpointapi_token:<token with at least read-access># You can generate an API token from eLabFTW user panel -> API keys tab.export_dir:~/Downloads/elAPIunsafe_api_token_warning:yesWe can get an overview of detected configurations.$elapishow-configIf bothhostandapi_tokenare detected, we are good to go!UsageelAPI can be invoked from the command-line.$elapi--helpGETrequestsWe can request an overview of running eLabFTW server.$elapigetinfo-Fyml# Here -F (or --format) defines the output formatWe can request a list o all active experiments and export it to aJSONfile.$elapigetexperiments--export~/Downoads/experiments.jsonPOSTrequestsWe can create a new user by the name 'John Doe'.$elapipostusers--id<userid>-d'{"firstname": "John", "lastname": "Doe", "email": "test_test@itnerd.de"}'PATCHrequestsWe can update an existing user's email address.$elapipatchusers--id<userid>-d'{"email": "new_email@itnerd.de"}'patchcommand allows us to make changes to eLabFTW server settings. E.g., we can update the time (in minutes)
after which the authentication cookie will expire.$elapipatchconfig-d'{"cookie_validity_time": 43200}'We can publish an announcement to all the members.$elapipatchconfig-d'{"announcement": "Notice: Server will be down tomorrow at midnight due to scheduled maintenance."}'Bill teamsWe can generate invoice for eLabFTW teams.$elapibill-teamsgenerate-invoiceWe may just want to have a look at the billing information without generating invoice.$elapibill-teamsinfo-FyamlWe can also export this information as aYAMLfile to the export directory defined in configuration
file (export_dir).elapibill-teamsinfo-Fyaml--exportOpen-sourceelAPI is open-source and published under AGPLv3 license. The repository is however hosted internally within
Universität Heidelberg's network. The codebase can still be accessed fromPyPI.
If you express interest in having the repository made completely public, or if you have any question, feel free
tocontact us.