Weather API is a REST API service that allows us to know the weather of more than 200,000 cities around the world thanks to its integration with the OpenWeatherMap API, what are you waiting to test it?
Table of Contents
- Quick Install
- Authentication in Postman
- Response Example
- Postman Test
- API View Test
- Some technologies used
- Contributing
- Author
Install virtualenv with the following command:
pip install virtualenv
To create a virtual environment for your project, open a new command prompt, navigate to the folder where you want to create your project and then enter the following:
py -m venv project-name
To activate the environment, run:
project-name\Scripts\activate.bat
Use the package manager pip to install the requirements file.
pip install requirements.txt
To deploy the application, run:
python manage.py runserver
Finally, you should see something like this on your console:
System check identified no issues (0 silenced).
October 27, 2020 - 22:35:11
Django version 3.1.2, using settings 'technicalTest.settings.dev'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Creating a user:
Login and generate a Token API:
Set Token in headers:
Set params:
Get the data:
This is an example of what the API returns when used:
[
{
"location_name": "Bello, CO",
"temperature": "13 C°",
"wind_speed": "1 m/s",
"cloudiness": "40 %",
"presure": "1026 hpa",
"humidity": "100 %",
"sunrise": "10:48",
"sunset": "22:43",
"geo_coordinates": "[6.34,-75.56]",
"requested_time": "2020-10-27 22:29:11",
"forecast": {
"temp_max": "15 C°",
"temp_min": "12 C°"
}
}
]
Django REST framework is a powerful and flexible toolkit for building Web APIs.
Install using pip
...
pip install djangorestframework
Add 'rest_framework'
to your INSTALLED_APPS
setting.
INSTALLED_APPS = [
...
'rest_framework',
]
Full documentation for the project is available at docs.
The OpenWeatherMap service provides open weather data for more than 200,000 cities and any geo location that is available on their website and through their API.
Using their service requires registration where you can get your API key.
The above script requires requests
$ apt-get install python-pip
$ pip install requests
import request
api_data = config('API_DATA').format(city,country)
response = requests.get(api_data)
content = response.json()
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
Name | Alex Steven Nieto Arboleda |
---|---|
Contact | alsteven.nietoar@gmail.com |