Git Product home page Git Product logo

bh-cv-api's Introduction

Bahrain (COVID-19) statistics

This is a json interface for the summary of cases table in Bahrain Ministry of Health website.

You can just call the above link and it will return the data as a josn object.

Returned data

key Description
total_check Total Tested
existing_cases Active Cases
stable_existing_cases Stable cases
critical_existing_cases Critical cases
recovered_cases Discharged
deaths Deaths
request_timestamp Unix time to know when the data fetched.

Quick integration

curl --location --request GET 'https://cvapi.awal.pw/'

More example available in the example folder.

Errors

the following errors might happen:

  • if there is no data cache and the server can not fetch data from the Bahrain MOH website it will return:
{"erorr": "connection error"}
  • if there is a cached data and the server can not fetch data from the Bahrain MOH website, cache data will be returned.

The code

The server code created with python3 using BeautifulSoup to parse the HTML table from Ministry of Health website

following library are required to run the code locally:

Files:

  • data_source.py: will load the data and return dictionary will all the keys
  • server.py: will run a local server at http://localhost:8181

Note:

  • The data is being cached in cvbh.json so it will only request new data every 5 minutes.
  • The function get_data can take a (True|False) value to enable data cache.

To run the server locally just run

python3 server.py

Extra

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.