elabapi package#
Submodules#
elabapi.elabapi module#
- class elabapi.elabapi.ELabApi#
Bases:
object
Represents a connection to the root ELabFTW API.
Authenticates via API key provided at init time (though this could be changed) and provides simple interfaces to various API endpoints. Currently mostly read-only
- __init__(api_base_url, api_key)#
- api_req(function, endpoint, limit=None, offset=None, **kwargs)#
Make a request to the ELabFTW API.
A helper method that wraps a function from
requests
, but adds a local certificate authority chain to validate any custom certificates. Will automatically retry on 500 errors using a strategy suggested here: https://stackoverflow.com/a/35636367.- Parameters:
function (str) – The function from the
requests
library to use (e.g.'GET'
,'POST'
,'PATCH'
, etc.)endpoint (str) – The API endpoint to fetch (will be appended to
ELAB_URL
environment variable)limit (int | Literal['all'] | None) – The number of records to return from the API request. If
'all'
(the default for ‘GET’ requests), the API call will be repeated until no more records are foundoffset (int | None) – Used together with
limit
, this is the pagination offset value to send to the API. Note, for bothlimit
andoffset
, any value provided as an argument to this function will override any value provided via URL parameters in theparams
kwarg. Any value foroffset
will be ignored iflimit
is'all'
.**kwargs (dict | None) – Other keyword arguments are passed along to the
fn
- Returns:
A list of dictionaries, one for each JSON object returned by the API
- Return type:
r
- Raises:
ValueError – If multiple methods of authentication are provided to the function
- export_experiment(experiment_id, output_filename=None, format='pdf', overwrite=False)#
Export and download an experiment in the specified format.
Allowed formats are ‘csv’, ‘eln’, ‘json’, ‘qrpdf’, ‘qrpng’, ‘pdf’, ‘pdfa’, ‘zip’, or ‘zipa’. If no filename/path is provided, a filename in the current directory will be autogenerated and returned as a
Path
object. Theoverwrite
option controls whether a file that already exists on disk will be overwritten.
- get_api_keys()#
- get_config()#
- get_experiments_by_category(category, **kwargs)#
Get experiments matching a given category
- class elabapi.elabapi.TeamApi#
Bases:
ELabApi
Represents a single ELabFTW Team by communicating with the REST API.
Provides methods to get information about a team and its content. Also provides a few static methods to get information about other teams. Currently is read-only.
- __init__(api_base_url, api_key, team_id='current')#
- get_experiments_categories()#
Get the experiments categories of a team
https://doc.elabftw.net/api/v2/#/Experiments%20categories/read-team-experiments-categories
- get_experiments_category(cat_id)#
Get a single experiments category of a team
https://doc.elabftw.net/api/v2/#/Experiments%20categories/read-team-experiments-categories
- get_experiments_category_by_name(cat_name)#
Get a single experiments category of a team by name
https://doc.elabftw.net/api/v2/#/Experiments%20categories/read-team-experiments-categories
- get_experiments_status(status_id)#
Get a single experiments status of a team
https://doc.elabftw.net/api/v2/#/Experiments%20status/read-team-one-expstatus
- get_experiments_status_by_title(title)#
Get a single experiments status of a team by its name
- get_experiments_statuses()#
Get the experiments statuses of a team
https://doc.elabftw.net/api/v2/#/Experiments%20status/read-team-experiments-status
- get_items_status(status_id)#
Get a single items status of a team
https://doc.elabftw.net/api/v2/#/Resources%20status/read-team-one-resstatus
- get_items_status_by_title(title)#
Get a single items status of a team by its name
- get_items_statuses()#
Get the items statuses of a team
https://doc.elabftw.net/api/v2/#/Resources%20status/read-team-items-status
- get_team(id='current')#
Get a team definition by id
- get_team_tag(id)#
Get a specific tag defined for this team
https://doc.elabftw.net/api/v2/#/Team%20tags/read-team_tag
- Return type:
Dict | None
- get_team_tags()#
Get the tags defined for this team
- get_teams()#
Get all teams from the API (always refreshes from API and adds to cache)