Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Latest commit

 

History

History
40 lines (21 loc) · 2.71 KB

README.en.md

File metadata and controls

40 lines (21 loc) · 2.71 KB

RiskLevelAPI

中文 | English

An API of the latest risk level regions on COVID-19 in China.

There is a frontend here, and visit panghaibin/COVID-Risk-Region for more information.

Feature

risklevel.py

  • Fetch the latest outbreak risk level data automatically from the National Health Commission website and save it as a .json file with the file name [update_time]-[hash_value].json (e.g. 2022041511-b38a8084.json).

  • When new data is fetched, the latest.json and info.json files are updated in addition to saving the current data. latest.json always holds the latest data, and info.json holds the filenames of all the original json files under the Archive folder and the corresponding timestamp of the update time.

GitHub Actions

run.py

  • The script will automatically fetch the latest data and push it to the api branch of the git repository. The script can be deployed to a server and run on the server, which can be used to automatically update the data. The git repository can be customized.

Usage

  • Clone the repo to local and run risklevel.py, then the outcome as .json files will be stored in the Archive folder.

  • Or fork this repository and enable GitHub Actions to automatically update the risk level data and push to the api branch of the repository.

  • You can also set up a cron job on the server to run the run.py script to update the risk level data, and push to the specified repository automatically.

About the token and key in the code

When making the request to acquire the data, you may notice there are some appeared private auth-keys like token or key in the code. Those are just clear texts in the JavaScript code of that website. Feel free to use.

The API version equipped with GitHub Actions

This API version is based on @KaikePing's original version, and adds the auto-update function based on GitHub Actions. You can use it as an API.