https://github.com/ai-helpers/example-api-template
Instantiating the API cookiecutter template (FastAPI).
https://github.com/ai-helpers/example-api-template
example fastapi machine-learning
Last synced: 6 months ago
JSON representation
Instantiating the API cookiecutter template (FastAPI).
- Host: GitHub
- URL: https://github.com/ai-helpers/example-api-template
- Owner: ai-helpers
- Created: 2024-05-27T09:30:32.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-31T12:48:04.000Z (over 1 year ago)
- Last Synced: 2025-01-13T12:42:06.097Z (about 1 year ago)
- Topics: example, fastapi, machine-learning
- Language: Python
- Homepage: https://ai-helpers.github.io/example-api-template/
- Size: 2.96 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# **API - API Example**
- **Template**: [AI Helpers API template](https://github.com/ai-helpers/api-cookiecutter-template)
- **Description**: My project description
## Table of Content (ToC)
- [Table of Content (ToC)](#table-of-content-toc)
- [Quickstart](#quickstart)
- [Endpoints](#endpoints)
- [Health](#health)
- [Info](#info)
- [Predict](#predict)
- [Test](#test)
- [Documentation](#documentation)
- [Project Structure](#project-structure)
- [Contributions](#contributions)
## Quickstart
```bash
$ poetry install
[...]
Package operations: 44 installs, 0 updates, 0 removals
[...]
$ poetry run api-example
[\2024-05-28 15:58:59,332] {\root} \INFO - \[API] Starting service with version 0.1.0...
[\2024-05-28 15:58:59,332] {\root} \INFO - \[API] Log level set to DEBUG
[\2024-05-28 15:58:59,332] {\api_example.cli} \INFO - \[API] Log level set to DEBUG
[\2024-05-28 15:58:59,332] {\api_example.cli} \INFO - \[API] API service starting on 0.0.0.0:80
[\2024-05-28 15:59:15,529] {\uvicorn.error} \INFO - \Started server process [98569]
[\2024-05-28 15:59:15,529] {\uvicorn.error} \INFO - \Waiting for application startup.
[\2024-05-28 15:59:15,529] {\uvicorn.error} \INFO - \Application startup complete.
[\2024-05-28 15:59:15,534] {\uvicorn.error} \INFO - \Uvicorn running on http://0.0.0.0:80 (Press CTRL+C to quit)
```
## Endpoints
### Health
A simple endpoint to check the health of the application.
```http
GET /health
```
Returns a status message indicating the service is up and running.
### Info
Provides information about the application.
```http
GET /info
```
Returns metadata such as version, author, and other relevant details (cf. `data/info.txt`)
### Predict
Endpoint for making predictions based on input data.
```http
POST /predict
```
Accepts a JSON payload with the necessary input data and returns the prediction results.
### Test
Endpoint for testing purposes.
```http
GET /test
```
Returns a test response, useful for debugging and ensuring the endpoint is reachable.
### Documentation
FastAPI provides interactive API documentation.
```http
GET /docs
```
Access the Swagger UI for a user-friendly interface to interact with your API.
```http
GET /redoc
```
Access the ReDoc interface for an alternative documentation style.
## Project Structure
├── api-example
│ ├── .github <- Github Actions CICD
│ ├── data
│ ├── docs <- Sphinx documentation
│ ├── src
│ └── api_example <- Core of project
│ │ ├── endpoints <- API endpoints definition
│ │ ├── settings <- settings
│ │ ├── __init__.py
│ │ ├── app.py
│ │ ├── cli.py
│ │ ├── errors
│ │ ├── load_model.py
│ │ └── setup_logging.py
│ ├── tasks <- Makefile tasks
│ ├── tests <- tests (units tests, data tests)
│ ├── .gitignore
│ ├── .mypy.ini
│ ├── Makefile
│ ├── poetry.toml
│ ├── pyproject.toml
└── README.md
## Contributions
Your contributions are valued! Please feel free to open issues or submit pull requests.
Let me know if you'd like any other sections added!