This is simple REST API project using a modern stack with FastAPI.
Celery for background tasks
Redis for the message broker
PostgreSQL for the database
SqlAlchemy for ORM
Docker for containerization
Docker Compose for defining and running multi-container
Request URL | Description | HTTP |
---|---|---|
/users/{count} | Get random user data from randomuser.me/api and add database using Celery. (Delay = 10 sec) | POST |
/users/{count}/{delay} | Get random user data from randomuser.me/api and add database using Celery. | POST |
/users/{user_id} | Get user from database. | GET |
/weathers/{city} | Get weather data from api.collectapi.com/weather and add database using Celery. (Delay = 10 sec) | POST |
/weathers/{city}/{delay} | Get weather data from api.collectapi.com/weather and add database using Celery. | POST |
/weathers/{city} | Get weather from database. | GET |
/tasks/{task_id} | Get task status. | GET |
- Docker and Docker Compose
docker-compose up --build
POST /users/10
{
"task_id": "44178ce4-6f7a-4a6b-97fd-0de72a055360"
}
GET /users/5
{
"first_name": "Lorenzo",
"last_name": "Domínguez"
}
POST /weathers/erzincan
{
"task_id": "46f5f77a-5fd7-41dd-898b-235d5def4a70"
}
GET /weathers/erzincan
{
"erzincan": [
{
"date": "08.10.2022",
"day": "Cumartesi",
"description": "orta şiddetli yağmur",
"degree": 26.02
},
{
"date": "09.10.2022",
"day": "Pazar",
"description": "hafif yağmur",
"degree": 18.59
},
{
"date": "10.10.2022",
"day": "Pazartesi",
"description": "açık",
"degree": 17.85
},
{
"date": "11.10.2022",
"day": "Salı",
"description": "açık",
"degree": 17.49
},
{
"date": "12.10.2022",
"day": "Çarşamba",
"description": "kapalı",
"degree": 17.42
},
{
"date": "13.10.2022",
"day": "Perşembe",
"description": "hafif yağmur",
"degree": 19.42
},
{
"date": "14.10.2022",
"day": "Cuma",
"description": "hafif yağmur",
"degree": 16.37
}
]
}
GET /tasks/46f5f77a-5fd7-41dd-898b-235d5def4a70
{
"state": "SUCCESS"
}
Alperen Cubuk