semvec/pypi-packages huggingface dataset:
xn-api 1.0.4
Simplest fastest minimal REST API CRUD generator for Tortoise ORM models
License: MIT
Requires Python: >=3.12
Keywords: starlette, fastapi, admin, generator, db-model, crud, tortoise-orm, ASGI-admin

# X-API
###### Simplest fastest minimal REST API CRUD generator for Tortoise ORM models.
Fully async Zero config One line ASGI app

#### Requirements
- Python >= 3.12

### INSTALL
```bash
pip install tortoise-api
```

### Run your app
- Describe your db models with Tortoise ORM in `models.py` module
```python
from x_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:
```python
from x_api import Api
import models

app = Api().start(models)
```
- Set `DB_URL` env variable in `.env` file
- Run it:
```bash
uvicorn main:app
```
Or you can just fork Completed minimal runnable example from [sample apps](https://github.com/XyncNet/x-api/blob/master/sample_apps/minimal/).

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

<img width="245" alt="Home - Models list" src="https://github.com/XyncNet/x-api/assets/5181924/0ddaa015-2193-43e1-a6d1-2dbad09bfc7b">


And JSON resources for each db Entity at [/{modelName}]() routes:

<img width="450" alt="User JSON resources" src="https://github.com/XyncNet/x-api/assets/5181924/d4497aa5-1f10-45f3-82e8-f5145b72572e">


And one separate Entity at [/{modelName}/{entity_id}]() routes:

<img width="362" alt="User 1 JSON resource" src="https://github.com/XyncNet/x-api/assets/5181924/f1fed04c-8bf2-462c-ad71-fbee35652b1a">


---
Made with ❤ on top of the [FastAPI](https://github.com/fastapi/fastapi) and [TortoiseORM](https://tortoise.github.io/).
cheerlights-api 0.1.2
A Python package to interact with the CheerLights API.
License: MIT
Requires Python: >=3.6

# CheerLights API Python Package

A Python package to interact with the CheerLights API. It allows users to get the current CheerLights color, retrieve the color history, and perform various color-related utilities.

## Installation

You can install the package using pip:

```bash
pip install cheerlights_api
```

## Usage Examples

```python
import cheerlights_api

# Get the current color name and hex code
current_color = cheerlights_api.get_current_color()
print(current_color)  # Example: {'color': 'red', 'hex': '#FF0000'}

# Get the current color name
color_name = cheerlights_api.get_current_color_name()
print(color_name)  # Example: 'red'

# Get the current hex code
hex_code = cheerlights_api.get_current_hex()
print(hex_code)  # Example: '#FF0000'

# Get the history of colors
history = cheerlights_api.get_color_history(5)
for entry in history:
    print(f"{entry['timestamp']}: {entry['color']} ({entry['hex']})")

# Convert a color name to hex
hex_code = cheerlights_api.color_name_to_hex('green')
print(hex_code)  # '#00FF00'

# Convert hex code to RGB
rgb = cheerlights_api.hex_to_rgb('#00FF00')
print(rgb)  # (0, 255, 0)

# Check if a color is valid
is_valid = cheerlights_api.is_valid_color('purple')
print(is_valid)  # True
```