Skip to content

Abdirahiim/covidtrackerapiwrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CovidSharp

CovidSharp is a C# API wrapper for the Coronavirus tracking API

NuGet NuGet GitHub stars GitHub forks HitCount

Installation

You can install it as a nuget package

Usage

Call the Library

using CovidSharp;
  • Declares the instance of the library
CoronavirusData data = new CoronavirusData();

Get the Latest Data

  • Fetches the latest worldwide data
 Console.WriteLine("Confirmed: " + data.LatestConfirmed());
 Console.WriteLine("Recovered: " + data.LatestRecovered());
 Console.WriteLine("Deaths: " + data.LatestDeaths());

Get Data by country code

  • Use a country code and fetch the latest data of that country
 Console.WriteLine("Denmark Confirmed: " + data.FromCountryConfirmed("DK"));
 Console.WriteLine("Denmark Recovered: " + data.FromCountryRecovered("DK"));
 Console.WriteLine("Denmark Deaths: " + data.FromCountryDeaths("DK"));

Get Data by country name

  • Use a country code and fetch the latest data of that country
   Console.WriteLine("China Confirmed: " + data.FromCountryNameConfirmed("China"));
   Console.WriteLine("China Recovered: " + data.FromCountryNameRecovered("China"));
   Console.WriteLine("China Deaths: " + data.FromCountryNameDeaths("China"));

Get Data by ID

You can use the associated ID of a province or country to get the desired information

  • This code gets the latest data of Denmark using ID instead of a country code
 Console.WriteLine("Denmark ID Confirmed: " + data.FromIDConfirmed("94"));
 Console.WriteLine("Denmark  ID Recovered: " + data.FromCountryRecovered("94"));
 Console.WriteLine("Denmark ID Deaths: " + data.FromCountryDeaths("94"));
  • Get the province name associated with an ID, in this case the ID of 92 is associated with the Faroe Islands province
  Console.WriteLine("Name of the Faroe Islands: " + data.FromIDProvince("92"));
  • Get the country name associated with an ID, in this case the ID of 92 is associated with the Faroe Islands province
  Console.WriteLine("Name of the country of the Faroe Islands: " + data.FromIDCountry("92"));
  • Get the latitude associated with an ID
  Console.WriteLine("Denmark Latitude: " + data.FromIDLatitude("94"));
  • Get the longitude associated with an ID
  Console.WriteLine("Denmark Longtitude: " + data.FromIDLongitude("94"));

Constribution

If you want to contribute, go ahead and do a PR