Python library for LORIOT API interactions: authentication, resource retrieval, and CSV helpers.
Created by LORIOT AG. Licensed under the Apache License 2.0.
- Python >= 3.7
pip(and optionallybuildto create distributable packages)
Create and activate a virtual environment (recommended):
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activateInstall directly from a checkout:
pip install .Editable install for development:
pip install -e .Build distributable packages (wheel and sdist are written to dist/):
pip install build
python -m build
pip install dist/loriot-*.whlInstall straight from the repository:
pip install "git+https://bitbucket.org/loriot/loriot-python-library.git"Verify the installation:
python -c "import loriot; print(loriot.getRequest)"getRequest(host, api, session)- HTTP GETpostRequest(host, params, api, session)- HTTP POSTputRequest(host, params, api, session)- HTTP PUTdeleteRequest(host, api, session)- HTTP DELETE
loginAdme(host, user, password)- Admin loginloginImpersonate(host, userid, adminSessionId)- Impersonate userlogin2FA(host, passcode, session)- 2FA loginis2FAEnabled(response)- Check 2FA requirementgetInstanceType(server, session)- Get server typegetResourcesFromPages(customerObj, session, api, apiFieldName)- Fetch all pages of a paginated endpoint (customerObjneeds aserverkey)getAccounts,getGateways,getOrganizations,getActiveDevicesCountLastMonth,getInOutFrames,getServerRelease- Resource retrieval (paginated, multithreaded)
loadNetworksFromCSV(csvPath)- Load networks from CSVloadGatewaysFromCSV(csvPath)- Load gateways from CSVloadDevicesFromCSV(csvPath)- Load devices from CSVloadCSV(csvPath, field_mappings, resource_type)- Generic CSV loader
debugPrint(message, color)- Print debug messages when DEBUG is enabledset_debug(enabled)- Enable/disable debug mode
from loriot import loginAdme, getRequest
from loriot.csv_utils import loadGatewaysFromCSV
# Login
login_resp = loginAdme('server.loriot.io', 'user@example.com', 'password')
session = login_resp['session']
# Make API call
data = getRequest('server.loriot.io', '/1/nwk/gateways', session)
# Load gateways from CSV
gateways = loadGatewaysFromCSV('gateways.csv')Call loriot.set_debug(True) to enable debug output.
Apache License, Version 2.0. See LICENSE.