Skip to main content

This Ceramic client implements the payload building, encoding, and signing needed to interact with the Ceramic Network. It currently supports ModelInstanceDocument and OrbisDB.

Project description

Ceramic and OrbisDB Python Client

These Orbis and Ceramic clients implements the payload building, encoding, and signing needed to interact with the Ceramic Network. It currently supports ModelInstanceDocument.

Features

  • Implements payload building, encoding, and signing for Ceramic interactions
  • Currently supports ModelInstanceDocument

Install the library using pip

pip3 install ceramicsdk

Instantiating a Client

You can use the Orbis Studio or run a local or self-hosted OrbisDB Instance to locate and configure your context ID, environment ID, and node endpoints (used below).

This README will utilize this data model as the input example.

First, generate a Decentralized Identifier (DID) using a DID library.

from ceramicsdk import OrbisDB

# using an existing data model example
table = "kjzl6hvfrbw6c6adsnzvbyr6itmf0igfy25xu0mqzei2pe2xw1hlusqyuknb9ky"

# using an existing context id
context = "<your-context-here>"

# dedicated orbis and ceramic endpoints 
o_endpoint = "<your-endpoint-here>"
c_endpoint = "<your-endpoint-here>"

# create a private key
privkey = os.urandom(32).hex()

# creating a client
db = OrbisDB(c_endpoint, o_endpoint, context, table, privkey)

Creating a Row

# input content must conform to data model used
doc = db.add_row({
    page: "/home",
    address: "0x8071f6F971B438f7c0EA72C950430EE7655faBCe",
    customer_user_id: 3,
    timestamp: "2024-09-25T15:06:14.957719+00:00"
})

Reading Data

env_id = "<your-env-id-here>"

# select rows without any filters
docs = orbis.read(env_id)

# using a defined query
q = 'SELECT * FROM kjzl6hvfrbw6c6adsnzvbyr6itmf0igfy25xu0mqzei2pe2xw1hlusqyuknb9ky as table WHERE table.customer_user_id = 3'
queried_rows = db.query(env_id, q)

Updating Data

# add a filter to select specific row
filters={"customer_user_id": 3}

# new content to replace the old
new_content={"customer_user_id": 2}

updated_rows = db.update_rows(env_id, filters, new_content)

Credits

This project is largely based on the work done by the team at https://github.com/valory-xyz/ceramic-py/, and by the team at https://github.com/indexnetwork/ceramic-python. We are grateful for their contributions to the Ceramic ecosystem and the open-source community.

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

ceramicsdk-0.1.1.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

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

ceramicsdk-0.1.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file ceramicsdk-0.1.1.tar.gz.

File metadata

  • Download URL: ceramicsdk-0.1.1.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for ceramicsdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 771c31354d0314bba0b1b6b9eed7f1946f8c20a574804837aa79c79fea8cf4a0
MD5 b16944098243afc5052853bdc61204be
BLAKE2b-256 b4fa45e68f0627fdaacb6ff8eee386800dcd3aa99dd1352efbd2b5cfea17b06a

See more details on using hashes here.

File details

Details for the file ceramicsdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ceramicsdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for ceramicsdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a536d525658469e7dd92b35224e8ce00a3131d8963958b3e8dc5e4e37f9bfc0f
MD5 55f405c2f8cd8bbe13cefa3bab0d5713
BLAKE2b-256 5ba8b65a4ab1fd13e5f8c8358cfd8679ca0daaa481fd1ca1d02e83750e74e29c

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