LogicVein API Client
A Python client for interacting with the LogicVein API.
Installation
From PyPI:
pip install lvi-api-client
From TestPyPI (pre-release / testing):
pip install \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple/ \
lvi-api-client
See PUBLISHING.md for instructions on publishing new releases.
Usage
from logicvein import LogicVeinAPIClient
client = LogicVeinAPIClient(host="your-lvi-server", api_token="your-token")
devices = client.search_devices_in_network()
Settings not passed as arguments are read from LVI_HOST, LVI_API_TOKEN (or LVI_USERNAME
and LVI_PASSWORD), LVI_VERIFY_SSL and LVI_TIMEOUT; ignore_env_vars=True reads none of
them.
Logging in
With an API token there is no login: the token goes in a header of every call. With a username
and password and no token, the client logs in as it is created, and authenticate() logs in
again. A login that does not work raises:
LogicVeinAuthenticationError: the server rejected the username or password (HTTP 401). It hashostandusername.LogicVeinConnectionError: the server could not be reached or did not answer as it should: connection refused, host name not found, TLS failure, timeout, a redirect, a request for a one-time code, no/authlogin, a success that leaves the session with no cookie, any other HTTP error status, or a CA bundle path that does not exist. It hashost,reasonand, if the server answered,status_code.
from logicvein import LogicVeinAPIClient, LogicVeinAuthenticationError, LogicVeinConnectionError
try:
client = LogicVeinAPIClient(host="your-lvi-server", username="your-user", password="your-password")
except LogicVeinAuthenticationError as error:
print(f"Wrong username or password: {error}")
except LogicVeinConnectionError as error:
print(f"Server problem: {error}")
Neither error holds the password, the request or its URL, so both are safe to print and log.
The password login is a POST to https://<host>/auth with the username and password in a form
body. The URL has no query string, so the password is not in the request line that servers and
reverse proxies commonly write to their access logs. The response authenticate() returns
holds the login request, and so the password, in request.body: do not log or print that.
Four answers to the login are a LogicVeinConnectionError whose reason says what they mean:
| Answer | Meaning | What to do |
|---|---|---|
| HTTP 202 | The account needs a one-time code, which the client cannot supply. | Use an API token. |
| HTTP 404 or 405 | The server has no /auth login. The client has no other password login. |
Use an API token. |
| Any HTTP 3xx | The login was redirected. The client never follows a login's redirect, because that can send the password to another address. | Set host to the name the server itself answers on. |
| HTTP 2xx (not 202) and no cookie in the session | A cookie login with no cookie logged nothing in: the answer came from a proxy's page or a host that is not a LogicVein server. | Check host and any proxy in front of the server. |
authenticate() passes extra keyword arguments on to the session's post(), except the ones
the login sets itself, which are a TypeError: allow_redirects, data, files, headers,
json, params and timeout.
A redirect whose Location header cannot be parsed is a LogicVeinConnectionError too, but
without the status: requests fails on it before the client sees the answer, so the reason
names that failure, as in request failed (ValueError), and status_code is None.
The login is judged by its HTTP status and by the session's cookies. Any 2xx but 202 is taken as
a login if the session holds a cookie afterwards, and raises if it holds none. The session's
cookie jar is what is checked, not the answer's Set-Cookie header: the server answers a second
login on a session that is already logged in without a new cookie, and that login returns. The
check is a necessary condition only. Any cookie in the jar counts: its name, the host it is for
and whether it has expired are not checked. A proxy's page that sets a cookie of its own passes,
and so does a session that already held a cookie from somewhere else, so test_connection() is
still what tells a LogicVein server from a host that is not one.
An API token needs no login and works where a password login does not: prefer one where you can.
TLS verification
The client verifies the server's TLS certificate by default. For a server whose certificate
comes from a private CA, keep verification on and point REQUESTS_CA_BUNDLE at the CA's
certificate. verify=False, or LVI_VERIFY_SSL=false, turns verification off, and the API
token or password is then sent to whichever server answers. LVI_VERIFY_SSL accepts
true/false, 1/0, yes/no and on/off in any case; unset or empty means verify, and anything else
is an error.
Metadata
Release files for lvi-api-client 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lvi_api_client-0.7.0.tar.gz | 99.9 kB | Without provenance | Details for lvi_api_client-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lvi_api_client-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for lvi_api_client-0.7.0-py3-none-any.whl |
Total release size: 149.1 kB
Release files / lvi_api_client-0.7.0.tar.gz
| Download URL | lvi_api_client-0.7.0.tar.gz |
|---|---|
| Size | 99.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ba77a2263a1c9093bd9322d9867bba3b996db7dffb939c6946d919e59141b104
|
|
BLAKE2b-256 checksum How to use checksums |
5dc0cb9b2b301e478eb93347a594a05f42b25e2aee9eeafb728abb31dc2ebae4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.10
|
Release files / lvi_api_client-0.7.0-py3-none-any.whl
| Download URL | lvi_api_client-0.7.0-py3-none-any.whl |
|---|---|
| Size | 49.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7c09593ee71b805f7df3b853fa7e10f915d7e44360cfc10f4fb809e4a1d2c06d
|
|
BLAKE2b-256 checksum How to use checksums |
fccb3a86fc4b70b0dbe7c15775e5984c4f6f81b368050a48406a85f2fa9f7681
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.10
|
Security for lvi-api-client 0.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.