UtilMeta


NameUtilMeta JSON
Version 2.6.4 PyPI version JSON
download
home_pageNone
SummaryUtilMeta - progressive meta framework for API development in Python
upload_time2024-11-22 04:30:19
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseCopyright (c) 2019-present Xulin Zhou (周煦林) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
keywords api restful backend declarative devops meta orm progressive utype web
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # UtilMeta Python Framework

<img src="https://utilmeta.com/img/logo-main-gradient.png" style="width: 200px" alt="">

**UtilMeta** Python framework is a progressive meta-framework to develop and manage backend applications, building declarative API & ORM efficiently based on the Python type annotation standard with both sync & async syntax, and supports using mainstream Python frameworks as runtime backend

* Homepage: [https://utilmeta.com/py](https://utilmeta.com/py)
* Documentation: [https://docs.utilmeta.com/py/en/](https://docs.utilmeta.com/py/en/)
* Author: <a href="https://github.com/voidZXL" target="_blank">@voidZXL</a>
* Language: [![en](https://img.shields.io/badge/lang-English-blue.svg)](https://github.com/utilmeta/utilmeta-py/blob/main/README.md) [![zh](https://img.shields.io/badge/lang-中文-green.svg)](https://github.com/utilmeta/utilmeta-py/blob/main/README.zh.md)

<a href="https://pypi.org/project/utilmeta/" target="_blank">
	<img src="https://img.shields.io/pypi/v/utilmeta" alt="">
</a>
<a href="https://pypi.org/project/utilmeta/" target="_blank">
	<img src="https://img.shields.io/pypi/pyversions/utilmeta" alt="">
</a>
<a href="https://pepy.tech/project/utilmeta" target="_blank">
	<img src="https://pepy.tech/badge/utilmeta/month" alt="">
</a>
<a href="https://github.com/utilmeta/utilmeta-py/blob/main/LICENSE" target="_blank">
	<img src="https://img.shields.io/badge/license-Apache%202.0-blue" alt="">
</a>
<a href="https://github.com/utilmeta/utilmeta-py/actions?query=branch%3Amain+" target="_blank">
	<img src="https://img.shields.io/github/actions/workflow/status/utilmeta/utilmeta-py/test.yaml?branch=main&label=CI" alt="">
</a>


## Installation
```
pip install utilmeta
```

> UtilMeta requires Python >= 3.8

## Core Features

### Declarative API & ORM

with UtilMeta, you can easily write declarative APIs with auto request validation, efficient ORM queries, and auto OpenAPI document generation, here is an example from [mini_blog/blog/api.py](https://github.com/utilmeta/utilmeta-py/blob/main/examples/mini_blog/blog/api.py)

```python
from utilmeta.core import api, orm
from .models import User, Article
from django.db import models

class UserSchema(orm.Schema[User]):
    username: str
    articles_num: int = models.Count('articles')

class ArticleSchema(orm.Schema[Article]):
    id: int
    author: UserSchema
    content: str

class ArticleAPI(api.API):
    async def get(self, id: int) -> ArticleSchema:
        return await ArticleSchema.ainit(id)
```

if you request the ArticleAPI like `GET /article?id=1`, you will get the result like

```python
{
  "id": 1,
  "author": {
    "username": "alice",
    "articles_num": 3
  },
  "content": "hello world"
}
```
This is just what you declared, UtilMeta will generate optimized ORM queries automatically based on your declared schemas, prevent N+1 problem and also generate OpenAPI document for your APIs

### Progressive Meta Framework
UtilMeta built a standard that support most major Python web frameworks as runtime backend, and support current projects using these frameworks to develop new API using UtilMeta progressively

Currently supported backends:

* **Django** (also Django REST framework)
* **Flask** (also APIFlask)
* **FastAPI** (also Starlette)
* **Sanic**
* **Tornado**

You can change the entire runtime backend with a single line of code, Here is a hello world example of UtilMeta
```python
from utilmeta import UtilMeta
from utilmeta.core import api
import django

class RootAPI(api.API):
    @api.get
    def hello(self):
        return 'world'

service = UtilMeta(
    __name__,
    name='demo',
    backend=django,    # or flask / fastapi / starlette / sanic / tornado
    api=RootAPI,
    route='/api'
)

app = service.application()  # wsgi app

if __name__ == '__main__':
    service.run()
```

You can create a Python file with the above code and run it to check it out.

## Quick Start

you can start by easily start by clone out repo and run an example 

```shell
pip install -U utilmeta
git clone https://github.com/utilmeta/utilmeta-py
cd utilmeta-py/examples/mini_blog
meta migrate        # migrate databases
meta run            # or python server.py
```

The following info Implies that the service has live
```
| UtilMeta (version) starting service [blog]
|     version: 0.1.0
|       stage: ● debug
|     backend: fastapi (version) | asynchronous
|    base url: http://127.0.0.1:8080
```

### Connect
When you started your service, you can see a line of output
```
UtilMeta OperationsAPI loaded at http://127.0.0.1:8080/ops, connect your APIs at https://ops.utilmeta.com
```

this indicates that UtilMeta Operations system is loaded successfully, you
You can connect your APIs by open this link: [https://ops.utilmeta.com/localhost?local_node=http://127.0.0.1:8080/ops](https://ops.utilmeta.com/localhost?local_node=http://127.0.0.1:8080/ops)

Click **API** and your will see the generated API document, you can debug your API here
<img src="https://utilmeta.com/assets/image/connect-local-api.png" href="https://ops.utilmeta.com" target="_blank" width="800"/>
With your local API connected, you can use these features

* **Data**: Manage database data (CRUD), in this example, you can add `user` and `article` instance
* **API**: view and debug on auto generated API document
* **Logs**: query realtime request logs, view request and response data, error tracebacks
* **Servers**: view realtime metrics of service resources like servers, databases, caches

> Using other management features requires you to connect a online service with public network address
## Document Guide
We have several introductory case tutorials from easy to complex, covering most usage of the framework. You can read and learn in the following order.

1. [BMI Calculation API](https://docs.utilmeta.com/py/en/tutorials/bmi-calc)
2. [User Login & RESTful API](https://docs.utilmeta.com/py/en/tutorials/user-auth)
3. [Realworld Blog Project](https://docs.utilmeta.com/py/en/tutorials/realworld-blog)
4. Websocket Chatroom (coming soon)

If you prefer to learn from a specific feature, you can refer to

* [Handle Request](https://docs.utilmeta.com/py/en/guide/handle-request): How to handle path, query parameters, request body, file upload, request headers and cookies.
* [API Class and Routing](https://docs.utilmeta.com/py/en/guide/api-route) How to use API class mounts to define tree-like API routing, and use  hooks to easily reuse code between APIs, handle errors, and template responses.
* [Schema Query and ORM](https://docs.utilmeta.com/py/en/guide/schema-query) How to use UtilMeta to write declarative ORM queries for RESTful API.
* [API Authentication](https://docs.utilmeta.com/py/en/guide/auth): How to use Session, JWT, OAuth and other methods to authenticate the request of the interface, get the current request's user and simplify the login operation
* [Declarative Web Client](https://docs.utilmeta.com/py/en/guide/client): Use the declarative syntax identical to API to write request client code, and genrate client code based on UtilMeta service or OpenAPI docs

If your APIs are developed, and want to know how to config, run and manage your APis, check

* [Config, Run & Deploy](https://docs.utilmeta.com/py/en/guide/config-run): How to configure the run settings, startup, and deployment of a service using features such as declarative environment variables
* [Connect & Operations](https://docs.utilmeta.com/py/en/guide/ops): How to connect and manage your API service 

## Community
Join our community to build great things together

* [Discord](https://discord.gg/JdmEkFS6dS)
* [X(Twitter)](https://twitter.com/@utilmeta)
* [Reddit](https://www.reddit.com/r/utilmeta)

## Enterprise Solutions & Support
The UtilMeta team is providing custom solutions and enterprise-level support at

* [https://utilmeta.com/solutions](https://utilmeta.com/solutions)

You can also contact us in [this page](https://utilmeta.com/about#contact)

### Wechat

Contact the creator's wechat (voidZXL) for support or join the developers wechat group

<img src="https://utilmeta.com/img/wx_voidzxl.jpg" href="https://utilmeta.com/py" target="_blank"  alt="drawing" width="200"/>

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "UtilMeta",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "API, RESTful, backend, declarative, devops, meta, orm, progressive, utype, web",
    "author": null,
    "author_email": "\"Xulin Zhou (voidZXL)\" <zxl@utilmeta.com>",
    "download_url": "https://files.pythonhosted.org/packages/0d/35/af82d831990475b6827a5a07b2ee5a9743bcced537b1dd923a547a14fff6/utilmeta-2.6.4.tar.gz",
    "platform": null,
    "description": "# UtilMeta Python Framework\n\n<img src=\"https://utilmeta.com/img/logo-main-gradient.png\" style=\"width: 200px\" alt=\"\">\n\n**UtilMeta** Python framework is a progressive meta-framework to develop and manage backend applications, building declarative API & ORM efficiently based on the Python type annotation standard with both sync & async syntax, and supports using mainstream Python frameworks as runtime backend\n\n* Homepage: [https://utilmeta.com/py](https://utilmeta.com/py)\n* Documentation: [https://docs.utilmeta.com/py/en/](https://docs.utilmeta.com/py/en/)\n* Author: <a href=\"https://github.com/voidZXL\" target=\"_blank\">@voidZXL</a>\n* Language: [![en](https://img.shields.io/badge/lang-English-blue.svg)](https://github.com/utilmeta/utilmeta-py/blob/main/README.md) [![zh](https://img.shields.io/badge/lang-\u4e2d\u6587-green.svg)](https://github.com/utilmeta/utilmeta-py/blob/main/README.zh.md)\n\n<a href=\"https://pypi.org/project/utilmeta/\" target=\"_blank\">\n\t<img src=\"https://img.shields.io/pypi/v/utilmeta\" alt=\"\">\n</a>\n<a href=\"https://pypi.org/project/utilmeta/\" target=\"_blank\">\n\t<img src=\"https://img.shields.io/pypi/pyversions/utilmeta\" alt=\"\">\n</a>\n<a href=\"https://pepy.tech/project/utilmeta\" target=\"_blank\">\n\t<img src=\"https://pepy.tech/badge/utilmeta/month\" alt=\"\">\n</a>\n<a href=\"https://github.com/utilmeta/utilmeta-py/blob/main/LICENSE\" target=\"_blank\">\n\t<img src=\"https://img.shields.io/badge/license-Apache%202.0-blue\" alt=\"\">\n</a>\n<a href=\"https://github.com/utilmeta/utilmeta-py/actions?query=branch%3Amain+\" target=\"_blank\">\n\t<img src=\"https://img.shields.io/github/actions/workflow/status/utilmeta/utilmeta-py/test.yaml?branch=main&label=CI\" alt=\"\">\n</a>\n\n\n## Installation\n```\npip install utilmeta\n```\n\n> UtilMeta requires Python >= 3.8\n\n## Core Features\n\n### Declarative API & ORM\n\nwith UtilMeta, you can easily write declarative APIs with auto request validation, efficient ORM queries, and auto OpenAPI document generation, here is an example from [mini_blog/blog/api.py](https://github.com/utilmeta/utilmeta-py/blob/main/examples/mini_blog/blog/api.py)\n\n```python\nfrom utilmeta.core import api, orm\nfrom .models import User, Article\nfrom django.db import models\n\nclass UserSchema(orm.Schema[User]):\n    username: str\n    articles_num: int = models.Count('articles')\n\nclass ArticleSchema(orm.Schema[Article]):\n    id: int\n    author: UserSchema\n    content: str\n\nclass ArticleAPI(api.API):\n    async def get(self, id: int) -> ArticleSchema:\n        return await ArticleSchema.ainit(id)\n```\n\nif you request the ArticleAPI like `GET /article?id=1`, you will get the result like\n\n```python\n{\n  \"id\": 1,\n  \"author\": {\n    \"username\": \"alice\",\n    \"articles_num\": 3\n  },\n  \"content\": \"hello world\"\n}\n```\nThis is just what you declared, UtilMeta will generate optimized ORM queries automatically based on your declared schemas, prevent N+1 problem and also generate OpenAPI document for your APIs\n\n### Progressive Meta Framework\nUtilMeta built a standard that support most major Python web frameworks as runtime backend, and support current projects using these frameworks to develop new API using UtilMeta progressively\n\nCurrently supported backends:\n\n* **Django** (also Django REST framework)\n* **Flask** (also APIFlask)\n* **FastAPI** (also Starlette)\n* **Sanic**\n* **Tornado**\n\nYou can change the entire runtime backend with a single line of code, Here is a hello world example of UtilMeta\n```python\nfrom utilmeta import UtilMeta\nfrom utilmeta.core import api\nimport django\n\nclass RootAPI(api.API):\n    @api.get\n    def hello(self):\n        return 'world'\n\nservice = UtilMeta(\n    __name__,\n    name='demo',\n    backend=django,    # or flask / fastapi / starlette / sanic / tornado\n    api=RootAPI,\n    route='/api'\n)\n\napp = service.application()  # wsgi app\n\nif __name__ == '__main__':\n    service.run()\n```\n\nYou can create a Python file with the above code and run it to check it out.\n\n## Quick Start\n\nyou can start by easily start by clone out repo and run an example \n\n```shell\npip install -U utilmeta\ngit clone https://github.com/utilmeta/utilmeta-py\ncd utilmeta-py/examples/mini_blog\nmeta migrate        # migrate databases\nmeta run            # or python server.py\n```\n\nThe following info Implies that the service has live\n```\n| UtilMeta (version) starting service [blog]\n|     version: 0.1.0\n|       stage: \u25cf debug\n|     backend: fastapi (version) | asynchronous\n|    base url: http://127.0.0.1:8080\n```\n\n### Connect\nWhen you started your service, you can see a line of output\n```\nUtilMeta OperationsAPI loaded at http://127.0.0.1:8080/ops, connect your APIs at https://ops.utilmeta.com\n```\n\nthis indicates that UtilMeta Operations system is loaded successfully, you\nYou can connect your APIs by open this link: [https://ops.utilmeta.com/localhost?local_node=http://127.0.0.1:8080/ops](https://ops.utilmeta.com/localhost?local_node=http://127.0.0.1:8080/ops)\n\nClick **API** and your will see the generated API document, you can debug your API here\n<img src=\"https://utilmeta.com/assets/image/connect-local-api.png\" href=\"https://ops.utilmeta.com\" target=\"_blank\" width=\"800\"/>\nWith your local API connected, you can use these features\n\n* **Data**: Manage database data (CRUD), in this example, you can add `user` and `article` instance\n* **API**: view and debug on auto generated API document\n* **Logs**: query realtime request logs, view request and response data, error tracebacks\n* **Servers**: view realtime metrics of service resources like servers, databases, caches\n\n> Using other management features requires you to connect a online service with public network address\n## Document Guide\nWe have several introductory case tutorials from easy to complex, covering most usage of the framework. You can read and learn in the following order.\n\n1. [BMI Calculation API](https://docs.utilmeta.com/py/en/tutorials/bmi-calc)\n2. [User Login & RESTful API](https://docs.utilmeta.com/py/en/tutorials/user-auth)\n3. [Realworld Blog Project](https://docs.utilmeta.com/py/en/tutorials/realworld-blog)\n4. Websocket Chatroom (coming soon)\n\nIf you prefer to learn from a specific feature, you can refer to\n\n* [Handle Request](https://docs.utilmeta.com/py/en/guide/handle-request): How to handle path, query parameters, request body, file upload, request headers and cookies.\n* [API Class and Routing](https://docs.utilmeta.com/py/en/guide/api-route) How to use API class mounts to define tree-like API routing, and use  hooks to easily reuse code between APIs, handle errors, and template responses.\n* [Schema Query and ORM](https://docs.utilmeta.com/py/en/guide/schema-query) How to use UtilMeta to write declarative ORM queries for RESTful API.\n* [API Authentication](https://docs.utilmeta.com/py/en/guide/auth): How to use Session, JWT, OAuth and other methods to authenticate the request of the interface, get the current request's user and simplify the login operation\n* [Declarative Web Client](https://docs.utilmeta.com/py/en/guide/client): Use the declarative syntax identical to API to write request client code, and genrate client code based on UtilMeta service or OpenAPI docs\n\nIf your APIs are developed, and want to know how to config, run and manage your APis, check\n\n* [Config, Run & Deploy](https://docs.utilmeta.com/py/en/guide/config-run): How to configure the run settings, startup, and deployment of a service using features such as declarative environment variables\n* [Connect & Operations](https://docs.utilmeta.com/py/en/guide/ops): How to connect and manage your API service \n\n## Community\nJoin our community to build great things together\n\n* [Discord](https://discord.gg/JdmEkFS6dS)\n* [X(Twitter)](https://twitter.com/@utilmeta)\n* [Reddit](https://www.reddit.com/r/utilmeta)\n\n## Enterprise Solutions & Support\nThe UtilMeta team is providing custom solutions and enterprise-level support at\n\n* [https://utilmeta.com/solutions](https://utilmeta.com/solutions)\n\nYou can also contact us in [this page](https://utilmeta.com/about#contact)\n\n### Wechat\n\nContact the creator's wechat (voidZXL) for support or join the developers wechat group\n\n<img src=\"https://utilmeta.com/img/wx_voidzxl.jpg\" href=\"https://utilmeta.com/py\" target=\"_blank\"  alt=\"drawing\" width=\"200\"/>\n",
    "bugtrack_url": null,
    "license": "Copyright (c) 2019-present Xulin Zhou (\u5468\u7166\u6797)  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.",
    "summary": "UtilMeta - progressive meta framework for API development in Python",
    "version": "2.6.4",
    "project_urls": {
        "Documentation": "https://docs.utilmeta.com/py/en",
        "Homepage": "https://utilmeta.com/py",
        "Repository": "https://github.com/utilmeta/utilmeta-py"
    },
    "split_keywords": [
        "api",
        " restful",
        " backend",
        " declarative",
        " devops",
        " meta",
        " orm",
        " progressive",
        " utype",
        " web"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "26c5503ace603645b8e3526407a37e456e018d9d5311ee576ff77d9888b61098",
                "md5": "70078f6b41f6ec8aaec016277d147937",
                "sha256": "3fbf8d094ea87a0953a5152de3855411a5557defd1d21119fe6cad36c27bff39"
            },
            "downloads": -1,
            "filename": "utilmeta-2.6.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "70078f6b41f6ec8aaec016277d147937",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 411467,
            "upload_time": "2024-11-22T04:30:17",
            "upload_time_iso_8601": "2024-11-22T04:30:17.512834Z",
            "url": "https://files.pythonhosted.org/packages/26/c5/503ace603645b8e3526407a37e456e018d9d5311ee576ff77d9888b61098/utilmeta-2.6.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0d35af82d831990475b6827a5a07b2ee5a9743bcced537b1dd923a547a14fff6",
                "md5": "36c4bf06de6fd72c652b8cd1ec298e7c",
                "sha256": "8f42c1eabe92cc0b75ae871c850271e283da84ea3ffa788b8c03646f96d954ff"
            },
            "downloads": -1,
            "filename": "utilmeta-2.6.4.tar.gz",
            "has_sig": false,
            "md5_digest": "36c4bf06de6fd72c652b8cd1ec298e7c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 311351,
            "upload_time": "2024-11-22T04:30:19",
            "upload_time_iso_8601": "2024-11-22T04:30:19.581787Z",
            "url": "https://files.pythonhosted.org/packages/0d/35/af82d831990475b6827a5a07b2ee5a9743bcced537b1dd923a547a14fff6/utilmeta-2.6.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-22 04:30:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "utilmeta",
    "github_project": "utilmeta-py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "utilmeta"
}
        
Elapsed time: 0.59849s