s3pe for Python
Read and write data on s3.pe.gov.br, the S3 object store of the State of Pernambuco (a Garage server), or on any S3-style store. Nine verbs, no configuration beyond two environment variables, and a Rust core that signs, retries and checks every transfer.
Website: https://strategicprojects.github.io/s3pe/python/ · API reference: https://strategicprojects.github.io/s3pe/python/api/ · Português
Install
pip install s3pe # bytes, str, dict/list and files
pip install "s3pe[pandas]" # also CSV, Parquet and Excel as DataFrames
Wheels for Linux, macOS and Windows; Python 3.9 or later.
Use
import s3pe
# credentials from the environment: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
meta = s3pe.read_s3("s3://iaempe/dados/metadata.json") # dict
meta["ultimo_mes"]
df = s3pe.read_s3("series/estado/icms.csv.gz", bucket="horizonte-fiscal") # DataFrame
prev = s3pe.read_s3("previsoes/26/icms/ultima.json", bucket="horizonte-fiscal")
s3pe.write_s3(df, "s3://iaempe/nota/icms.parquet") # by extension
s3pe.upload_s3("figura1.png", "s3://iaempe/nota/") # keeps the file name
s3pe.download_s3("s3://iaempe/dados/pe_municipios.geojson", "pe.geojson")
for o in s3pe.list_s3("s3://iaempe/dados/"):
print(o.size, o.key)
s3pe.exists_s3("s3://iaempe/dados/metadata.json")
s3pe.delete_s3("s3://iaempe/nota/old.parquet")
Every call prints one line on stderr (↑ s3://iaempe/nota/icms.parquet (1.2 MB, 0.3 s)); s3pe.quiet() or S3PE_QUIET=1 silences it.
With S3PE_BUCKET=iaempe in the environment, bare keys work:
s3pe.read_s3("dados/metadata.json"). For explicit settings use a client:
s3 = s3pe.Client(endpoint="http://127.0.0.1:9003", bucket="iaempe",
access_key="GK...", secret_key="...")
s3.read("dados/metadata.json")
s3.write(df, "nota/icms.csv")
s3.list("dados/")
Formats
| Extension | read_s3 returns |
write_s3 accepts |
|---|---|---|
.json, .geojson |
dict / list |
dict, list, str, DataFrame (orient="records") |
.csv, .csv.gz, .tsv |
pandas.DataFrame |
DataFrame |
.parquet |
pandas.DataFrame |
DataFrame |
.xlsx |
pandas.DataFrame |
DataFrame |
.txt, .md, .html, .xml, .svg, ... |
str |
str |
| anything else | bytes |
bytes, file-like, pathlib.Path |
format="bytes" (or "text", "json", "csv", "parquet", "xlsx")
overrides the extension; extra keyword arguments go to the reader or writer
(s3pe.read_s3("x.csv", bucket="b", sep=";", dtype=str)). A .gz suffix
is compressed and decompressed on the way.
Configuration
| Setting | Environment | Default |
|---|---|---|
| endpoint | S3PE_ENDPOINT, then AWS_ENDPOINT_URL |
https://s3.pe.gov.br |
| region | AWS_REGION, then AWS_DEFAULT_REGION |
us-east-1 |
| credentials | AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY (AWS_SESSION_TOKEN) |
required |
| bucket | S3PE_BUCKET |
none: use s3://bucket/key or bucket= |
Errors
All errors derive from s3pe.S3Error: NotFoundError (404),
AccessDeniedError (403), HttpError (other statuses, with .status,
.code, .message), TransportError (network, after retries),
ConfigError (missing credentials or bucket) and IntegrityError (the
bytes that arrived differ from the bytes sent). exists_s3 and head_s3
turn 404 into False / None.
What happens in every call
Dependable by default
- SigV4 signatures over the real SHA-256 of the payload, path-style URLs.
- Connection failures and HTTP 429/500/502/503/504 are retried twice (1 s, then 2 s). Other errors are raised at once, typed.
- After an upload the server's ETag is compared with the local MD5; after a
download the byte count with
Content-Lengthand, when the ETag is an MD5, the MD5 of what arrived. - Files are streamed to a
.s3pe-partfile and renamed when complete. - The Rust core releases the GIL during transfers.
Architecture
Em português
s3pe lê e grava dados no s3.pe.gov.br (o Garage da plataforma do
Condepe/Fidem) com nove verbos: read_s3, write_s3, download_s3,
upload_s3, list_s3, delete_s3, exists_s3, head_s3, buckets_s3.
As credenciais vêm do ambiente (AWS_ACCESS_KEY_ID,
AWS_SECRET_ACCESS_KEY); o formato vem da extensão do arquivo. Cada
transferência imprime uma linha no terminal; s3pe.quiet() silencia.
The family
The same package exists for R (install.packages("s3pe")), Rust
(cargo add s3pe, with the s3pe command line) and Go
(go get github.com/StrategicProjects/s3pe), all in
one repository.
Metadata
Release files for s3pe 0.1.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 | |
|---|---|---|---|---|
| s3pe-0.1.0.tar.gz | 51.0 kB | With provenance | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| s3pe-0.1.0-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details |
| s3pe-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| s3pe-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| s3pe-0.1.0-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details |
| s3pe-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl | CPython 3.9 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 6.4 MB
Release files / s3pe-0.1.0.tar.gz
| Download URL | s3pe-0.1.0.tar.gz |
|---|---|
| Size | 51.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
628b8ca8714d4074b61b86f34c0cbb4cab718ed322c8502f00945f9d303f3ca7
|
|
BLAKE2b-256 checksum How to use checksums |
913e76a9692e4e2859f19e2c424b616541e9653773723989d0f7c490ef0037f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.
Transparency logRelease files / s3pe-0.1.0-cp39-abi3-win_amd64.whl
| Download URL | s3pe-0.1.0-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
994541550a6d69555bc7deb6739b4f92e113207bd4b4d970ced61290f1fdce57
|
|
BLAKE2b-256 checksum How to use checksums |
310993029c6aa2d59a0adedfb0f54912c7acad853cf170e83995bfa0bf755357
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.
Transparency logRelease files / s3pe-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | s3pe-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
d5e74fe97acdfa2f44fd78ed4ac21eeaa6b98f6273cdfcf72ff5054117f33bae
|
|
BLAKE2b-256 checksum How to use checksums |
050857ae1113702ded1a8c9b7d61a7962f2a588e366dde597d8163fce5565fba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.
Transparency logRelease files / s3pe-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | s3pe-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
f581036279d165586846f3cef7f86db25f2664d31ca355b48858f0260c761b7c
|
|
BLAKE2b-256 checksum How to use checksums |
c80eaed4c76a44332311df5cf7ab4247b1876b166d004bfb79d25cffcd66a6ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.
Transparency logRelease files / s3pe-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | s3pe-0.1.0-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
41e01ec0017a652aae476e0ab39f6ba18d4deb6e9719c65bab3c2559d12fc937
|
|
BLAKE2b-256 checksum How to use checksums |
bc7c092e39c807ed62ea66836ce27cefab0f23ca864a5c3a3866aa8fa9b84cce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.
Transparency logRelease files / s3pe-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | s3pe-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.9 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
c34962c8420762254a1559b1c33c444cbf9cb4e585400b6911f97dca06f5a2a4
|
|
BLAKE2b-256 checksum How to use checksums |
f9b660ae353581a40fdb30c5e239dcf35f78fc58dda3c24d03367e9b8679ad7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.
Transparency logSecurity for s3pe 0.1.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.
Full provenance
All 6 files in this release have been uploaded with provenance metadata.
Attestation for s3pe-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.
Transparency logA 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.