JsonBank.io Python SDK
The official repository for the jsonbank.io Python SDK.
Documentation | PyPI | GitHub
Installation
pip install jsonbank
Usage
The client can be initialized with or without API keys. Keys are only required to access protected/private documents.
from jsonbank import JsonBank
# Initialize without keys (public content only)
jsb = JsonBank()
# Get json content of a public file
data = jsb.get_content("jsonbank/sdk-test/index")
print(data["author"]) # -> "jsonbank"
# Get a json file from GitHub (default branch)
pkg = jsb.get_github_content("jsonbankio/jsonbank-js/package.json")
# Get document metadata (typed, attribute access)
meta = jsb.get_document_meta("jsonbank/sdk-test/index")
print(meta.id, meta.content_size.number)
Authenticated requests
from jsonbank import JsonBank
# Flat keyword arguments are the primary style
jsb = JsonBank(public_key="JSB_PUBLIC_KEY", private_key="JSB_PRIVATE_KEY")
# Optionally verify the keys
auth = jsb.authenticate()
print("Authenticated as:", auth.username)
# Read your own content
content = jsb.get_own_content("sdk-test/index.json")
JsonBank also works as a context manager, which closes the underlying HTTP
session on exit:
with JsonBank(public_key="...", private_key="...") as jsb:
jsb.update_own_document("sdk-test/index.json", {"updated": True})
Flexible inputs
Write methods accept keyword arguments, a plain dict, or a typed body object,
whichever you prefer. content may be a JSON string or any JSON-serializable
object (it is serialized for you):
from jsonbank import JsonBank, CreateDocumentBody
jsb = JsonBank(public_key="...", private_key="...")
# keyword arguments
jsb.create_document(name="movie.json", project="sdk-test", content={"title": "Avatar"})
# a plain dict
jsb.create_document({"name": "movie.json", "project": "sdk-test", "content": "{}"})
# a typed body
jsb.create_document(CreateDocumentBody(name="movie.json", project="sdk-test", content={}))
Errors
Failed requests raise JsonBankError, which carries a code and message:
from jsonbank import JsonBank, JsonBankError
jsb = JsonBank()
try:
jsb.get_content("does/not/exist")
except JsonBankError as err:
print(err.code, "-", err.message) # e.g. "notFound - ..."
Configuration
Keys can be supplied in whichever form is convenient:
from jsonbank import JsonBank, Keys, InitConfig
JsonBank(public_key="...", private_key="...") # flat kwargs (recommended)
JsonBank(keys={"public": "...", "private": "..."}) # dict (also accepts pub/prv)
JsonBank(keys=Keys(public="...", private="...")) # typed Keys
JsonBank(config=InitConfig(host="...", keys=Keys(...))) # full InitConfig
Testing
Create an .env file in the root of the project and add the following variables:
JSB_HOST="https://api.jsonbank.io"
JSB_PUBLIC_KEY="your public key"
JSB_PRIVATE_KEY="your private key"
Install the dev dependencies and run the tests:
pip install -e ".[dev]"
pytest
The offline helper tests need neither network nor keys:
pytest tests/test_functions.py
Metadata
Release files for jsonbank 0.1.2
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 |
|---|---|---|---|---|
| jsonbank-0.1.2.tar.gz | 24.2 kB | Without provenance | Details for jsonbank-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jsonbank-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for jsonbank-0.1.2-py3-none-any.whl |
Total release size: 37.8 kB
Release files / jsonbank-0.1.2.tar.gz
| Download URL | jsonbank-0.1.2.tar.gz |
|---|---|
| Size | 24.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2575ce6d803c9662c93798565f740963e36b39ad57e5f5b798ae9593f12d93eb
|
|
BLAKE2b-256 checksum How to use checksums |
5d43f9b3b24b282a9ef728690bae19bcceea543adbfed0174b59bcb582e14435
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / jsonbank-0.1.2-py3-none-any.whl
| Download URL | jsonbank-0.1.2-py3-none-any.whl |
|---|---|
| Size | 13.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e4b62a103b9a1393d9515523ee2004b70765781cb134e1994662fe6c87c9fd85
|
|
BLAKE2b-256 checksum How to use checksums |
2503022b50741dbc287a3c01569e63eeaf2de5681ae06e46e7970b71d562e39d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for jsonbank 0.1.2
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.