lca-data-interface
List and download LCA databases from openLCA Nexus and LCA Collaboration Servers into a hash-checked cache.
pip install lca-data-interface
LCA Collaboration Server
CommonsServer reads one server's public release history and downloads a released commit. It needs no account, and its default server is the Federal LCA Commons at https://www.lcacommons.gov/lca-collaboration; CommonsServer(base) names another address.
releases(group, name) answers that repository's released commits, in the order the server serves them, each a Release carrying version, commit and released_at, the last a UTC datetime built from the server's millisecond timestamp. download(group, name, commit) answers a Downloaded carrying the path of the file in the cache, its size in bytes and its sha256 digest.
from lca_data_interface import CommonsServer
server = CommonsServer()
releases = server.releases("Federal_LCA_Commons", "IPCC_GWP")
newest = releases[0]
downloaded = server.download("Federal_LCA_Commons", "IPCC_GWP", newest.commit)
print(newest.version, newest.released_at)
print(downloaded.path, downloaded.size, downloaded.sha256)
openLCA Nexus
NexusSession(account, password, token=None, base="https://nexus.openlca.org") is a logged-in account, used as a context manager: entering it logs in once, and leaving it logs out. The token is the second factor when the account carries one. NexusSession.from_environment() takes the account from NEXUS_USERNAME, the password from NEXUS_PASSWORD and the second factor from NEXUS_TOKEN. A session prints as its server and its account, never its password or its token.
catalog()answers every database the account may download, read from the server once per session: a list ofDatabasewithname,typeandpacks, eachPackwithuuid,name,licence_fileandversions, eachPackVersionwithnumber,release_noteandfiles, eachPackFilewithdatafile_idandfile_format.pack(uuid)answers the catalog's pack with that uuid; a uuid the catalog lacks is aNotInCatalog.licence(pack)answers thePathof the pack's terms file in the cache, downloading it once; a pack that carries no terms is aNotInCatalog.download(pack, version=..., file_format=..., accept_licence=False)answers one file of a pack version at a format as aDownloaded; a pack that carries terms needsaccept_licence=True.
from lca_data_interface import NexusSession
with NexusSession.from_environment() as session:
for database in session.catalog():
print(database.name, database.type, len(database.packs))
pack = session.pack("c068d31e-7268-4926-8720-b8f9b4648492")
terms = session.licence(pack)
got = session.download(pack, version=1, file_format="ecoSpold1", accept_licence=True)
print(terms, got.path, got.size, got.sha256)
The cache
cache_dir() answers the cache root: the directory LCA_DATA_INTERFACE_CACHE names, or the platform's user cache directory for this package, ~/.cache/lca-data-interface on Linux. One directory under it holds each kind of download, the file under the name the server serves it with:
commons/<host>/<group>/<name>/<commit>/<file>
nexus/<pack uuid>/licence/<file>
nexus/<pack uuid>/<version>/<format>/<file>
A body streams into a .part file there and is renamed once its bytes reach the length its answer announces, so a body that stops short is a ShortDownload and no file lands under the served name. sha256.txt beside it records the digest and the name of the bytes that landed, and a later call answers the cached file only while its bytes still hash to that digest; anything else is downloaded again.
Errors
Every error derives from LcaDataInterfaceError, and each names in its message what a caller can act on.
| Error | Raised when |
|---|---|
CredentialsMissing(variables) |
from_environment finds NEXUS_USERNAME or NEXUS_PASSWORD unset |
LoginRefused(account, status) |
the login answers 401 or 403; the password is never named |
TokenRequired |
the login answer asks for a second factor, so NEXUS_TOKEN is needed |
NotInCatalog(uuid, wanted, available) |
the catalog holds no such pack, version, format or licence file |
LicenceNotAccepted(uuid, licence_file) |
a pack carrying terms is downloaded without accept_licence=True |
NotOnServer(repository, commit, detail) |
a Collaboration Server answers 404 for the repository or the commit |
MissingField(call, field) |
an answer lacks a field the client reads, including the served file name of a download |
ShortDownload(name, expected, received) |
a body ended before the length its answer announced |
ServiceError(call, status, detail) |
a status of 400 or more, an unreachable host, a body that is not JSON, or a served name the cache cannot hold |
Tests
uv run pytest runs the suite against a loopback server and a temporary cache, with no network. The two checks in tests/test_live.py reach both services and run only with LCA_DATA_INTERFACE_LIVE=1 and -m live.
Licence
Apache-2.0. Copyright 2026 Carlos Gaete-Morales; see LICENSE and NOTICE.
Metadata
Release files for lca-data-interface 0.1.1
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 | |
|---|---|---|---|---|
| lca_data_interface-0.1.1.tar.gz | 53.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lca_data_interface-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 70.3 kB
Release files / lca_data_interface-0.1.1.tar.gz
| Download URL | lca_data_interface-0.1.1.tar.gz |
|---|---|
| Size | 53.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2baa9d2913770c205aeee630443f00cca8c27a4fe6ec85538ff043c7ce2937f3
|
|
BLAKE2b-256 checksum How to use checksums |
c3d33d5a147d8fded54c6c57d68267d7e721211724ecd5266a8eee63a596d995
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Release files / lca_data_interface-0.1.1-py3-none-any.whl
| Download URL | lca_data_interface-0.1.1-py3-none-any.whl |
|---|---|
| Size | 17.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ea6d91cc6aa1feffd20c8c4d1a122b95c4de0593327ea25896266db35c549c88
|
|
BLAKE2b-256 checksum How to use checksums |
1364a3b3e86f572d8aaad52e9ae51c4c587485f7bda7f0973e9c85100df82929
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Security for lca-data-interface 0.1.1
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.