Skip to main content
https://github.com/infraguys/restalchemy/actions/workflows/tests.yml/badge.svg https://img.shields.io/pypi/pyversions/restalchemy https://img.shields.io/pypi/dm/restalchemy

RESTAlchemy

RESTAlchemy is a Python toolkit for building HTTP REST APIs on top of a flexible data model and storage abstraction.

It combines:

  • A Data Model (DM) layer for defining domain models and validation.

  • A Storage layer for persisting models (for example, SQL databases).

  • An API layer for exposing models as RESTful HTTP resources.

  • Optional OpenAPI support for discoverable, documented APIs.

Features

  • Clear separation between domain models, storage implementation details, and HTTP API.

  • Strongly typed, validated data model with reusable properties.

  • Minimal boilerplate to expose models as REST resources.

  • Built-in migration tooling for evolving database schemas.

Documentation

The rendered documentation is published at https://infraguys.github.io/restalchemy/.

All documentation is available in four languages. The structure of files and sections is identical across languages:

If you are new to RESTAlchemy, start with:

Quick start

Install from PyPI:

pip install restalchemy

Define a simple DM model (simplified from the getting started guide):

from restalchemy.dm import models
from restalchemy.dm import properties
from restalchemy.dm import types


class FooModel(models.ModelWithUUID):
    value = properties.property(types.Integer(), required=True)

For a complete in-memory REST service example, including controllers, routes and a WSGI application, see docs/en/getting-started.md.

Examples

Real code examples live in the examples/ directory:

  • examples/restapi_foo_bar_service.py – a simple REST API service built with in-memory storage.

  • examples/dm_mysql_storage.py – data model with MySQL storage example.

  • examples/openapi_app.py – example API with OpenAPI specification generation.

Migration commands

RESTAlchemy provides command-line tools for managing database migrations.

<migration number>-<message>-<hash>.py
$ ra-rename-migrations -p <path-to-migrations>

Create migrations:

$ ra-new-migration --path examples/migrations/ --message "1st migration"
$ ra-new-migration --path examples/migrations/ --message "2st migration" --depend 1st
$ ra-new-migration --path examples/migrations/ --message "3st migration" --depend 2st
$ ra-new-migration --path examples/migrations/ --message "4st migration"
$ ra-new-migration --path examples/migrations/ --message "5st migration" --depend 3st --depend 4st

Apply migrations:

$ ra-apply-migration --path examples/migrations/ --db-connection mysql://test:test@localhost/test -m 5st
> upgrade 1st
> upgrade 2st
> upgrade 3st
> upgrade 4st
> upgrade 5st

Rolled back migrations:

$ ra-rollback-migration --path examples/migrations/ --db-connection mysql://test:test@localhost/test -m 4st
> downgrade 5st
> downgrade 4st
$ ra-rollback-migration --path examples/migrations/ --db-connection mysql://test:test@localhost/test -m 1st
> downgrade 3st
> downgrade 2st
> downgrade 1st

Tests

Tests are managed via tox. The default environment list includes Python 3.8, 3.10, 3.12 and 3.13.

Run the full test suite:

tox

Run tests for a specific Python version (for example, Python 3.10):

tox -e py310

Run functional tests (require access to a MySQL database):

export DATABASE_URI="mysql://root:@localhost:3306/radatabase"
tox -e py310-functional

Run functional tests with PostgreSQL:

export DATABASE_URI="postgresql://postgres:password@localhost:5432/radatabase"
tox -e py310-functional

License

RESTAlchemy is licensed under the Apache License, Version 2.0.

Copyright (c) Genesis Corporation, 2025.

See the LICENSE file in this repository or https://www.apache.org/licenses/LICENSE-2.0 for the full license text.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

restalchemy-15.3.0.tar.gz (560.8 kB view details)

Uploaded Source

Built Distribution

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

restalchemy-15.3.0-py3-none-any.whl (618.6 kB view details)

Uploaded Python 3

File details

Details for the file restalchemy-15.3.0.tar.gz.

File metadata

  • Download URL: restalchemy-15.3.0.tar.gz
  • Upload date:
  • Size: 560.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for restalchemy-15.3.0.tar.gz
Algorithm Hash digest
SHA256 22b0d31d91009aacc72c291374bbe274022a784cee04ce5382bf75ca27f10e99
MD5 7707448e175b10081f20b00e26cb56b5
BLAKE2b-256 bb0afb50d392111b8415798582939f1923585f204ca7ab103fbc9367cacbbc6f

See more details on using hashes here.

Provenance

The following attestation bundles were made for restalchemy-15.3.0.tar.gz:

Publisher: publish-to-pypi.yml on infraguys/restalchemy

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

File details

Details for the file restalchemy-15.3.0-py3-none-any.whl.

File metadata

  • Download URL: restalchemy-15.3.0-py3-none-any.whl
  • Upload date:
  • Size: 618.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for restalchemy-15.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 27ff0d7928724c5a7da11ef079d37819e4d48ca125969453e82d2ce23a2df703
MD5 e243106b00ed054f5247a2a99951aa3d
BLAKE2b-256 09476beac6b129ba5f52b35bb3c225081b46dd7fde092f249f0dbb07e1c15d21

See more details on using hashes here.

Provenance

The following attestation bundles were made for restalchemy-15.3.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on infraguys/restalchemy

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

Release history Release notifications | RSS feed

16.0.4

2 files

16.0.3

2 files

16.0.2

2 files

16.0.1

2 files

16.0.0

2 files

This release

15.3.0 This release

2 files

15.2.8

2 files

15.2.7

2 files

15.2.6

2 files

15.2.5

2 files

15.2.4

2 files

15.2.3

2 files

15.2.2

2 files

15.2.1

2 files

15.2.0

2 files

15.1.2

2 files

15.1.1

2 files

15.1.0

2 files

15.0.12

2 files

15.0.11

2 files

15.0.10

2 files

15.0.9

2 files

15.0.8

2 files

15.0.7

2 files

15.0.6

2 files

15.0.5

2 files

15.0.4

2 files

15.0.3

2 files

15.0.2

2 files

15.0.1

2 files

15.0.0

2 files

14.7.0

2 files

14.6.0

2 files

14.5.0

2 files

14.4.1

2 files

14.4.0

2 files

14.3.0

2 files

14.2.0

2 files

14.1.6

2 files

14.1.5

2 files

14.1.4

2 files

14.1.3

2 files

14.1.2

2 files

14.1.1

2 files

14.1.0

2 files

14.0.0

2 files

13.0.1

2 files

13.0.0

2 files

12.10.1

2 files

12.9.0

2 files

12.8.0

2 files

12.7.0

2 files

12.6.0

2 files

12.5.1

2 files

12.5.0

2 files

12.4.0

2 files

12.3.1

2 files

12.3.0

2 files

12.2.0

2 files

12.1.0

2 files

12.0.0

2 files

11.0.1

2 files

11.0.0

2 files

1.2.1

2 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