Skip to main content

vBase REST API Python Client

Project description

vbase-py

vBase REST API Python Client

See documentation and the Swagger UI for more details.


License

This project is licensed under the Apache 2.0 License - see the LICENSE.txt file for details.

Introduction

vBase creates a global auditable record of when data was created, by whom, and how it has changed (collectively, “data provenance”). Data producers can prove the provenance of their data to any external party, increasing its value and marketability. Data consumers can ensure the integrity of historical data and any derivative calculations. The result is trustworthy information that can be put into production quickly without expensive and time-consuming trials.

Verifiable provenance establishes the credibility of data and calculations. For example, if you wish to prove investment skill, the recipient must be sure they are receiving a complete and accurate record of your timestamped trades or portfolios.

vBase resolves several expensive market failures common to financial data. Some of the areas that benefit include:

  • Provably point-in-time datasets
  • Auditable investing track records
  • Sound backtests, historical simulations, and time-series modeling

vBase services do not require access to the data itself, assuring privacy. They also do not rely on centralized intermediaries, eliminating the technical, operating, and business risks of a trusted party controlling your data and its validation. vBase ensures data security and interoperability that is unattainable with legacy centralized systems. It does so by storing digital fingerprints of data, metadata, and revisions on secure public blockchains.

With vBase, creating and consuming provably correct data is as easy as pressing a button.

Installation

Install the package using pip:

pip install vbase-api

Quick Start

Getting Your API Key

To use the vBase API, you'll need an API key (Bearer token). You can obtain this from your vBase account settings.

Basic Usage

from vbase_api import VBaseAPIClient

# Initialize the client
client = VBaseAPIClient(api_key="your-bearer-token")

# Stamp some data
stamp = client.create_stamp(data="Important data to be stamped")
print(f"Stamped with CID: {stamp.commitment_receipt.object_cid}")

# List your collections
collections = client.get_collections()
for collection in collections:
    print(f"{collection.name}: {collection.cid}")

Usage Guide

Creating a Client

The VBaseAPIClient can be initialized with your API key:

from vbase_api import VBaseAPIClient

# Basic initialization
client = VBaseAPIClient(api_key="your-bearer-token")

# With custom base URL and timeout
client = VBaseAPIClient(
    api_key="your-bearer-token",
    base_url="https://app.vbase.com",
    timeout=60
)

# Using context manager (recommended)
with VBaseAPIClient(api_key="your-bearer-token") as client:
    collections = client.get_collections()
    # Client resources are automatically cleaned up

Stamping Data

The create_stamp() method is the core functionality of vBase. It allows you to create a blockchain-verified timestamp of your data.

Stamp Inline Data

# Stamp text data
stamp = client.create_stamp(
    data="Important document content"
)
print(f"Object CID: {stamp.commitment_receipt.object_cid}")
print(f"Transaction: {stamp.commitment_receipt.transaction_hash}")
print(f"Timestamp: {stamp.commitment_receipt.timestamp}")

Stamp a File

# Stamp a file from disk
stamp = client.create_stamp(file="report.pdf")

# Stamp a file and add to a collection
stamp = client.create_stamp(
    file="portfolio.csv",
    collection_name="Investment Records",
    idempotent=False
)

# Access file information
if stamp.file_object:
    print(f"File: {stamp.file_object.file_name}")
    print(f"Path: {stamp.file_object.file_path}")

Stamp precalculated CID, without uploading actual data

# Stamp a CID that already exists
stamp = client.create_stamp(
    data_cid="0xbd9c71f7277c841210dd60b84be775e0a48cd6643c5e28eebf8f11b95b893201",
    collection_name="My Collection"
)

Working with Collections

Collections help organize your stamped data into logical groups.

List Collections

# Get all collections
collections = client.get_collections()
for collection in collections:
    print(f"{collection.name} - {collection.description}")

# Filter by pinned status
pinned_collections = client.get_collections(is_pinned=True)

# Filter by user address
user_collections = client.get_collections(user_address="0x...")

Create a Collection

collection = client.create_collection(
    name="Investment Track Records",
    description="Auditable portfolio holdings and trades"
)
print(f"Created collection: {collection.name}")

Verifying Stamps

Verify that specific CIDs have been stamped on the blockchain.

# Verify one or more CIDs
result = client.verify_stamps(
    cids=[
        "0xbd9c71f7277c841210dd60b84be775e0a48cd6643c5e28eebf8f11b95b893201",
        "0xcd9c71f7277c841210dd60b84be775e0a48cd6643c5e28eebf8f11b95b893202"
    ]
)

# Check results
print(f"Timezone: {result.display_timezone}")
for stamp in result.stamp_list:
    print(f"Found stamp:")
    print(f"  CID: {stamp.object_cid}")
    print(f"  Timestamp: {stamp.timestamp}")
    print(f"  Transaction: {stamp.transaction_hash}")
    print(f"  User: {stamp.user_address}")

