Skip to main content

async_data_api - Async DataApi Client

pipeline status

coverage report

Table of Contents

Introduction

This project/package aims to provide a fully asynchronous client for PSIs REST DataAPI.

Installation

Install with pip

pip install async_data_api

Quick-start Guide

Here are some simple examples to get you started:

import asyncio
from datetime import datetime, timedelta

from async_data_api import (
    Aggregation,
    Backends,
    ChannelName,
    DataApi,
    EventFields,
    RangeByDate,
)


async def search_channels_example():
    """Example of how to find a channel by it's name on any backend.
    """
    async with DataApi(base_url="https://data-api.psi.ch/") as api:
        channels = await api.find_channels(
                regex="MMAC3:STR:2",
                return_config=True,
            )
    print(channels)


async def get_data_example():
    """Example to get the data for a channel of the last 3 days, aggregated and binned to 500 bins, as pandas dataframe.
    """
    async with DataApi(base_url="https://data-api.psi.ch/") as api:
        async for result in api.get_data(
            channels=ChannelName(name="MMAC3:STR:2", backend=Backends.proscan),
            range=RangeByDate(
                start_date=datetime.now() - timedelta(days=3),
                endDate=datetime.now(),
                start_expansion=False,
            ),
            event_fields=[EventFields.global_millis, EventFields.raw_value],
            aggregation=Aggregation(
                aggregations=[
                    Aggregation.Aggregations.min,
                    Aggregation.Aggregations.mean,
                    Aggregation.Aggregations.max,
                ],
                nr_of_bins=500,
            ),
        ):
            df = api.json_to_dataframe(result)
            print(df)


async def main():
    """Uncomment the example you want to run
    """
    #await search_channels_example()
    #await get_data_example()
    pass

if __name__ == "__main__":
    asyncio.run(main())

Documentation

Current Features:

  • Fully asynchronous
  • 100% Test coverage
  • Search for channels
  • get data as pandas dataframe

Check out the wiki for more info!

Dependencies

Contribute

To contribute, simply clone the project. You can uses pip -r requirements.txt or the Makefile to set up the project. After that you can make changes and create a pull request or if allowed merge your changes.

Project Changes and Tagged Releases

  • See the Changelog file for further information
  • Project releases are available in pypi (NOT YET)

Developer Notes

Currently None

Contact

If you have any questions pleas contract 'niklas.laufkoetter@psi.ch'

Metadata

Release files for async-data-api 1.0.0

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

Source distribution (sdist)

Source distribution for async-data-api 1.0.0
File Size Uploaded
async_data_api-1.0.0.tar.gz 24.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for async-data-api 1.0.0
File Interpreter ABI Platform
async_data_api-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 50.2 kB

Release files / async_data_api-1.0.0.tar.gz

Download URL async_data_api-1.0.0.tar.gz
Size 24.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c7b4fce2286dde0ee0e6f3055f402c822a0983ad4b0823c66f84af7b80b9352b
BLAKE2b-256 checksum
How to use checksums
c07c9353cdf9564edfaac379c5b4053e7bc065349b1a9e98c4ccf1fa262fbb27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.11.1 Linux/3.10.0-1160.71.1.el7.x86_64

Release files / async_data_api-1.0.0-py3-none-any.whl

Download URL async_data_api-1.0.0-py3-none-any.whl
Size 25.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb868de09496e86dd740d8fd5a2f00dbfcfa1f6536003c4c9b2c8f2730eb8fd0
BLAKE2b-256 checksum
How to use checksums
c9bb56147b06f63068c92097b8a54a64a3c8b825287035e193d52a35e57fcf00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.11.1 Linux/3.10.0-1160.71.1.el7.x86_64

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

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