Giter Site home page Giter Site logo

weather-graphql-api's Introduction

weather-graphQL-api

This is a Weather API Microservice using GraphQL and Symfony 4.
It accepts a city name and return a pediction of its whether on a random day.

Usage:

Input: city name and country code divided by comma, use ISO 3166 country codes.
Output: One day weather prediction

Installation

download the repo then:

  • $ cd weather-graphQL-api/
  • $ composer install
  • $ php bin/console server:run

the Api is exposed on http://localhost:8000/weather/ (with a trailing slash).
This url to work, expects a POST request with a parameter named query that contains the GraphQL query.

Usage

This is the schema and how to use it

Input: in the Weather parameter, pass the city name and country code divided by comma, use ISO 3166 country codes Output: One day weather prediction

type Query {
  weather: Weather(city: String!)
}

type Weather {
  date_timestamp: Int!
  date_text: String!
  condition: String! # sunny, couldy...
  description: String
  cloudiness: Int
  atmosphere: Atmosphere
  wind: Wind
}

type Atmosphere {
  temperature: Float!
  pressure: Float!
  sea_level: Float!
  grnd_level: Float!
  humidity: Float!
}

type Wind {
  speed: Float!
  degree: Float!
}

Example

This is an example of the weather query

 {
  weather(city: "fes,ma") {
    date_text
    condition
    description
    atmosphere {
      temperature
    }
  }
}

And this is the result:

{
    "data": {
        "weather": {
            "date_text": "2019-05-26 12:00:00",
            "condition": "Clear",
            "description": "clear sky",
            "atmosphere": {
                "temperature": 301.751
            }
        }
    }
}

To see the results in action, you can use Postman! like in the image below or you can test it on local with the playground page http://localhost:8000/graphiql

Demo

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.