Skip to main content

Tortoise-API

Simplest fastest minimal REST API CRUD generator for Tortoise ORM models.

Fully async Zero config One line ASGI app

Requirements

  • Python >= 3.9

INSTALL

pip install tortoise-api

Run your app

  • Describe your db models with Tortoise ORM in models.py module
from tortoise_api import Model

class User(Model):
    id: int = fields.IntField(pk=True)
    name: str = fields.CharField(255, unique=True, null=False)
    posts: fields.ReverseRelation["Post"]

class Post(Model):
    id: int = fields.IntField(pk=True)
    text: str = fields.CharField(4095)
    user: User = fields.ForeignKeyField('models.User', related_name='posts')
    _name = 'text' # `_name` sets the attr for displaying related Post instace inside User (default='name')
  • Write run script main.py: pass your models module in Api app:
from tortoise_api import Api
import models

app = Api().start(models)
  • Set DB_URL env variable in .env file
  • Run it:
uvicorn main:app

Or you can just fork Completed minimal runnable example from sample apps.

And voila:

You have menu with all your models at root app route: http://127.0.0.1:8000

Home - Models list

And JSON resources for each db Entity at /{modelName} routes:

User JSON resources

And one separate Entity at /{modelName}/{entity_id} routes:

User 1 JSON resource

Made with ❤ on top of the Starlette and Tortoise ORM.

Metadata

Release files for tortoise-api 0.2.7

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

Source distribution (sdist)

Source distribution for tortoise-api 0.2.7
File Size Uploaded Provenance Actions
tortoise-api-0.2.7.tar.gz 5.1 kB Without provenance Details for tortoise-api-0.2.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tortoise-api 0.2.7
File Interpreter ABI Platform Actions
tortoise_api-0.2.7-py3-none-any.whl Python 3 none any Details for tortoise_api-0.2.7-py3-none-any.whl

Total release size: 10.8 kB

Release files / tortoise-api-0.2.7.tar.gz

Download URL tortoise-api-0.2.7.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0030b7756f2f194da8baf6dfd70c4fb32de24a2c22ecee9d2250690311f4d3dd
BLAKE2b-256 checksum
How to use checksums
605a87f6d7ee043cf9575d782020d727bf917370ed2ff215c5a2452d942c26d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / tortoise_api-0.2.7-py3-none-any.whl

Download URL tortoise_api-0.2.7-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50e3ff2a1c784dd838efd4bbee00755c89105643bd55f0abef57e3d7b8c5cbdd
BLAKE2b-256 checksum
How to use checksums
c07bb6c59535cea4ec19d48cfa4a51451cc02acc65d84a345fe3589a15c60ec6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Security for tortoise-api 0.2.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.7 This release

2 release files No provenance

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