Skip to content

ReductStore Client SDK for Python

PyPI PyPI - Downloads GitHub Workflow Status

This package provides an asynchronous HTTP client for interacting with the ReductStore service.

Features

  • Supports the ReductStore HTTP API v1.9
  • Bucket management
  • API Token management
  • Write, read and query data
  • Labels
  • Batching records for read and write operations
  • Subscription on new data

Install

To install this package, run the following command:

pip install reduct-py

Example

Here is an example of how to use this package to create a bucket, write data to it, and read data from it:

from datetime import datetime
import asyncio
from reduct import Client, Bucket

async def main():
    # Create a client for interacting with a ReductStore service
    client = Client("http://localhost:8383")

    # Create a bucket and store a reference to it in the `bucket` variable
    bucket: Bucket = await client.create_bucket("my-bucket", exist_ok=True)

    # Write data to the bucket
    ts = datetime.now()
    await bucket.write("entry-1", b"Hey!!", ts)

    # Read data from the bucket
    async with bucket.read("entry-1", ts) as record:
        data = await record.read_all()
        print(data)

# Run the main function
loop = asyncio.get_event_loop()
loop.run_until_complete(main())

For more examples, see the Quick Start.

References