Giter Club home page Giter Club logo

sweater_weather's Introduction

Sweater Weather

Sweater weather is an application that mimics working in a service-oriented architecture. This APIs job is to expose data that satisfies the front-end team’s requirements.

Table of Contents

Learning Goals

  • 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

Getting Started

To get started, clone this repo and run the following commands:

$ bundle install
$ rails db:{create,migrate}

Next you will need to run rails credentials:edit and setup you credentials file like this:

openweathermap:
  api_key: YOUR_API_KEY_HERE

mapquest:
  api_key: YOUR_API_KEY_HERE

unsplash:
  api_key: YOUR_API_KEY_HERE

To get your own api keys you can visit the following sites:

Endpoints

To hit these endpoints locally, start your rails server $ rails s

Each endpoint should be prefixed with http://localhost:3000/

Forecast

Retrieves current, daily, and hourly weather for a city.


GET /api/v1/forecast



Parameter      Type        Description

location       String      The city where you want to find the weather.
Default response

{
    "data": {
        "id": null,
        "type": "forecast",
        "attributes": {
            "current_weather": {
                "datetime": "2021-01-19 21:03:52 -0600",
                "sunrise": "2021-01-19 06:55:45 -0600",
                "sunset": "2021-01-19 16:59:45 -0600",
                "temperature": 46.2,
                "feels_like": 38.46,
                "humidity": 53,
                "uvi": 0,
                "visibility": 10000,
                "conditions": "scattered clouds",
                "icon": "03n"
            },
            "daily_weather": [
                {
                    "date": "2021-01-19",
                    "sunrise": "2021-01-19 06:55:45 -0600",
                    "sunset": "2021-01-19 16:59:45 -0600",
                    "max_temp": 53.26,
                    "min_temp": 41.81,
                    "conditions": "overcast clouds",
                    "icon": "04d"
                },
                {
                    "date": "2021-01-20",
                    "sunrise": "2021-01-20 06:55:19 -0600",
                    "sunset": "2021-01-20 17:00:47 -0600",
                    "max_temp": 44.83,
                    "min_temp": 34.05,
                    "conditions": "clear sky",
                    "icon": "01d"
                },

                ETC...
            ],
            "hourly_weather": [
                {
                    "time": "9:00PM",
                    "temperature": 46.2,
                    "wind_speed": "7 mph",
                    "wind_direction": "from NW",
                    "conditions": "scattered clouds",
                    "icon": "03n"
                },
                {
                    "time": "10:00PM",
                    "temperature": 44.47,
                    "wind_speed": "7 mph",
                    "wind_direction": "from W",
                    "conditions": "scattered clouds",
                    "icon": "03n"
                },

                ETC...
            ]
        }
    }
}

Backgrounds

Retrieves a background image for a city.


GET /api/v1/backgrounds



Parameter      Type        Description

location       String      The city you want to find an image for.
Default response

{
    "data": {
        "id": null,
        "type": "image",
        "attributes": {
            "image": {
                "photographer": "cody lannom",
                "profile": "https://unsplash.com/@codylannom",
                "hosting_site": "https://www.unsplash.com",
                "image_location": "nashville,tn",
                "image_url": "https://images.unsplash.com/photo-1586732538632-47e539174a1c?ixid=MXwxOTkzNDd8MHwxfHNlYXJjaHwxfHxuYXNodmlsbGUsdG58ZW58MHx8fA&ixlib=rb-1.2.1"
            }
        }
    }
}

User

Creates a new user.

POST /api/v1/users
Content-Type: application/json
Accept: application/json


Raw json body

{
  "email": "[email protected]",
  "password": "password",
  "password_confirmation": "password"
}
Default response

{
  "data": {
    "type": "users",
    "id": "1",
    "attributes": {
      "email": "[email protected]",
      "api_key": "jgn983hy48thw9begh98h4539h4"
    }
  }
}

Login

Authenticates an existing user.

POST /api/v1/sessions
Content-Type: application/json
Accept: application/json

Raw json body

{
  "email": "[email protected]",
  "password": "password"
}
Default response

{
  "data": {
    "type": "users",
    "id": "1",
    "attributes": {
      "email": "[email protected]",
      "api_key": "jgn983hy48thw9begh98h4539h4"
    }
  }
}

Road Trip

Allows a user to plan road trips.

POST /api/v1/road_trip
Content-Type: application/json
Accept: application/json

Raw json body

{
  "origin": "Denver,CO",
  "destination": "Pueblo,CO",
  "api_key": "jgn983hy48thw9begh98h4539h4"
}
Default response

{
  "data": {
    "id": null,
    "type": "roadtrip",
    "attributes": {
      "start_city": "Denver, CO",
      "end_city": "Pueblo, CO",
      "travel_time": "1 hour(s), 51 minutes",
      "weather_at_eta": {
        "temperature": 59.4,
        "conditions": "partly cloudy"
      }
    }
  }
}

sweater_weather's People

Contributors

taphill avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.