{"id":23955560,"url":"https://github.com/tnwei/msia-covid-api","last_synced_at":"2026-05-14T08:33:57.845Z","repository":{"id":47758822,"uuid":"256697748","full_name":"tnwei/msia-covid-api","owner":"tnwei","description":"API access to Malaysia COVID19 stats, drawing from MOH github release","archived":false,"fork":false,"pushed_at":"2024-05-22T05:37:21.000Z","size":72,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-06T15:44:44.745Z","etag":null,"topics":["covid-19","fastapi","malaysia","open-data","python"],"latest_commit_sha":null,"homepage":"https://msia-covid-api-371415.uc.r.appspot.com/docs","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tnwei.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-18T07:49:51.000Z","updated_at":"2024-05-22T05:37:25.000Z","dependencies_parsed_at":"2025-01-06T15:39:52.332Z","dependency_job_id":null,"html_url":"https://github.com/tnwei/msia-covid-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tnwei%2Fmsia-covid-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tnwei%2Fmsia-covid-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tnwei%2Fmsia-covid-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tnwei%2Fmsia-covid-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tnwei","download_url":"https://codeload.github.com/tnwei/msia-covid-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240459323,"owners_count":19804709,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["covid-19","fastapi","malaysia","open-data","python"],"created_at":"2025-01-06T15:35:37.204Z","updated_at":"2026-05-14T08:33:57.788Z","avatar_url":"https://github.com/tnwei.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# msia-covid-api\n\n![LGTM Grade](https://img.shields.io/lgtm/grade/python/github/tnwei/msia-covid-api)\n![License](https://img.shields.io/github/license/tnwei/msia-covid-api)\n\nQuery `https://msia-covid-api-371415.uc.r.appspot.com` for API access to [case count, testing, contact tracing](https://github.com/MoH-Malaysia/covid19-public), [and vaccination](https://github.com/CITF-Malaysia/citf-public) data, released and updated by the Malaysian Ministry of Health. \nDesign decisions documented in [ARCHITECTURE.md](ARCHITECTURE.md).\n\n## Usage\n\nCall the `/` endpoint for summary info. Returns new cases, deaths, cumulative vaccinations and tests. Example query: `https://msia-covid-api-371415.uc.r.appspot.com/?start_date=2021-08-08\u0026end_date=2021-08-10\u0026state=kl`\n\nCall the `detailed/` endpoint using the same params above to retrieve detailed statistics uploaded by MoH. Example query: `https://msia-covid-api-371415.uc.r.appspot.com/detailed/?start_date=2021-08-08\u0026end_date=2021-08-10\u0026state=kl`\n\nRefer to API docs for more info: `https://msia-covid-api-371415.uc.r.appspot.com/docs`\n\nUse the following param for both the summary and detailed endpoints:\n\n+ `start_date`: YYYY-MM-DD format e.g. 2021-08-09. If left blank, defaults to five days before current date.\n+ `end_date`: YYYY-MM-DD format e.g. 2021-08-13. If left blank, defaults to current date.\n+ `state`: Leave blank for national data, specify `allstates` for all states, specify specific state names (ref to docs) for state data.\n\n\n## Example usage for data analysis in Python\n\n``` python\nimport requests\nimport pandas as pd\n\nurl = \"https://msia-covid-api-371415.uc.r.appspot.com/\"\n\n# National summary for last 5 days\nnat_sum = requests.get(url).json()\nnat_sum_df = pd.DataFrame.from_dict(nat_sum, orient=\"index\")\n\n# State summary for last 5 days\nselangor_sum = requests.get(url + \"?state=selangor\").json()\nselangor_sum_df = pd.DataFrame.from_dict(selangor_sum, orient=\"index\")\n\n# Summary of all states for last 5 days\nallstates_sum = requests.get(url + \"?state=allstates\").json()\n# allstates returns a Dict of states\nselangor_sum_df_from_allstates = pd.DataFrame.from_dict(allstates_sum[\"selangor\"], orient=\"index\")\n\n# National detailed for last 5 days\nnat_detailed = requests.get(url + \"detailed\").json()\nprint(nat_detailed.keys())\n# dict_keys(['cases_malaysia', 'deaths_malaysia', 'vax_malaysia', 'tests_malaysia', 'hospital_malaysia', 'icu_malaysia', 'pkrc_malaysia'])\ncases_malaysia = nat_detailed[\"cases_malaysia\"]\n\n# State detailed for last 5 days\nselangor_detailed = requests.get(url + \"detailed?state=selangor\").json()\nprint(selangor_detailed.keys())\n# dict_keys(['cases_state', 'deaths_state', 'vax_state', 'tests_state', 'hospital_state', 'icu_state', 'pkrc_state'])\nselangor_cases_state = pd.DataFrame.from_dict(selangor_detailed[\"cases_state\"], orient=\"index\")\n\n# Detailed info of all states for last 5 days\nallstates_detailed = requests.get(url + \"detailed?state=allstates\").json()\nprint(allstates_detailed.keys())\n# dict_keys(['johor', 'kedah', 'kelantan', 'melaka', 'negerisembilan', 'pahang', 'perak', 'perlis', 'penang', 'sabah', 'sarawak', 'selangor', 'terengganu', 'kl', 'labuan', 'putrajaya'])\nselangor_cases_state_from_allstates = pd.DataFrame.from_dict(allstates_detailed[\"selangor\"][\"cases_state\"], orient=\"index\")\n```\n\n\n## cURL from terminal\n\n```\n$ curl https://msia-covid-api-371415.uc.r.appspot.com/ascii\n\nLatest update - Msia COVID19\nMOH data updated 3h 5m ago\nVax data updated 8h 49m ago\n\n            cases_new  deaths_new  dose1_cumul  \\\n-------------------------------------------------\n2021-08-09     17,236         212   15,959,596   \n2021-08-10     19,991         201   16,119,916   \n2021-08-11     20,780         211   16,347,422   \n2021-08-12     21,668         318   16,545,384   \n2021-08-13     21,468         277   16,707,566   \n\n            dose2_cumul  total_cumul  total_tests  \n-------------------------------------------------\n2021-08-09    9,048,634   25,008,230      153,561  \n2021-08-10    9,246,295   25,366,211      144,565  \n2021-08-11    9,516,141   25,863,563      169,444  \n2021-08-12    9,843,521   26,388,905      171,982  \n2021-08-13   10,144,199   26,851,765       -9,999  \n \n```\n\n## Data schema changes\n\nThe data schema in source repos are updated as new information is collected and reported, which can lead to the API breaking. For this purpose, changes to the data schema are tracked regularly for in these gists: [case statistics](https://gist.github.com/tnwei/507f582644b9a8c8be167637cea1e2fc) and [vaccination statistics](https://gist.github.com/tnwei/6b1e974ff0fa5463933c94964a831dd0). `generate-data-schema-changelog.py` is used to keep track of data schema updates. Example output: \n\n``` bash\n$ python generate-data-schema-changelog.py citf\n$ tail citf-schema-changes.txt -n 18 \nChanges in commit b222fd on (2021-08-18 01:07:06+08:00)\n-------------------------------------------------------\n+vax_malaysia.csv: pending\n+vax_state.csv: pending\n\n-vax_malaysia.csv: cansino\n-vax_malaysia.csv: pending1\n-vax_malaysia.csv: pending2\n-vax_state.csv: cansino\n-vax_state.csv: pending1\n-vax_state.csv: pending2\n\nChanges in commit 536c89 on (2021-08-28 04:35:57+08:00)\n-------------------------------------------------------\n+vax_malaysia.csv: cansino\n+vax_state.csv: cansino\n```\n\n## Changes\n\n+ (8ac732a) Migrated to GCP following Heroku free tier shutting down. I plan to keep this online as long as MoH keeps uploading data.\n+ (95668d2) Small update to adjust to upstream changes in data source. Been 4 years wow\n\n## License\n\nCode is released under the MIT license. For data, quoting the license from the source data repos:\n\n\u003e The data shared in this repository may be used per the terms of reference found in Appendix B of the Pekeliling Pelaksanaan Data Terbuka Bil.1/2015, accessible here:\n\u003e https://www.data.gov.my/p/pekeliling-data-terbuka\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftnwei%2Fmsia-covid-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftnwei%2Fmsia-covid-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftnwei%2Fmsia-covid-api/lists"}