{"id":15554445,"url":"https://github.com/markertmer/sweater_weather","last_synced_at":"2026-05-09T23:42:43.038Z","repository":{"id":41831075,"uuid":"484816700","full_name":"markertmer/sweater_weather","owner":"markertmer","description":"API to expose weather forecasts based on location and timeframe for a FE application","archived":false,"fork":false,"pushed_at":"2022-05-10T14:32:40.000Z","size":212,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-10T23:46:45.691Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/markertmer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-23T17:44:14.000Z","updated_at":"2022-04-23T17:44:53.000Z","dependencies_parsed_at":"2022-08-11T18:50:26.581Z","dependency_job_id":null,"html_url":"https://github.com/markertmer/sweater_weather","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markertmer%2Fsweater_weather","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markertmer%2Fsweater_weather/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markertmer%2Fsweater_weather/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markertmer%2Fsweater_weather/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markertmer","download_url":"https://codeload.github.com/markertmer/sweater_weather/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241096152,"owners_count":19908926,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T15:01:28.831Z","updated_at":"2026-05-09T23:42:38.003Z","avatar_url":"https://github.com/markertmer.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sweater Weather \n### version 1\n\nA Rails API that consumes four external APIs to expose weather data via endpoints that can be easily called from a front end application. Through HTTP `get` and `post` requests, the client can obtain:\n- A detailed weather forecast for a supplied location, including current, daily and hourly weather data, along with embeddable icon links that reflect the conditions.\n- An embeddable link to a relevant image for the location.\n- \"Road Trip\" data, including the travel time between an origin and destination, and arrival forecast info.\n- \"Munchies\" data, which includes travel time and the name and address of a restaurant near the destination.\n\nThere is also functionality for registering a new user and logging in an existing user. Users are supplied with a unique API key, which is required to consume the \"Road Trip\" endpoint.\n\n## Getting Started\n\nFollow these instructions to get a copy of this project up and running on your local machine. See [Deployment](#deployment) for information on setting up the API in a production environment.\n\n### Prerequisites\n\n- Ruby 2.7.4\n- Rails 5.2.7\n- Obtain a [MapQuest API](https://developer.mapquest.com/) key.\n- Obtain an [OpenWeather API](https://openweathermap.org/api) key.\n- Obtain a [Yelp Fusion API](https://www.yelp.com/developers/documentation/v3) key.\n- Obtain an [Usplash API](https://unsplash.com/developers) key.\n\n### Installing\n\nFork this repo and clone it down to your machine.\n\nNavigate into the home directory, install the gems, and setup a local database:\n```\n$ cd sweater_weather\n$ bundle install\n$ rails db:create\n$ rails db:migrate\n```\n\nCreate an `application.yml` file using Figaro, then open it for editing. The file is git-ignored, so it may not show up in your GUI.\n```\n$ bundle exec figaro install\n$ (open in your text editor) config/application.yml\n```\n\nAdd your API credentials to `application.yml` file using the syntax shown:\n```YML\nunsplash_key: your_unsplash_key\nopenweather_key: your_openweather_key\nmapquest_key: your_mapquest_key\nyelp_key: your_yelp_key\n```\n\nEnsure all tests are passing.\n```\n$ bundle exec rspec\n=\u003e ..........................................................................\n\n=\u003e Finished in 0.74927 seconds (files took 1.62 seconds to load)\n=\u003e 74 examples, 0 failures\n\n=\u003e Coverage report generated for RSpec to /sweater_weather/coverage. 1392 / 1397 LOC (99.64%) covered.\n```\n\nYou should now be able to establish a local server to start answering requests.\n```\n$ rails s\n```\n\n## Endpoints\n\nUsing a tool such as [Postman](https://www.postman.com/), you can send HTTP requests to the API according to the following guidelines.\n\n### 1. Authentication\nNew users may register for an API key, which is required for some features.\n\nTo register with Sweater Weather, send a `POST` request to this URI, prepended with your local server, such as `http://localhost:3000`.\n```\napi/v1/users\n```\nA JSON payload must be sent in the body of this request to set the user's email and password:\n```JSON\n{\n  \"email\": \"man@dude.com\",\n  \"password\": \"abc123\",\n  \"password_confirmation\": \"abc123\"\n}\n```\n\nThe response will include your unique Sweater Weather API key in the body.\n```JSON\n{\n    \"data\": {\n        \"type\": \"users\",\n        \"id\": 7,\n        \"attributes\": {\n            \"email\": \"man@dude.com\",\n            \"api_key\": \"XU3YM4C9FBPY80ZVC19VTJDN7899BTKUQP1SRPBGF0NJV2GSQODE2SMQPQ3K15E54RIOA\"\n        }\n    }\n}\n```\n\nExisting users can retrieve their API key with this `POST` request...\n```\n/api/v1/sessions\n```\n... and this body:\n```JSON\n{\n  \"email\": \"man@dude.com\",\n  \"password\": \"abc.123\"\n}\n```\n\n### 2. Forecast\nThis `GET` request will obtain weather forecast data for the `location` entered in the params. For example:\n```\n/api/v1/forecast?location=boise,id\n```\nThe response will look like this:\n```JSON\n{\n    \"data\": {\n        \"id\": \"null\",\n        \"type\": \"forecast\",\n        \"attributes\": {\n            \"location\": {\n                \"city\": \"Boise\",\n                \"state\": \"ID\",\n                \"country\": \"US\"\n            },\n            \"current\": {\n                \"date\": \"April 27\",\n                \"description\": \"overcast clouds\",\n                \"feels_like_temp\": 49, # in degrees Farenheit\n                \"high_temp\": 60, # in degrees Farenheit\n                \"humidity\": 60, # percent\n                \"icon_url\": \"http://openweathermap.org/img/wn/04d@2x.png\", # link to icon representing the conditions\n                \"low_temp\": 42, #in degrees Farenheit\n                \"sunrise\": \"6:42 AM\", # local time of today's sunrise\n                \"sunset\": \"8:41 PM\", # local time of today's sunset\n                \"temperature\": 52, #degrees Farenheit\n                \"time\": \"11:55 AM\", # current local time\n                \"uv_index\": 0,\n                \"uv_description\": \"low\",\n                \"visibility\": 6.2 # in miles\n            },\n            \"hourly\": [ # weather data for the next 48 hours\n                {\n                    \"time\": \"11:00 AM\",\n                    \"temperature\": 52, \n                    \"icon_url\": \"http://openweathermap.org/img/wn/04d@2x.png\"\n                },\n                {...},\n            ],\n            \"daily\": [ # weather data for the next 8 days\n                {\n                    \"name\": \"Wednesday\",\n                    \"description\": \"broken clouds\",\n                    \"high_temp\": 60,\n                    \"icon_url\": \"http://openweathermap.org/img/wn/04d@2x.png\",\n                    \"low_temp\": 42,\n                    \"precip_amount\": 0.0, # in millimeters\n                    \"precip_chance\": 9 # percent\n                },\n                {...},\n            ]\n        }\n    }\n}\n```\n\n### 3. Background Image\nUse this `GET` request to obtain a link to a relevant image to be used for the forecast background of the city specified in the `location` param.\n```\n/api/v1/backgrounds?location=grandjunction,co\n```\nThe response body will look like this:\n```JSON\n{\n    \"data\": {\n        \"id\": \"null\",\n        \"type\": \"image\",\n        \"attributes\": {\n            \"image\": {\n                \"url\": \"https://images.unsplash.com/photo-1602980045401-3f4479127ad5?crop=entropy\u0026cs=srgb\u0026fm=jpg\u0026ixid=MnwzMjIxNjF8MHwxfHNlYXJjaHwxfHxncmFuZGp1bmN0aW9uJTJDY298ZW58MHx8fHwxNjUxMDgyODY5\u0026ixlib=rb-1.2.1\u0026q=85\",\n                \"alt_text\": null\n            },\n            \"credits\": {\n                \"source_name\": \"Malachi Brooks\",\n                \"source_url\": \"https://unsplash.com/@mebrooks01\",\n                \"unsplash_url\": \"https://unsplash.com/?utm_source=sweater_weather\u0026utm_medium=referral\"\n            }\n        }\n    }\n}\n```\n**NOTICE:** You MUST credit photos according to the Unsplash API [guidelines](https://unsplash.com/documentation#guidelines--crediting). \n\n### 4. Munchies\nThis `GET` request will provide a restaurant at your destination, along with the local forecast for the day of your arrival. It requires parameters for `start` and `destination` locations, along with a `food` type search query, such as `fast food`, `barbecue`, `tapas`, `olive garden`, `sushi`, `gyros`, `pizza`, or `mexican`. _**It's MMMMMunchilicious!\u003csup\u003eTM\u003c/sup\u003e**_\n```\n/api/v1/munchies?start=lafayette,in\u0026destination=nashville,tn\u0026food=bbq\n```\nResponse:\n```JSON\n{\n    \"data\": {\n        \"id\": \"null\",\n        \"type\": \"munchie\",\n        \"attributes\": {\n            \"destination_city\": \"Nashville, TN\",\n            \"travel_time\": \"5 hours 20 minutes\",\n            \"forecast\": {\n                \"summary\": \"clear sky\",\n                \"temperature\": \"67\" # degrees Farenheit\n            },\n            \"restaurant\": {\n                \"name\": \"Peg Leg Porker\",\n                \"address\": \"903 Gleaves St, Nashville, TN 37203\"\n            }\n        }\n    }\n}\n```\n\n### 5. Road Trip\nNOTE: The user must [obtain an API key](#1-authentication) in order to consume this endpoint.\n\nA `POST` request. Supply an `origin` and `destination` to obtain the travel time and local weather forecast data for the arrival time and destination. Example:\n```\n/api/v1/road_trip\n```\nInclude the locations, along with your Sweater Weather `api_key`, in the body of your request like so:\n```JSON\n{\n  \"origin\": \"seattle, wa\",\n  \"destination\": \"louisville, ky\",\n  \"api_key\": \"TZRAZA4QI0E3HW3T61U2H3VW06F32KYR2KAOST070DD0XIY1Z0OXHUCRBEN7AGLIXKFAX\"\n}\n```\nThe response will look something like this:\n```JSON\n{\n    \"data\": {\n        \"id\": \"null\",\n        \"type\": \"roadtrip\",\n        \"attributes\": {\n            \"start_city\": \"Seattle, WA\",\n            \"end_city\": \"Louisville, KY\",\n            \"travel_time\": \"33 hours 25 minutes\",\n            \"weather_at_eta\": {\n                \"temperature\": 55,\n                \"conditions\": \"overcast clouds\"\n            }\n        }\n    }\n}\n```\n\u003c!-- ## Caching\nLow-level caching is enabled for all external API calls in the `app/services` directories. You will need to enable local caching in your local environment:\n```\n$ rails dev cache\n```\n --\u003e\n## Deployment\n\nThe Sweater Weather API will be deployed via [Heroku](herokuapp.com) very soon! Check back here for updates.\n\n## Tools\nSweater Weather was built with the help of these tools:\n  - [Postman](https://www.postman.com/) - Used for testing HTTP requests in the local dev environment.\n  - [Webmock](https://github.com/bblimke/webmock) - This gem was particularly helpful in stubbing HTTP requests for the project's [RSpec](https://rubygems.org/gems/rspec/versions/3.5.0) testing suite.\n  - [Atom](https://atom.io/) - Because I don't know any better! But it proved to be a robust tool for supporting a dynamic workflow while editing this project and referencing 10+ other repos that were kept open for the duration of the v1 build. \n\n## Authors\n\n  - **[Mark Ertmer](https://github.com/markertmer)**\n\n## Contributing\n\nPlease [contact me](https://github.com/markertmer) if you are interested in contributing to this API.\n\n## License\n\nAll rights reserved. But feel free to make a copy and make it yours!\n\n## Acknowledgments\n  - Sweater Weather was the final project of Module 3 in the [Back End Engineering Program](https://backend.turing.edu/) at **[Turing School of Software and Design](https://turing.edu/)**.\n  - It was submitted on April 27, 2022 and received a passing grade from instructor [Jamison Ordway](https://github.com/jamisonordway).\n  - The project was built to the specification of [these requirements].\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkertmer%2Fsweater_weather","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkertmer%2Fsweater_weather","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkertmer%2Fsweater_weather/lists"}