An API service that retrieves current weather, daily weather, and hourly weather by geographical location.
Report Bug
·
Request Feature
Table of Contents
This project utilizes the MapQuest API geocoding endpoint to retrieve the lattitude and longititute for a given location. These coordinates are then fed through to the WeatherAPI service to retrive the current weather, daily weather for the next 5 days, and the hourly weather. This data is then provided in the forecast endpoint.
This is a Ruby on Rails application which establishes API endpoints to be called in an application like Postman. To get started, please follow the directions below.
-
Clone the repo:
git clone git@github.com:DMTimmons1/sweater_weather.git
-
Install gems:
bundle install
-
To establish the database, run:
rails db:{drop,create,migrate}
-
To start up the local rails server, run:
rails server
Visit http://localhost:3000 in a web browser to confirm that the app is running, or use an application such as Postman to make your API calls and confirm the responses are accurate.
In order to use this application you will API keys from both MapQuest
and the WeatherAPI
.
Once you have these keys, they will be stored in the application.yml
file that you create.
- Run
bundle exec figaro install
, then open theapplication.yml
file. Here you'll add yourmapquest_key
andweather_api_key
.
mapquest_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxx
weather_api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Once sweater_weather
is correctly installed, run tests locally to ensure the repository will work as intended.
To test the entire RSpec suite, run:
bundle exec rspec
All tests should be passing if the installation was successful.
If any tests are not passing, please report which tests are not passing Here. We will issue an update/fix as soon as possible!
-
This API can be called locally using a program like Postman.
-
Note: Necessary parameters marked with {}
Note: pass location
as a paramater within this endpoint. the location should follow the format: 'City,State(Abbreviated)' ex: 'Denver,CO'
GET '/api/v1/forecast?location=<location>'
Response:
{
"data": {
"id": null,
"type": "forecast",
"attributes": {
"current_weather": {
"last_updated": "LAST_UPDATED",
"temperature": "TEMPERATURE",
"feels_like": "FEELS_LIKE",
"humidity": "HUMIDITY",
"uvi": "UVI",
"visibility": "VISIBILITY",
"conditions": "CONDITIONS",
"icon": "ICON_IMG_LINK"
},
"daily_weather": [
{
"date": "DATE",
"sunrise": "SUNRISE",
"sunset": "SUNSET",
"max_temp": "MAX_TEMP",
"min_temp": "MIN_TEMP",
"condition": "CONDITIONS",
"icon": "ICON_IMG_LINK"
}
],
"hourly_weather": [
{
"time": "TIME",
"temperature": "TEMPERATURE",
"conditions": "CONDITIONS",
"icon": "ICON_IMG_LINK"
}
]
}
}
}
Note: this response will return daily weather for 5 days and hourly weather for the next 24 hours. Only one is provided for each as an example of what the response looks like.
POST 'api/vi/users/'
Note: this endpoint will require the paramaters of the user passed into the body of the request as raw JSON. The formatting for this is shown below.
{
"email": "whatever@example.com",
"password": "password",
"password_confirmation": "password"
}
Note: Since we are passing this data in the body of the request as raw JSON, you will need to add the following headers to your request as well.
Content-Type: applicaton/json
Accept: application/json
Response:
{
"data": {
"id": "ID",
"type": "users",
"attributes": {
"email": "USER_EMAIL",
"api_key": "GENERATED_API_KEY"
}
}
}
POST 'api/vi/sessions'
Note: this endpoint will require the paramaters of the user passed into the body of the request as raw JSON. This request only requires the email and password of an existing user. The formatting for this is shown below.
{
"email": "whatever@example.com",
"password": "password"
}
Note: Since we are passing this data in the body of the request as raw JSON, you will need to add the following headers to your request once again.
Content-Type: applicaton/json
Accept: application/json
Response:
{
"data": {
"id": "1",
"type": "users",
"attributes": {
"email": "USER_EMAIL",
"api_key": "USER_API_KEY"
}
}
}
Sweater weather was created to satisfy the Turing Mod 3 final project.
See the official project requirements here.
- Consume multiple external APIs, and create functionallity using the return from one API, to get a specific return from another.
- Expose an API that creates an API key upon user creation.
- Expose an API that creates sessions based on the user login information.
- Demonstrate REST and CRUD fundamentals.
Dawson Timmons |
GitHub |