GithubHelp home page GithubHelp logo

reejit / openweatherapi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vcruzato/open-weather-api

0.0 0.0 0.0 6 KB

This service collects data from an Open Weather API and stores it as JSON data in a sqlite database.

Dockerfile 2.59% Python 97.41%

openweatherapi's Introduction

OpenWeather API

The API was built with Python 3 using the AIOHTTP Asynchronous HTTP Client / Server for asyncio framework.

This service collects data from an Open Weather API and stores it as JSON data in a sqlite database.

The free account of the OpenWeather API has a limit of 60 calls/minute so this API respects this limit.

Installation

Run docker-compose up to start the application.

Run docker-compose down stops containers and removes containers, networks, volumes, and images created by up.

Run docker-compose build or docker-compose up --build to rebuild.

Usage

The local API service must be available after the command * docker-compose up * on port 7007.

The POST endpoint:

/weather/unit of measurement/api key/list of city IDs

Units of measurement API Key City ID

The GET endpoint:

/weather/requestID

Create an account at OpenWeather API to generate a token to call their API.

In the test folder, there are two post_weather_city_id.py and get_weather_progress.py scripts available to test the API.

The post_weather_city_id.py is an async script responsible for calling the OpenWeather API passing as parameters the api Key and a list of city ID.

Example:

url = 'http://localhost:7007'
api_key = 'your api key here'
city_id_list = [3439525, 3439781, 3440645]

The request will return a unique ID, save it to see the progress of the request.

Example:

{"RequestID": "132e6d67-0424-49fe-88ad-c208d9d2ee62"}

The get_weather_progress.py is an async script returns with the percentage of the POST progress ID (collected cities completed) until the current moment..

Example:

url = 'http://localhost:7007'
request_ids = ['4615c7a3-2b4f-452f-bcb5-acb00765ca22','4615c7a3-2b4f-452f-bcb5-acb00765ca22']

The ID request will return the progress of the POST request or a message if it encounters any problems.

Example:

{"requestID": "132e6d67-0424-49fe-88ad-c208d9d2ee62", "progress": "77.8%"}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

openweatherapi's People

Contributors

vcruzato 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.