Skip to main content

Unified Interface for JSON Database with jsonbin.io

Project description

JsonDBin: Unified Interface for JSON Database with jsonbin.io

JsonDBin is a Python package that offers a unified interface for leveraging jsonbin.io as a JSON database. It simplifies managing collections and documents within jsonbin.io, providing an easy-to-use API for CRUD operations.

PyPI version License Downloads

Features

  • Collection Management: Create, retrieve, and update collections.
  • Document Management: Perform CRUD operations on documents within collections.
  • Schema Support: Attach and remove schemas from collections.
  • Batch Retrieval: Retrieve documents in batches or all at once.
  • Error Handling: Graceful handling of HTTP errors with informative exceptions.

Installation

You can install JsonDBin using pip:

pip install jsondbin

Getting Started

To start using JsonDBin, instantiate the JsonDBin class with your jsonbin.io API key:

from jsondbin import JsonDBin

# Initialize JsonDBin with your API key
db = JsonDBin(
    api_key="YOUR_JSONBIN_API_KEY", 
    collection_name="my_collection", # this is optional
)

Collection Management

# Create a new collection
collection = db.create(name="my_collection")

# Retrieve all collections
collections = db.get_all()

# Rename an existing collection
collection = db.rename(new_name="new_name")

Document Management

# Create a new document in a collection
document = db.create_document(doc={"key": "value"})

# Retrieve a document by ID
document = db.get_document(doc_id="DOCUMENT_ID")

# Update an existing document
updated_document = db.update_document(doc_id="DOCUMENT_ID", doc={"key": "updated_value", "new_key": "new_value"})

# Delete a document by ID
db.delete_document(doc_id="DOCUMENT_ID")

Batch Retrieval

# Retrieve documents in batches of 10
for batch in db.get_pages():
    for document in batch:
        print(document)

# Retrieve all documents in a collection
all_documents = db.get_all_documents()

Schema Management

# Attach a schema document to the collection
schema = db.attach_schema(schema_doc_id="SCHEMA_DOCUMENT_ID")

# Remove the schema attached to the collection
db.remove_schema()

Retrieving API Key

To retrieve your API key or X-Master-Key from JSONBin.io, follow these steps:

  1. Login or Signup to JSONBin.io: Visit the JSONBin.io website and log in to your account using your preferred authentication method (Google, Twitter, Facebook, or GitHub).

  2. Navigate to Dashboard: After logging in, navigate to the Dashboard by clicking on the "Dashboard" option in the navigation menu.

  3. Access API Keys Section: In the Dashboard, locate the "API Keys" section. This section typically contains options related to managing API keys and access permissions.

  4. Retrieve X-Master-Key: Your X-Master-Key is displayed in the API Keys section. It is a default key generated upon creating your JSONBin.io account. Copy the value of X-Master-Key for accessing API endpoints that require authentication.

    Note: Keep your API key secure and do not share it with unauthorized individuals. The X-Master-Key provides access to all API endpoints on JSONBin.io and should be handled with care.

If you have any issues retrieving your API key or need further assistance, you can reach out to JSONBin.io support for help.


JsonDBin is designed for experimental and educational purposes. It is not recommended for production use due to its limitations and the experimental nature of the jsonbin.io service.

Contributions

Contributions are welcome! If you encounter any issues or have suggestions for improvements, feel free to open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsondbin-0.1.4.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jsondbin-0.1.4-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file jsondbin-0.1.4.tar.gz.

File metadata

  • Download URL: jsondbin-0.1.4.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for jsondbin-0.1.4.tar.gz
Algorithm Hash digest
SHA256 c4018086e986216839857939b32f3a8b531e8ace40857d0c29fc6802fe532261
MD5 5b4e5f32f28c5def72771aa6933f179b
BLAKE2b-256 129348632441a1603dfa27e0881b247e124e3bfb06254640d4b1d02f85273ef6

See more details on using hashes here.

File details

Details for the file jsondbin-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: jsondbin-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for jsondbin-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 543b0e835f8641fe6742b901268fa2a15d9664eee8fe67f22c7ad4305b87f790
MD5 bf8611de62e50b6391f17159198f4fe3
BLAKE2b-256 25163c72e541cae19af11921b0f4a928a15f2aa22150edabd494650e249ff7ce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page