# Verify CIDs for current user only
result = client.verify_stamps(
    cids=["0xbd9c71f7277c841210dd60b84be775e0a48cd6643c5e28eebf8f11b95b893201"],
    filter_by_user=True
)

Upload Previously Stamped Files

Upload a file that has already been stamped to vBase storage.

result = client.upload_stamped_file(
    collection_name="Investment Records",
    file="previously_stamped.pdf"
)
print(f"Uploaded: {result.file_object.file_name}")

User Account Information

# Get current user information
user = client.get_current_user()
print(f"Email: {user.email}")
print(f"Name: {user.name}")
print(f"Timezone: {user.display_timezone}")
print(f"Address: {user.last_address}")

# Get another user's information by address
other_user = client.get_user("0x1234123412341234123412341234123412341234")
print(f"User name: {other_user.name}")

Error Handling

The client raises VBaseAPIError for API-related errors:

from vbase_api_py import VBaseAPIClient, VBaseAPIError

client = VBaseAPIClient(api_key="your-bearer-token")

try:
    stamp = client.create_stamp(data={"test": "data"})
except VBaseAPIError as e:
    print(f"Error: {e.message}")
    if e.status_code:
        print(f"Status code: {e.status_code}")

Response Objects

The client returns typed response objects for easy data access:

  • StampCreatedResponse: Returned when a new stamp is created (201 status)

    • commitment_receipt: CommitmentReceipt object
    • file_object: FileObject (optional)
  • IdempotentStampResponse: Returned when stamp already exists (200 status)

    • commitment_receipt: CommitmentReceipt object
  • CommitmentReceipt: Blockchain stamp details

    • transaction_hash: Blockchain transaction hash
    • user_address: User's blockchain address
    • set_cid: Set CID (collection)
    • object_cid: Object CID (stamped data)
    • timestamp: ISO format timestamp
    • chain_id: Blockchain chain ID
  • Collection: Collection information

    • id, name, cid, description
    • is_pinned, is_public
    • created_at
  • AccountSettings: User account details

    • name, email, persistent_id
    • display_timezone, date_joined
    • last_address, last_is_verified

Complete Example

from vbase_api import VBaseAPIClient, VBaseAPIError

def main():
    # Initialize client
    with VBaseAPIClient(api_key="your-bearer-token") as client:
        try:
            # Get user info
            user = client.get_current_user()
            print(f"Authenticated as: {user.email}")
            
            # Create a collection
            collection = client.create_collection(
                name="Trading Records",
                cid=None,
                description="Timestamped trading data",
                is_pinned=True
            )
            
            # Stamp trading data
            trade_data = {
                "symbol": "AAPL",
                "shares": 100,
                "price": 150.25,
                "timestamp": "2025-11-24T10:30:00Z"
            }
            
            stamp = client.create_stamp(
                data=trade_data,
                collection_name="Trading Records"
            )
            
            print(f"Trade stamped!")
            print(f"  CID: {stamp.commitment_receipt.object_cid}")
            print(f"  Transaction: {stamp.commitment_receipt.transaction_hash}")
            print(f"  Blockchain timestamp: {stamp.commitment_receipt.timestamp}")
            
            # Verify the stamp
            verification = client.verify_stamps(
                cids=[stamp.commitment_receipt.object_cid]
            )
            
            if verification.stamp_list:
                print("Stamp verified on blockchain!")
            
        except VBaseAPIError as e:
            print(f"API Error: {e}")

if __name__ == "__main__":
    main()

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

vbase_api-0.1.1.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

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

vbase_api-0.1.1-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vbase_api-0.1.1.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vbase_api-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2a97ac3b61bf97d1ee23cb4f669efd1d478d68ff65a611bc49f1ad0bf84ab4bc
MD5 fd67f20723cf5a78d28d99a9c8b23613
BLAKE2b-256 649c4622a05f503756991c44c9579507ab55b91932a68ae7d1d6b179b0a68503

See more details on using hashes here.

Provenance

The following attestation bundles were made for vbase_api-0.1.1.tar.gz:

Publisher: publish-pypi.yml on validityBase/vbase-api-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: vbase_api-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vbase_api-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 02a68bf7be28e2b8f1fe8a19e07f6e8116aa951e8ec4c2549f534161fa1b8b80
MD5 413bcc4523eeb0681eaae17c9a834847
BLAKE2b-256 947a9ddad76b906044367a0e3ba3bb0edfd63e90738534a6ca8253f6c7748768

See more details on using hashes here.

Provenance

The following attestation bundles were made for vbase_api-0.1.1-py3-none-any.whl:

Publisher: publish-pypi.yml on validityBase/vbase-api-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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