An API server side application that provides users the ability to plan trips with other users while estimating travel time and retrieving weather forecast upon arrival
This application is meant to be used either individually using or in conjunction with a Front End application. If using a front end application, all end points should provide sufficient data to renders views and a functional user interface. To see possible wire frames for what a FE application may look like using this data - Click Here π±οΈ
2οΈβ£ Install gems locally via bundle install from CL
3οΈβ£ Reset database via rails db:{drop,create,migrate} from CL
4οΈβ£ Start server via rails s from CL
5οΈβ£ Call endpoints in FE application or in Postman
In order to effectively call API endpoints, a few API keys will need to be obtained from third party APIs. Assuming 'bundle install' was ran as instructed in "Getting Started", the Figaro gem should be ready to go. Simply run 'bundle exec figaro install' from the CL to create an application yml file. This is where you will store the following keys from the following API's:
Map Quest's GeoCoding API
OpenWeather One Call API
Pexels Photo API
open_weather_key: <YOUR KEY HERE >
map_quest_key: <YOUR KEY HERE >
pexels_key: <YOUR KEY HERE >
V1 endpoints do not require an account. No user information or authentication token is needed to call the following end points.
GET /api/v1/forecast?location=keywest, fl
Content-Type: application/json
Accept: application/json
{
"data": {
"id": "null",
"type": "forecast",
"attributes": {
"current_weather": {
"datetime": "2022-04-27T11:38:05.000-04:00",
"sunrise": "2022-04-27T06:54:52.000-04:00",
"sunset": "2022-04-27T19:54:22.000-04:00",
"temp": 82.49,
"feels_like": 85.98,
"humidity": 64,
"visibility": 10000,
"conditions": "scattered clouds",
"icon": "03d"
},
"daily_weather": [
{
"date": "2022-04-27",
"sunrise": "2022-04-27T06:54:52.000-04:00",
"sunset": "2022-04-27T19:54:22.000-04:00",
"max_temp": 82.49,
"min_temp": 76.41,
"conditions": "light rain",
"icon": "10d"
},
{
"date": "2022-04-28",
"sunrise": "2022-04-28T06:54:07.000-04:00",
"sunset": "2022-04-28T19:54:51.000-04:00",
"max_temp": 77.52,
"min_temp": 76.75,
"conditions": "clear sky",
"icon": "01d"
},
{
"date": "2022-04-29",
"sunrise": "2022-04-29T06:53:22.000-04:00",
"sunset": "2022-04-29T19:55:21.000-04:00",
"max_temp": 77.52,
"min_temp": 76.82,
"conditions": "scattered clouds",
"icon": "03d"
},
{
"date": "2022-04-30",
"sunrise": "2022-04-30T06:52:38.000-04:00",
"sunset": "2022-04-30T19:55:50.000-04:00",
"max_temp": 78.13,
"min_temp": 77.14,
"conditions": "clear sky",
"icon": "01d"
},
{
"date": "2022-05-01",
"sunrise": "2022-05-01T06:51:55.000-04:00",
"sunset": "2022-05-01T19:56:20.000-04:00",
"max_temp": 78.28,
"min_temp": 77.45,
"conditions": "clear sky",
"icon": "01d"
}
],
"hourly_weather": [
{
"time": "11:00:00",
"temperature": 81.45,
"min_temp": 81.45,
"conditions": "broken clouds",
"icon": "04d"
},
{
"time": "12:00:00",
"temperature": 82.49,
"min_temp": 82.49,
"conditions": "light rain",
"icon": "10d"
},
{
"time": "13:00:00",
"temperature": 81.5,
"min_temp": 81.5,
"conditions": "scattered clouds",
"icon": "03d"
},
{
"time": "14:00:00",
"temperature": 80.55,
"min_temp": 80.55,
"conditions": "broken clouds",
"icon": "04d"
},
{
"time": "15:00:00",
"temperature": 79.59,
"min_temp": 79.59,
"conditions": "broken clouds",
"icon": "04d"
},
{
"time": "16:00:00",
"temperature": 78.6,
"min_temp": 78.6,
"conditions": "broken clouds",
"icon": "04d"
},
{
"time": "17:00:00",
"temperature": 77.7,
"min_temp": 77.7,
"conditions": "broken clouds",
"icon": "04d"
},
{
"time": "18:00:00",
"temperature": 77.72,
"min_temp": 77.72,
"conditions": "broken clouds",
"icon": "04d"
}
]
}
}
}
GET /api/v1/backgrounds?location=san diego, ca
Content-Type: application/json
Accept: application/json
{
"data": {
"id": "null",
"type": "image",
"attributes": {
"image": {
"location": "San Diego",
"image_url": "https://www.pexels.com/photo/marina-during-golden-hour-2157685/"
},
"credit": {
"source": "pexels.com",
"author": "Lucas Fonseca",
"logo": "https://images.pexels.com/lib/api/pexels-white.png"
}
}
}
}
POST /api/v1/road_trip
Content-Type: application/json
Accept: application/json
body:
{
"origin": "Denver,CO",
"destination": "Pueblo,CO",
"api_key": "jgn983hy48thw9begh98h4539h4"
}
{
"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"
}
}
}
}
All endpoints in Version 2 require an authentication token in order to call such endpoints. To obtain an authentication token please follow the instructions regarding the login endpoint
To obtain a authentication token, first register a user by posting your user data to the following endpoint as shown below. Your authentication token will be returned in the response (as shown below). The authentication token in the example response will not be valid. If you already have an account please log in using the sign_in route
POST /user
Content-Type: application/json
Accept: application/json
body:
{
"email": "[email protected]",
"password": "testpassword1",
"password_confirmation": "testpassword1"
}
{
"id": 6,
"created_at": "2022-08-03T16:54:09.895Z",
"updated_at": "2022-08-03T16:54:09.895Z",
"email": "[email protected]",
"authentication_token": "wK2ajsPhVuepe3VY_vZU"
}
POST /user/sign_in
Content-Type: application/json
Accept: application/json
body:
{
"email": "[email protected]",
"password": "testpassword1"
}
{
"id": 6,
"email": "[email protected]",
"authentication_token": "wK2ajsPhVuepe3VY_vZU"
}
To see the endpoint collection in it's entirety please review the following Postman documentation. This will show detailed information for endpoints pertaining to creating a trip, seeing all trips for a user, sending an invitation, viewing an invitation and accepting/requesting an invitation. All endpoints must include the following headers.
Headers:
key: 'X-User_Token'
value: '<unique auth token>'
key: 'X-User_Email'
value: '<unique user email>'