first commit
This commit is contained in:
87
api/README.md
Normal file
87
api/README.md
Normal file
@@ -0,0 +1,87 @@
|
||||
# API Service - FastAPI
|
||||
|
||||
A RESTful API service built with FastAPI featuring Swagger documentation.
|
||||
|
||||
## Features
|
||||
|
||||
- 📚 Automatic Swagger/OpenAPI documentation
|
||||
- 🔄 RESTful API endpoints
|
||||
- ✅ Data validation with Pydantic
|
||||
- 📊 Statistics and monitoring endpoints
|
||||
- ❤️ Health check endpoints
|
||||
|
||||
## Local Development
|
||||
|
||||
### Run with Python
|
||||
|
||||
```bash
|
||||
# Install dependencies
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Run the application
|
||||
python main.py
|
||||
|
||||
# Or use uvicorn directly
|
||||
uvicorn main:app --reload --host 0.0.0.0 --port 8000
|
||||
```
|
||||
|
||||
### Run with Docker
|
||||
|
||||
```bash
|
||||
# Build image
|
||||
docker build -t fastapi-api .
|
||||
|
||||
# Run container
|
||||
docker run -p 8000:8000 fastapi-api
|
||||
```
|
||||
|
||||
## API Endpoints
|
||||
|
||||
### Items
|
||||
- `GET /items` - List all items (with pagination)
|
||||
- `GET /items/{item_id}` - Get specific item
|
||||
- `POST /items` - Create new item
|
||||
- `PUT /items/{item_id}` - Update item
|
||||
- `DELETE /items/{item_id}` - Delete item
|
||||
|
||||
### Users
|
||||
- `GET /users` - List all users
|
||||
- `GET /users/{user_id}` - Get specific user
|
||||
- `POST /users` - Create new user
|
||||
|
||||
### Other
|
||||
- `GET /` - API information
|
||||
- `GET /health` - Health check
|
||||
- `GET /info` - Service information
|
||||
- `GET /stats` - API statistics
|
||||
|
||||
## Documentation
|
||||
|
||||
- Swagger UI: http://localhost:8000/docs
|
||||
- ReDoc: http://localhost:8000/redoc
|
||||
- OpenAPI JSON: http://localhost:8000/openapi.json
|
||||
|
||||
## Example Requests
|
||||
|
||||
### Create Item
|
||||
```bash
|
||||
curl -X POST "http://localhost:8000/items" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"id": 4,
|
||||
"name": "Monitor",
|
||||
"description": "4K Display",
|
||||
"price": 299.99,
|
||||
"in_stock": true
|
||||
}'
|
||||
```
|
||||
|
||||
### Get Items
|
||||
```bash
|
||||
curl "http://localhost:8000/items?skip=0&limit=10&in_stock=true"
|
||||
```
|
||||
|
||||
### Get Statistics
|
||||
```bash
|
||||
curl "http://localhost:8000/stats"
|
||||
```
|
||||
Reference in New Issue
Block a user