This project provides a simple API for managing licenses using FastAPI, PostgreSQL, and Docker.
- Check license validity
- Create new users with licenses
- FastAPI for rapid development and high performance
- PostgreSQL for reliable database management
- Docker for easy deployment
-
Clone the repository
git clone https://github.com/wizzzz9/license_apies cd license_apies
-
Set up Docker
docker-compose build docker-compose up
host:port/docs or you can use nginx and use some domain
Endpoint: /api/license/check_license
Method: GET
Description: Check the validity of a license.
Query Parameters:
license_key
(str): The license key to be checked.
Response:
- 200 OK: License is valid.
- 400 Bad Request: License is invalid or expired.
Endpoint: /api/license/create_user
Method: POST
Description: Create a new user with a license.
Request Body:
admin_key
(str): The admin key for authentication.payload
(CreateUserPayload): The payload containing user details.
Endpoint: /api/license/renew_license
Method: POST
Description: Renew a license.
Request Body:
admin_key
(str): The admin key for authentication.payload
(RenewLicensePayload): The payload containing user details.
Response:
- 200 OK: User created successfully.
- 400 Bad Request: Username already exists.
class CreateUserPayload(BaseModel):
username: str
license_time: Optional[datetime] = None
user_info: Optional[str] = None
role_id: int
class CheckLicenseResponseModel(BaseModel):
valid: bool
expiry_date: Optional[datetime] = None
class RenewLicensePayload(BaseModel):
user_licence_key: str
license_time: datetime = None # None == utcnow + 30 days
class CreateUserResponseModel(BaseModel):
username: str
license_key: str
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to contribute to this project by creating issues or submitting pull requests. Your contributions are greatly appreciated!
For further details, refer to the FastAPI documentation and the Docker documentation.