diff --git a/README.md b/README.md
index 8fb2e962..865633db 100644
--- a/README.md
+++ b/README.md
@@ -36,6 +36,8 @@ Currently 2 different data-sources are available to retrieve the data:
* **csbs** - https://www.csbs.org/information-covid-19-coronavirus - U.S. County data that comes from the Conference of State Bank Supervisors.
+* **nyt** - https://github.com/nytimes/covid-19-data - The New York Times is releasing a series of data files with cumulative counts of coronavirus cases in the United States, at the state and county level, over time.
+
__jhu__ data-source will be used as a default source if you don't specify a *source parameter* in your request.
## API Reference
@@ -71,7 +73,8 @@ __Sample response__
{
"sources": [
"jhu",
- "csbs"
+ "csbs",
+ "nyt"
]
}
```
@@ -87,7 +90,7 @@ GET /v2/latest
__Query String Parameters__
| __Query string parameter__ | __Description__ | __Type__ |
| -------------------------- | -------------------------------------------------------------------------------- | -------- |
-| source | The data-source where data will be retrieved from *(jhu/csbs)*. Default is *jhu* | String |
+| source | The data-source where data will be retrieved from *(jhu/csbs/nyt)*. Default is *jhu* | String |
__Sample response__
```json
@@ -117,7 +120,7 @@ __Path Parameters__
__Query String Parameters__
| __Query string parameter__ | __Description__ | __Type__ |
| -------------------------- | -------------------------------------------------------------------------------- | -------- |
-| source | The data-source where data will be retrieved from *(jhu/csbs)*. Default is *jhu* | String |
+| source | The data-source where data will be retrieved from *(jhu/csbs/nyt)*. Default is *jhu* | String |
#### Example Request
```http
@@ -160,7 +163,7 @@ GET /v2/locations
__Query String Parameters__
| __Query string parameter__ | __Description__ | __Type__ |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | -------- |
-| source | The data-source where data will be retrieved from.
__Value__ can be: *jhu/csbs*. __Default__ is *jhu* | String |
+| source | The data-source where data will be retrieved from.
__Value__ can be: *jhu/csbs/nyt*. __Default__ is *jhu* | String |
| country_code | The ISO ([alpha-2 country_code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)) to the Country/Province for which you're calling the Endpoint | String |
| timelines | To set the visibility of timelines (*daily tracking*).
__Value__ can be: *0/1*. __Default__ is *0* (timelines are not visible) | Integer |
diff --git a/app/data/__init__.py b/app/data/__init__.py
index aef58e8c..9e0f34c1 100644
--- a/app/data/__init__.py
+++ b/app/data/__init__.py
@@ -1,9 +1,11 @@
"""app.data"""
from ..services.location.csbs import CSBSLocationService
from ..services.location.jhu import JhuLocationService
+from ..services.location.nyt import NYTLocationService
# Mapping of services to data-sources.
-DATA_SOURCES = {"jhu": JhuLocationService(), "csbs": CSBSLocationService()}
+DATA_SOURCES = {"jhu": JhuLocationService(), "csbs": CSBSLocationService(), "nyt": NYTLocationService()}
+# DATA_SOURCES = {"jhu": JhuLocationService(), "csbs": CSBSLocationService()}
def data_source(source):
diff --git a/app/enums/sources.py b/app/enums/sources.py
index b4538c45..9fc00744 100644
--- a/app/enums/sources.py
+++ b/app/enums/sources.py
@@ -8,3 +8,4 @@ class Sources(str, Enum):
jhu = "jhu"
csbs = "csbs"
+ nyt = "nyt"
diff --git a/app/services/location/nyt.py b/app/services/location/nyt.py
new file mode 100644
index 00000000..0f32f46e
--- /dev/null
+++ b/app/services/location/nyt.py
@@ -0,0 +1,54 @@
+"""app.services.location.nyt.py"""
+import csv
+from datetime import datetime
+
+from asyncache import cached
+from cachetools import TTLCache
+
+from ...utils import httputils
+from . import LocationService
+
+
+class NYTLocationService(LocationService):
+ """
+ Service for retrieving locations from New York Times (https://github.com/nytimes/covid-19-data).
+ """
+
+ async def get_all(self):
+ # Get the locations.
+ locations = await get_locations()
+ return locations
+
+ async def get(self, loc_id): # pylint: disable=arguments-differ
+ # Get location at the index equal to provided id.
+ locations = await self.get_all()
+ return locations[loc_id]
+
+
+# ---------------------------------------------------------------
+
+
+# Base URL for fetching category.
+BASE_URL = "https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv"
+
+
+@cached(cache=TTLCache(maxsize=1024, ttl=3600)) # TODO
+async def get_category(category):
+ pass
+
+
+@cached(cache=TTLCache(maxsize=1024, ttl=3600))
+async def get_locations():
+ """
+ Retrieves the locations from the categories. The locations are cached for 1 hour.
+
+ :returns: The locations.
+ :rtype: List[Location]
+ """
+ pass
+ '''
+ async with httputils.CLIENT_SESSION.get(BASE_URL) as response:
+ text = await response.text()
+
+ data = list(csv.DictReader(text.splitlines()))
+ '''