Skip to main content

jsonbox-python

Python wrapper for https://jsonbox.io (with support for V2 features)

PyPI version License: MIT Downloads Downloads CircleCI

Installation

pip install jsonbox

Usage

from jsonbox import JsonBox

# generate unique box id
MY_BOX_ID = JsonBox.get_new_box_id()

# create instance
jb = JsonBox()

data = [{"name": "first", "age": 25}, {"name": "second", "age": 19}]

# write data
result = jb.write(data, MY_BOX_ID)

# get record id of written data
record_ids = jb.get_record_id(result)

# read record
print(jb.read(MY_BOX_ID, record_ids[0]))

# read all records in box
print(jb.read(MY_BOX_ID))

# get metadata for box
print(jb.get_meta(MY_BOX_ID))

# read all records in box with sort
print(jb.read(MY_BOX_ID, sort_by="age"))

# read records in box with sort matching query (see documentation for syntax)
print(jb.read(MY_BOX_ID, query="name:firs*"))
print(jb.read(MY_BOX_ID, query="age:=19"))

# read records with limit
print(jb.read(MY_BOX_ID, limit=1))

# read records with skip
print(jb.read(MY_BOX_ID, skip=1))

# update data
data = {"name": "Bob", "age": 23}
jb.update(data, MY_BOX_ID, record_ids[0])

# read updated data
print(jb.read(MY_BOX_ID))
print(jb.read(MY_BOX_ID, record_ids[0]))

# delete records matching to query
print(jb.delete(MY_BOX_ID, query="age:=23"))

# delete records
jb.delete(MY_BOX_ID, record_ids[1])

# write to a private box
MY_PRIVATE_BOX_ID = JsonBox.get_new_box_id()
api_key = jb.get_new_api_key()
result = jb.write(data, MY_PRIVATE_BOX_ID, api_key=api_key)
record_id = jb.get_record_id(result)

# update a private box
data = {"name": "David", "age": 35}
jb.update(data, MY_PRIVATE_BOX_ID, record_id, api_key=api_key)

# delete a private box
jb.delete(MY_PRIVATE_BOX_ID, record_id, api_key=api_key)

Private Box

Add api_key to write/update/delete as shown above.
read is always accessible, even with out an api_key.
A valid and unique api_key can be generated using get_new_api_key()

Query Params

As supported (and documented) by https://github.com/vasanthv/jsonbox

You can query by constructing a query string and passing it to the query parameter:

name:arya%20stark,age:>13

The above sample will look for the name arya stark and age greater than 13.

You can filter on Number, String & Boolean values only.

Filters for Numeric values.

Sample
To filter values greater than or less than a specific value age:>10 or age:<10
To filter values greater (or less) than or equal to a specific value age:>=10 or age:<=10
To filter values that match a specific value. age:=10

Filters for String values.

Sample
Filter values that start with a specific string name:arya*
Filter values that end with a specific string name:*stark
Filter values where a specific string appears anywhere in a string name:*ya*
Filter values that match a specific string name:arya%20stark

You can combine multiple fields by separating them with commas as shown below:

name:arya%20stark,age:>13,isalive:true

Deleting records

There are two ways to delete records (see examples above for both)

  • Provide the record_id
  • Provide a query parameter, with the same syntax used for filtering on read

Use your own instance of jsonbox

jb = JsonBox(service_host="https://my-jsonbox-server.com")

License

MIT

Metadata

Release files for jsonbox 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jsonbox 1.2.1
File Size Uploaded Provenance Actions
jsonbox-1.2.1.tar.gz 3.9 kB Without provenance Details for jsonbox-1.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jsonbox 1.2.1
File Interpreter ABI Platform Actions
jsonbox-1.2.1-py2-none-any.whl Python 2 none any Details for jsonbox-1.2.1-py2-none-any.whl

Total release size: 8.5 kB

Release files / jsonbox-1.2.1.tar.gz

Download URL jsonbox-1.2.1.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
52ee1634e58c908efde8e62df34d50eb2c1e3811e0a9425751eaa0bc8a80e58b
BLAKE2b-256 checksum
How to use checksums
d532a0096c9ee7662bfce6003f7c0c077b7790c3cbb46858c0f8405223cf8195
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/2.7.15

Release files / jsonbox-1.2.1-py2-none-any.whl

Download URL jsonbox-1.2.1-py2-none-any.whl
Size 4.7 kB
Tags Python 2
SHA-256 checksum
How to use checksums
13d74eabd167d4453f9ce4ee82865ab3f505307af4529c74e4ce69562c5000fa
BLAKE2b-256 checksum
How to use checksums
1faf88bd879af59121006afd9d56ae55fcf5d37d36ebca3c450594131e43daf1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/2.7.15

Security for jsonbox 1.2.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page