vmarcella / openweather

An openweather API take home project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Openweather API takehome project

GitHub repo size Snyk Vulnerabilities for GitHub Repo GitHub issues Twitter Follow

Description

This application is a simple api that allows users to retrieve the weather for any city and then fill in their mood for said weather in the city.

How to run

The first thing you need to do is have a working copy of node 8.16.0+ (version written on) and npm. The next thing you'll need is a copy of the project which you can obtain with:

git clone https://github.com/C3NZ/openweather.git

After getting the project folder, you can then do:

cd openweather
npm install

This will install project dependencies/dev tools used to aid the project. To run the api, you can then do:

npm run start

After that, you are good to go! Refer to the API documentation for working with the API.

Resources

Openweather

API

Table of Contents

getWeatherByCity

Get the weather by city name through the query parameters

Parameters

  • req The express Request context
  • res The express Response context

Examples

GET /api/v1/weather/city?city=San Francisco&country=us -> {SF weather data}

Returns any A JSON response

getWeatherByID

Get the weather by id through the query parameter: id

Parameters

  • req The express Request context
  • res The express Response context

Examples

GET /api/v1/weather/id?id=5391959 -> {SF weather data}

Returns any A JSON response

getWeatherByZipCode

Get the weather by city name

Parameters

  • req The express Request context
  • res The express Response context

Examples

GET /api/v1/weather/zip?zip=94102&country=us -> {SF weather data}

Returns any A JSON response

getWeatherByName

Get the weather by the city name and the country

Parameters

  • cityName
  • country String The country for the city (optional, default "us")
  • cityName-null String The zip code for the city

Examples

weather.getWeatherByName("San Francisco", country="us") -> {SF weather data from OW}

Returns Object the weather object containing weather data about the particular area.

getWeatherById

Get the weather by the city ID

Parameters

  • cityID String The city ID for the city

Examples

weather.getWeatherById(cityId) -> {City ID weather from OW}

Returns Object the weather object containing weather data about the particular area.

getWeatherByZip

Get the weather by the zipcode and country

Parameters

  • zip String The zip code for the city
  • country String The country for the city (optional, default "us")

Examples

weather.getWeatherByZip(94102, country='us') -> {SF weather data from OW}

Returns Object the weather object containing weather data about the particular area.

handleRequest

Contact the openweather api to get weather data

Parameters

  • url
  • url-null String The endpoint url with query strings attached to make a request to.

Returns Object the weather object containing weather data about the particular area.

getMoods

Get all the moods ever stored on the server

Parameters

  • req The Express request context
  • res The Express response context

Examples

GET /api/v1/moods -> {Mood object}

Returns Object All of the stored mood data about cities

getMood

Get all the moods ever stored on the server

Parameters

  • req The Express request context
  • res The Express response context

Examples

GET /api/v1/mood/:moodId -> {Mood object}

Returns Object The mood object for the requested mood object

getMoodsByCity

Get all the moods ever stored on the server

Parameters

  • req The Express request context
  • res The Express response context

Examples

GET /api/v1/moods/city?city=San Francisco -> [{List of mood objects}]

Returns Object the mood of an object for a particular city

postMood

Send a mood about a city to the server

Parameters

  • req The Express request context
  • res The Express response context

Examples

POST /api/v1/moods?city=San Francisco { mood: "Happy"} -> {Mood object}

Returns Object The created mood object with information about the weather

About

An openweather API take home project


Languages

Language:JavaScript 100.0%