Metadata-Version: 2.1
Name: mirapi
Version: 0.0.2
Summary: A lightweight and fast ASGI-based Python web framework for building APIs with automatic OpenAPI documentation.
Home-page: https://github.com/Diyarbekoralbaev/mirapi
Author: Diyarbek Oralbaev
Author-email: diyarbekdev@gmail.com
License: MIT
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Development Status :: 3 - Alpha
Classifier: Operating System :: OS Independent
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Requires-Python: >=3.9.0
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: starlette==0.39.2
Requires-Dist: parse==1.20.2
Requires-Dist: uvicorn==0.31.1
Requires-Dist: pydantic==2.9.2
Provides-Extra: database
Requires-Dist: psycopg2-binary; extra == "database"
Provides-Extra: orm
Requires-Dist: sqlalchemy; extra == "orm"


# MirAPI

[![PyPI version](https://badge.fury.io/py/mirapi.svg)](https://badge.fury.io/py/mirapi)
[![Python Versions](https://img.shields.io/pypi/pyversions/mirapi.svg)](https://pypi.org/project/mirapi/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

MirAPI is a lightweight, fast, and easy-to-use ASGI-based Python web framework for building APIs. It's designed to be simple yet powerful, allowing developers to quickly create robust asynchronous web applications and RESTful APIs with automatic OpenAPI (Swagger) documentation.

## Features

- ASGI-based for high performance and scalability
- Easy-to-use routing system
- Automatic OpenAPI (Swagger) documentation generation
- Built-in support for JSON responses
- Type hinting and Pydantic model integration
- Lightweight and fast asynchronous application
- Customizable error handling
- Support for all standard HTTP methods

## Installation

You can install MirAPI using pip:

```bash
pip install mirapi
```

## Quick Start

Here's a simple example to get you started with MirAPI:

```python
from mirapi import MirAPI
from pydantic import BaseModel

app = MirAPI(title="My API", version="1.0.0")

class Item(BaseModel):
    name: str
    price: float

@app.get("/")
async def root():
    return {"message": "Hello, World!"}

@app.post("/items")
async def create_item(item: Item):
    return {"item": item, "message": "Item created successfully"}

if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)
```

This example creates a simple asynchronous API with two endpoints: a GET route at the root path and a POST route for creating items.

## Advanced Usage

### Route Parameters

MirAPI supports path parameters in your routes:

```python
@app.get("/items/{item_id}")
async def get_item(item_id: int):
    return {"item_id": item_id}
```

### Request Body Validation

Use Pydantic models to validate request bodies:

```python
from pydantic import BaseModel

class User(BaseModel):
    username: str
    email: str
    age: int

@app.post("/users")
async def create_user(user: User):
    return {"user": user, "message": "User created successfully"}
```

### Error Handling

MirAPI provides built-in error handling, but you can also customize error responses:

```python
from starlette.exceptions import HTTPException
from starlette.responses import JSONResponse

@app.route("/custom_error")
async def custom_error(request):
    raise HTTPException(status_code=400, detail="Custom error message")

@app.exception_handler(HTTPException)
async def http_exception_handler(request, exc):
    return JSONResponse(
        status_code=exc.status_code,
        content={"message": exc.detail},
    )
```

## Documentation

MirAPI automatically generates OpenAPI (Swagger) documentation for your API. You can access the interactive API documentation by navigating to `/docs` in your browser when running your application.

## Dependencies

MirAPI depends on the following packages:

- starlette (0.39.2)
- parse (1.20.2)
- uvicorn (0.31.1)
- pydantic (2.9.2)

These dependencies will be automatically installed when you install MirAPI.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

## License

This project is licensed under the MIT License - see the [LICENSE](https://github.com/Diyarbekoralbaev/mirapi/LICENSE) file for details.

## Acknowledgments

- Inspired by modern ASGI-based Python web frameworks
- Built with love for the Python community

For more detailed information and advanced usage, please refer to the [documentation](https://mirapi.readthedocs.io).
