Sweather Weather is a backend application that exposes several external API's to support an application for planning roadtrips based on weather conditions.
- Expose an API that aggregates data from multiple external APIs
- Expose an API that requires an authentication token
- Expose an API for CRUD functionality
- Determine completion criteria based on the needs of other developers
- Research, select, and consume an API based on your needs as a developer
๐ค Jes Jones
- Fork and Clone the repo
- Install gem packages:
bundle install
- Set up the database:
rails db:{drop,create,migrate,seed}
- Get API keys from MapQuest, OpenWeather, and Unsplash
- Enter API keys into your
application.yml
file
map_key: <enter your key here>
weather_key: <enter your key here>
background_key: <enter your key here>
Request
GET /api/v1/forecast?location=denver,co
Response
{
"data": {
"id": null,
"type": "forecast",
"attributes": {
"current_weather": {
"datetime": "2020-09-30 13:27:03 -0600",
"temperature": 79.4,
etc
},
"daily_weather": [
{
"date": "2020-10-01",
"sunrise": "2020-10-01 06:10:43 -0600",
etc
},
{...} etc
],
"hourly_weather": [
{
"time": "14:00:00",
"conditions": "cloudy with a chance of meatballs",
etc
},
{...} etc
]
}
}
}
Request
GET /api/v1/backgrounds?location=denver,co
Response
{
"data": {
"type": "image",
"id": null,
"attributes": {
"image": {
"location": "denver,co",
"image_url": "https://pixabay.com/get/54e6d4444f50a814f1dc8460962930761c38d6ed534c704c7c2878dd954dc451_640.jpg",
"credit": {
"source": "pixabay.com",
"author": "quinntheislander"
}
}
}
}
}
Request
POST /api/v1/users
Request body:
{
"email": "[email protected]",
"password": "password",
"password_confirmation": "password"
}
Response
{
"data": {
"type": "users",
"id": "1",
"attributes": {
"email": "[email protected]",
"api_key": "jgn983hy48thw9begh98h4539h4"
}
}
}
Request
POST /api/v1/sessions
Request body:
{
"email": "[email protected]",
"password": "password"
}
Response
{
"data": {
"type": "users",
"id": "1",
"attributes": {
"email": "[email protected]",
"api_key": "jgn983hy48thw9begh98h4539h4"
}
}
}
Request
POST /api/v1/road_trip
Request body:
{
"origin": "Denver,CO",
"destination": "Pueblo,CO",
"api_key": "jgn983hy48thw9begh98h4539h4"
}
Response
{
"data": {
"id": null,
"type": "roadtrip",
"attributes": {
"start_city": "Denver, CO",
"end_city": "Estes Park, CO",
"travel_time": "2 hours, 13 minutes"
"weather_at_eta": {
"temperature": 59.4,
"conditions": "partly cloudy with a chance of meatballs"
}
}
}
}
- MapQuest API
- OpenWeather API
- Unsplash API - please refer to this documentation for crediting image use