FastAPI-powered TimescaleDB microservice for storing time-series measurements
Project description
Kronicle API
Kronicle is a FastAPI-based time-series measurements storage service with strict separation of admin, writer, and reader permissions. The API is organized into three main route groups: Reader/API, Writer/Data and Setup/Admin.
Base URL prefixes include the API version:
/api/v1→ Reader/read-only routes/data/v1→ Writer/data routes/setup/v1→ Admin/setup routes
Here is the full updated API (as an OpenAPI JSON)
If the server is launched, you can get an interactive Swagger at http://localhost:8000/docs
Setup / Admin Routes (/setup/{api_version})
These routes are intended for administrators or users with full access to manage channels.
| Method | Path | Description |
|---|---|---|
| POST | /channels |
Create a new channel with metadata and schema. Fails if the channel exists. |
| PUT | /channels/{channel_id} |
Upsert a channel: updates metadata if exists, otherwise creates it. |
| PATCH | /channels/{channel_id} |
Partially update a channel’s metadata, tags, or schema. |
| DELETE | /channels/{channel_id} |
Delete a channel and its metadata. All associated data rows are also removed. |
| GET | /channels |
List all channels with metadata and row counts (admin view). |
| DELETE | /channels/{channel_id}/rows |
Delete all data rows for a channel, keeping metadata intact. |
| POST | /channels/{channel_id}/clone |
Clone a channel’s schema and optionally metadata. Does not copy data rows. |
| GET | /channels/columns/types |
List the types available to describe the columns. |
Writer / Data Routes (/data/{api_version})
These routes are primarily for appending channel data and managing metadata safely. Writers have read-only access for exploration.
Append-only Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /channels |
Upsert metadata and insert rows. Auto-creates channel if missing. |
| POST | /channels/{channel_id}/rows |
Insert new rows for an existing channel. Metadata is not modified. |
Read-only Endpoints (accessible to writers)
| Method | Path | Description |
|---|---|---|
| GET | /channels |
Fetch metadata for all channels. |
| GET | /channels/{channel_id} |
Fetch metadata for a specific channel. |
| GET | /channels/{channel_id}/rows |
Fetch all rows and metadata for a specific channel. |
| GET | /channels/{channel_id}/columns |
Fetch all columns and metadata for a specific channel. |
Reader / API Routes (/api/{api_version})
These routes are read-only and safe for public or restricted clients.
| Method | Path | Description |
|---|---|---|
| GET | /channels |
List all available channel channels with metadata (no rows). |
| GET | /channels/{channel_id} |
Fetch metadata for a specific channel (no rows). |
| GET | /channels/{channel_id}/rows |
Fetch stored rows along with metadata for a specific channel. |
| GET | /channels/{channel_id}/columns |
Fetch stored rows along with metadata for a specific channel. |
Notes
- Immutable Data: channel data rows are append-only once inserted.
- Metadata: Includes schema, tags, and additional channel metadata.
- Permissions:
- Setup routes require admin access.
- Writer routes allow appending data plus safe reads.
- Reader routes are read-only.
Prerequisites
Install Postgresql@17 and TimescaleDB (MacOS version here)
brew install postgresql@17 timescaledb
# Start Postgres
brew services start postgresql@17
# You can check if it is running correctly with
pg_ctl -D /opt/homebrew/var/postgresql@17 status
# or
brew services list
# Add this is your ~/.zshrc
export PATH="/opt/homebrew/opt/postgresql@17/bin:$PATH"
export PGDATA="/opt/homebrew/var/postgresql@17"
# Then
source ~/.zshrc
# By default, postgres role is created. You can create your own user and DB
createuser --interactive # prompts for username & superuser? yes/no
createdb mydb # creates a database owned by your new user
psql mydb # now you can connect to it in psql
Inside psql
-- inside psql
\du -- list roles/users
\l -- list databases
See additional psql/timescaleDB commands in ./docs
Enable TimescaleDB
-- inside psql:
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
If you want it enabled by default for all databases, you can edit postgresql.conf:
shared_preload_libraries = 'timescaledb'
Then restart PostgreSQL:
brew services restart postgresql@17
Verify TimescaleDB
-- inside psql
\dx
Launch
FastAPI server
cd src
# nodemon-like reload-on-code-change server launch
# instead of `fastapi run kronicle/main.py`
uvicorn kronicle.main:app --reload --host 0.0.0.0 --port 8000
You can then test the API with Swagger: http://localhost:8000/docs
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kronicle-0.1.0.tar.gz.
File metadata
- Download URL: kronicle-0.1.0.tar.gz
- Upload date:
- Size: 62.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fceb3bbe7c831084267542255ff70888f137b22719081c87b68cca2823fb5c60
|
|
| MD5 |
7da6d14797fa908231927622ff95e40d
|
|
| BLAKE2b-256 |
d650b02855ef3721fc2ca7d67d83951845d70fa200b4d958c131782ff02f2a36
|
File details
Details for the file kronicle-0.1.0-py3-none-any.whl.
File metadata
- Download URL: kronicle-0.1.0-py3-none-any.whl
- Upload date:
- Size: 74.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb74c317888753fee327140b337844536b914c6d25c2d55f2be022907798e4a9
|
|
| MD5 |
8547df7048760ae59849d79b94554ea3
|
|
| BLAKE2b-256 |
5680ce34780a4226377511aee2a1a2af443afd16accedb4d5edc47869573be30
|