Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.
/ bh-cv-api Public archive

Coronavirus statistics from Bahrain Ministry of Health

License

Notifications You must be signed in to change notification settings

plusmnt/bh-cv-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Coronavirus statistics from Bahrain Ministry of Health

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages