A lightweight framework for building API endpoints using Python's native libraries.
Project description
LightApi
What is LightApi?
LightApi is a lightweight API framework designed for rapid development of RESTful APIs in Python. It provides a simple and intuitive interface for defining endpoints and handling HTTP requests without the need for complex configuration or dependencies.
This project dont use any external library to create the API, it uses the built-in http.server
to create a minimalistic yet powerful API framework.
How does it work?
LightApi leverages Python's built-in http.server
module to create a minimalistic yet powerful API framework. It allows you to define endpoints using familiar Python classes and methods, making it easy to map HTTP requests to Python code.
Key Features:
- Lightweight and easy to use.
- Minimal dependencies.
- Automatic generation of CRUD endpoints for data models.
- Designed for rapid development and prototyping.
Why use LightApi?
Simplicity:
LightApi provides a simple and straightforward API for defining endpoints and handling HTTP requests. You can get started with just a few lines of code, without the need for complex configuration or setup.
Flexibility:
With LightApi, you have full control over how your API endpoints are defined and how requests are processed. You can easily customize middleware, error handling, and request/response processing to suit your specific requirements.
Performance:
LightApi is designed to be lightweight and efficient, with minimal overhead. It leverages Python's built-in http.server
module for request handling, ensuring optimal performance and scalability.
Rapid Development:
LightApi is perfect for rapid development and prototyping of RESTful APIs. It allows you to quickly define endpoints, test them locally, and iterate on your API design without getting bogged down in unnecessary complexity.
Caveats:
- LightApi is intended for use in development and prototyping environments only. The built-in
http.server
module used by LightApi is not suitable for production use, as it lacks features such as concurrency, scalability, and security.
Getting Started:
To get started with LightApi, simply install the package using pip:
pip install lightapi
Then, define your API endpoints using Python classes and methods, and run your API using the LightApi
class:
from lightapi import LightApi
# Define your API endpoints here...
app = LightApi()
# Register your endpoints with the app...
app.run()
Example:
Registering a person endpoint:
from dataclasses import dataclass
from typing import Optional
from lightapi import LightApi
from lightapi.handlers import BaseModel
@dataclass
class Person(BaseModel):
name: str
age: int
email: Optional[str] = None
app = LightApi()
app.endpoint(Person)
app.run()
This will create all REST endpoints:
GET /person
GET /person/{id}
POST /person
DELETE /person/{id}
PUT /person/{id}
with all CRUD operations.
Contributing:
This project is currently in the early stages of development, and contributions are welcome! If you find any issues or have suggestions for improvement, please feel free to open an issue or submit a pull request on GitHub. Your contributions are greatly appreciated!
GOAL
The goal of the project is to develop a python minimal api interface that can be used to create RESTful APIs with minimal effort and dependencies. This library will install as minimum third party libraries as possible in order to keep it lightweight and easy to use.
License:
LightApi is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file LightApi-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: LightApi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 776490358c88962ef76bca32254ab38886a4d8250b2fbdf75d2197366d34c209 |
|
MD5 | 3f14c929eaae09236e843d3b818143b6 |
|
BLAKE2b-256 | f2680659d52926f6e4db18bb57032c2159f76695a3f6c7c15e87192594ddc710 |