Java-Spring BootNo Comments

Covid4J – Spring Boot REST Api for Pulling Covid-19 Stats

Hey Folks! If you want to pull Covid-19 Stats for a Country or State or City, you can do it pretty easily by following the below code. And it does not need signup to any website nor any public/private keys. Covid4J sources the latest data from WHO website which is regularly updated. So, its always authentic and correct.

git Download the code from GitHub

Add the following Maven dependency:-


If you want to see how to use Covid4J to build a simple web application to fetch and display data, visit the link.

The Api exposes two endpoints which provide the Covid-19 stats for a Country or City/State. The path variables are not case-sensitive.

1. Get stats by Country:-

    public CovidStats getCovidDataByCountry(@PathVariable String country) throws IOException {

        return CovidApi.getAllCovidStatsForCountry(country);

2. Get stats by State/City:-

    public CovidStats getCovidDataByCityOrState(@PathVariable String cityOrState) throws IOException {

        return CovidApi.getAllCovidStatsForCityOrState(cityOrState);

Sample response returned by the Api for country ‘India’:-

    "name": "india",
    "type": "country",
    "confirmed": "321K",
    "recovered": "162K",
    "deaths": "9,195",
    "confirmedNewCases": "+11,929",
    "confirmedNewDeaths": "+311",
    "lastUpdated": "Updated less than 20 mins ago"

git Download the code from GitHub