Skip to content

This is an API that exposes 6 endpoints to find weather condition at roadtrip location. It utilizes Weather API and MapQuest Geolocation API to obtain roadtrip and weather info, Unsplash API for destination photo, and OpenLibary API to get books about location, and assigns secureRandom API keys.

Notifications You must be signed in to change notification settings

garussell/road_trip_planner_be

Repository files navigation

Road Trip Planner - Project README

Back-End API

Front-End Repo

Screenshot 2023-12-17 at 6 36 22 AM Screenshot 2023-12-17 at 6 36 09 AM

Table of Contents

  1. Learning Goals
  2. Project Description
  3. Example Code
  4. Setup
  5. Data Structure
  6. End Points
  7. Suggestions for Use
  8. Contributors

Learning Goals

  • Expose API with integration of multiple APIs, including requiring an authentication token.
  • Utilize ErrorSerializer and JSONAPI formatting.
  • Impliment caching to speed up process when search query includes location / city & state or latitude & longitude.
  • Complete application based on criteria from other developers.
  • Practice robust testing for poros, services, facades, and requests using mocking tool VCR.

Project Description

Road Trip Planner BE is a back-end project that exposes multiple API endpoints to make data available from MapQuest API, Unspash API, Open Library API, and Weather API. It allows the front-end to obtain JSON data that contains weather forecast information for a city, where the city and state are passed in the URL body as a location param. This API also utilizes OpenLibrary API to search for books about the destination location. Additionally, there is an endpoint that retrieves a background image from Unsplash API.

Example Code

Screenshot 2023-09-26 at 9 41 02 AM Screenshot 2023-09-26 at 9 43 01 AM Screenshot 2023-09-26 at 9 44 00 AM Screenshot 2023-09-26 at 9 44 18 AM

Setup

How to Use

  • Fork/Clone the BE repo
  • bundle install
  • rails s to start server at localhost:3000
  • Hit the endpoints with Postman or your front-end
  • Optionally: visit the front-end repo, fork/clone,
  • npm install then nmp start - select Y to run on localhost:3001 for React

Data Structure

  • data attribute contains id=null, type="forecast", and attributes.
  • attributes is an object that contains weather information: current_weather
  • current_weather holds the weather data as last_updated (format "2023-04-07 16:30"), temperature (float / Fahrenheit), feels_like (float / Fahrenheit), humidity (int or float), uvi (int or float), visibility (int or float), condition (string), icon (png string for current weather condition)
  • daily_weather holds array of next 5 days of weather data: date (format "2023-04-07"), sunrise (format "07:13 AM"), sunset (format "08:07 PM"), max_temp (float / Fahrenheit), min_temp (float / Fahrenheit), condition (string), icon (png string for weather condition)
  • hourly_weather holds array of 24 hours data for current day‘‘‘: time (format "22:00"), temperature (float / Fahrenheit), conditions (string / per hour), icon (png string for weather condition per hour)

End-Points

  • Get data as one endpoint: GET /api/v1/data - takes in 'location' as a param.
  • Get weather for a city: GET /api/v0/forecast?location=cincinatti,oh - data can be sent as params, units are optional ("imperial" or "metric") - Units default to imperial.
  • User Registration: POST /api/v0/users - raw data needs to be sent in the body of the request
  • Login: POST /api/v0/sessions - raw data needs to be sent in the body of the request
  • Create Roadtrip: POST /api/v0/road_trip - raw data needs to be sent in the body of the request, units are optional but can be passed as params ("imperial" or "metric") - Units default to imperial.
  • Search Books: GET /api/v0/book_search?location=#{location}&quantity=#{quantity} - data can be sent as params (location); quantity: optional, units: optional ("imperial" or "metric"). Units default to imperial.
  • Backgrounds: GET api/v0/backgrounds?location=#{location} - will return a photo of that location

Suggestions for Use

  1. Clone the application: Create a clone of this repository
  2. Obtain an API key: Sign-up with email, password, and confirmation password to receive a response with your unique API key (currently no limits)

Contributors

About

This is an API that exposes 6 endpoints to find weather condition at roadtrip location. It utilizes Weather API and MapQuest Geolocation API to obtain roadtrip and weather info, Unsplash API for destination photo, and OpenLibary API to get books about location, and assigns secureRandom API keys.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages