This is a simple Flask API that provides real-time weather information for a specified city. The API is integrated with the Weatherstack service to fetch accurate and up-to-date weather data.
Project description
# Weather Information API
This is a simple Flask API that provides real-time weather information for a specified city. The API is integrated with the Weatherstack service to fetch accurate and up-to-date weather data.
## Getting Started
These instructions will help you set up and run the Weather Information API on your local machine.
### Prerequisites
- Python (version 3.6 or higher)
- Flask
- Requests library
Install the required dependencies using the following command:
```bash
pip install Flask requests
API Key
To use this API, you need to obtain an API key from Weatherstack. Visit Weatherstack to sign up and get your API key.
Configuration
Open the app.py
file and replace 'YOUR_API_KEY'
with your actual Weatherstack API key.
# Weatherstack API key (replace 'YOUR_API_KEY' with your actual API key)
API_KEY = 'YOUR_API_KEY'
Running the API
Run the Flask application using the following command:
python main.py
The API will be accessible at http://127.0.0.1:5000/weather
.
API Endpoints
Get Weather Information
- Endpoint:
/weather
- Method:
GET
- Parameters:
city
(required): The name of the city for which you want to get weather information.
Example Request:
curl http://127.0.0.1:5000/weather?city=London
Example Response:
{
"city": "London",
"temperature": 15,
"conditions": "Partly cloudy"
}
Error Handling
- If the city parameter is not provided, the API will return a
400 Bad Request
error.
{
"error": "City parameter is required"
}
- If the specified city is not found, the API will return a
404 Not Found
error.
{
"error": "City not found"
}
Acknowledgments
- Flask: Flask Documentation
- Weatherstack: Weatherstack API Documentation
Feel free to customize this README based on your specific project structure and additional features.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file simple-weather-api-by-ys-0.1.2.tar.gz
.
File metadata
- Download URL: simple-weather-api-by-ys-0.1.2.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77bbbb1cd07452ef9034b15ec12bf60431af2f8d5a7d954e4d7e7fa6f1e2eab4 |
|
MD5 | d742f2f482a7620268320ec330090b36 |
|
BLAKE2b-256 | a4d09ee0d86ab2a814d64698886a79ac61ff2cb27f6a60a9c907cff5892a55ed |
File details
Details for the file simple_weather_api_by_ys-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: simple_weather_api_by_ys-0.1.2-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ee7d8e944b9cce19247a7c95c9ba6a60cbf89c724827e35bc04c43788d43a82 |
|
MD5 | 92aab4cb6ff916795766a5b077ffdc7c |
|
BLAKE2b-256 | fb0fdc1c1f48953c3fc84985c0e31afc37263ded4f87e304ad76673aab1175e9 |