The Weather API provides weather reports for any country in three languages: English, German, and Bengali. It sources its data from Open Weather.
This guide provides instructions for setting up and running the Weather API locally using Docker Compose.
Make sure you have the following installed on your local machine:
-
Clone the Repository
git clone [email protected]:mohidex/openweather-api.git cd openweather-api
-
Docker Compose Configuration
Customize the following environment variables for the 'web' service:
- SECRET_KEY=<django-secret-key> - MIGRATE_ON_STARTUP=True - OPEN_WEATHER_API_KEY=<your-api-key> - CACHE_TIMEOUT_IN_MIN=<cached-timeout> # could be 5, 10, 60
-
Build and Run the Containers
Execute the following command to build and run the Docker containers:
docker compose up --build
This command will pull the necessary images, build the application, and start the development server.
-
Access the API
Once the containers are running, you can access the Weather API at http://localhost:8000/api/v1/weather.
-
Access Swagger Documentation
Explore the API using the Swagger documentation at http://localhost:8000/docs to test different endpoints and view the API specifications.
-
Stopping the Containers
To stop the containers, press
Ctrl + C
in the terminal where thedocker compose up
command is running.If you want to stop and remove the containers, use the following command:
docker compose down
-
city
(Query Parameter): The name of the city for which you want to get the weather report.- Type: String
- Required: Yes
-
Accept-Language
(Header Parameter): The preferred language for the response.- Type: String
- Enum: en-us, de, bn
- Default: en-us
-
200
(Successful Response)- Content Type:
application/json
- Example:
{ "status": "success", "data": { "city": "Dhaka", "temperature": { "current": 16.99, "minimum": 16.99, "maximum": 16.99 }, "humidity": 59, "pressure": 1017, "wind": { "speed": 0, "direction": "North" }, "description": "haze" } }
- Content Type:
-
400
(Bad Request)- Content Type:
application/json
- Example:
{ "status": "error", "message": "Bad Request: No city provided." }
- Content Type:
-
404
(Not Found)- Content Type:
application/json
- Example:
{ "status": "error", "message": "Not Found: No city found with the provided query." }
- Content Type:
-
503
(Service Unavailable)- Content Type:
application/json
- Example:
{ "status": "error", "message": "Service Unavailable: The service is currently unavailable. Please try again later." }
- Content Type:
For any inquiries, please contact: [email protected]
This project is licensed under the MIT License.