Skip to content

Commit 6975cb7

Browse files
committed
added csbs as service via middleware
2 parents 009cb80 + 54e5f94 commit 6975cb7

File tree

16 files changed

+1005
-238
lines changed

16 files changed

+1005
-238
lines changed

.all-contributorsrc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@
4343
"code",
4444
"test"
4545
]
46+
},
47+
{
48+
"login": "oliver-xapix-io",
49+
"name": "Oliver Thamm",
50+
"avatar_url": "https://avatars0.githubusercontent.com/u/13470858?v=4",
51+
"profile": "https://github.com/oliver-xapix-io",
52+
"contributions": [
53+
"doc"
54+
]
55+
},
56+
{
57+
"login": "MM-coder",
58+
"name": "Mauro M.",
59+
"avatar_url": "https://avatars1.githubusercontent.com/u/22800592?v=4",
60+
"profile": "https://maurom.dev",
61+
"contributions": [
62+
"doc"
63+
]
4664
}
4765
],
4866
"contributorsPerLine": 7,

LICENSE.md

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 57 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@
1515

1616
All requests must be made to the base url: ``https://coronavirus-tracker-api.herokuapp.com/v2/`` (e.g: https://coronavirus-tracker-api.herokuapp.com/v2/locations). You can try them out in your browser to further inspect responses.
1717

18+
### Picking data source
19+
20+
We provide multiple data-sources you can pick from, simply add the query paramater ``?source=your_source_of_choice`` to your requests. JHU will be used as a default if you don't provide one.
21+
22+
#### Available sources:
23+
24+
* **jhu** - https://github.com/CSSEGISandData/COVID-19 - Data repository operated by the Johns Hopkins University Center for Systems Science and Engineering (JHU CSSE).
25+
26+
* **csbs** - https://www.csbs.org/information-covid-19-coronavirus - US County data comes from Conference of State Bank Supervisors
27+
28+
* **... more to come later**.
29+
1830
### Getting latest amount of total confirmed cases, deaths, and recoveries.
1931
```http
2032
GET /v2/latest
@@ -41,6 +53,7 @@ GET /v2/locations
4153
"country": "Thailand",
4254
"country_code": "TH",
4355
"province": "",
56+
"last_updated": "2020-03-21T06:59:11.315422Z",
4457
"coordinates": {
4558
"latitude": "15",
4659
"longitude": "101"
@@ -56,6 +69,7 @@ GET /v2/locations
5669
"country": "Norway",
5770
"country_code": "NO",
5871
"province": "",
72+
"last_updated": "2020-03-21T06:59:11.315422Z",
5973
"coordinates": {
6074
"latitude": "60.472",
6175
"longitude": "8.4689"
@@ -91,6 +105,7 @@ GET /v2/locations/:id
91105
"country": "Norway",
92106
"country_code": "NO",
93107
"province": "",
108+
"last_updated": "2020-03-21T06:59:11.315422Z",
94109
"coordinates": { },
95110
"latest": { },
96111
"timelines": {
@@ -118,53 +133,55 @@ GET /v2/locations?timelines=0
118133
GET /v2/locations?source=csbs
119134
```
120135
```json
121-
{
122-
"Iowa":[
123-
{
124-
"coordinates":{
125-
"latitude":41.67149574,
126-
"longitude":-91.58805417
136+
{
137+
"locations": [
138+
{
139+
"coordinates": {
140+
"latitude": 40.71455,
141+
"longitude": -74.00714
142+
},
143+
"country": "US",
144+
"country_code": "US",
145+
"county": "New York",
146+
"id": 0,
147+
"last_updated": "2020-03-21 14:00 EDT",
148+
"latest": {
149+
"confirmed": 6211,
150+
"deaths": 43,
151+
"recovered": 0
127152
},
128-
"county":"Johnson",
129-
"latest":{
130-
"confirmed":22,
131-
"death":0,
132-
"new":0
133-
}
153+
"province": "New York",
154+
"state": "New York"
134155
},
135-
{
136-
"coordinates":{
137-
"latitude":41.68541161,
138-
"longitude":-93.57344237
156+
{
157+
"coordinates": {
158+
"latitude": 41.16319759,
159+
"longitude": -73.7560629
139160
},
140-
"county":"Polk",
141-
"latest":{
142-
"confirmed":6,
143-
"death":0,
144-
"new":0
145-
}
161+
"country": "US",
162+
"country_code": "US",
163+
"county": "Westchester",
164+
"id": 1,
165+
"last_updated": "2020-03-21 14:00 EDT",
166+
"latest": {
167+
"confirmed": 1385,
168+
"deaths": 0,
169+
"recovered": 0
170+
},
171+
"province": "Westchester",
172+
"state": "New York"
146173
},
147174
...
148-
...
149-
}
150-
```
151-
Additionally, you can also filter by state.
152-
```http
153-
GET /v2/locations?source=csbs&state=Iowa
154-
```
155-
156-
## Data
175+
]
176+
}
157177

158-
The data comes from the [2019 Novel Coronavirus (nCoV) Data Repository, provided
159-
by JHU CCSE](https://github.com/CSSEGISandData/2019-nCoV). It is
160-
programmatically retrieved, re-formatted and stored in the cache for one hour.
178+
## Wrappers
161179

162-
US County data comes from CSBS (https://www.csbs.org/information-covid-19-coronavirus)
163-
It is programmatically retrieved, re-formatted and stored in the cache for one hour.
180+
These are the available API wrappers created by the community. They are not necessarily maintained by any of this project's authors or contributors.
164181

165-
## Wrappers
182+
### Golang
166183

167-
These are the available API wrappers created by the community. They are not neccecarily maintained by any of this project's authors or contributors.
184+
* [Go-corona by @itsksaurabh](https://github.com/itsksaurabh/go-corona).
168185

169186
### C#
170187

@@ -235,6 +252,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
235252
<td align="center"><a href="https://github.com/bjarkimg"><img src="https://avatars2.githubusercontent.com/u/1289419?v=4" width="100px;" alt=""/><br /><sub><b>bjarkimg</b></sub></a><br /><a href="#question-bjarkimg" title="Answering Questions">💬</a></td>
236253
<td align="center"><a href="https://github.com/Bost"><img src="https://avatars0.githubusercontent.com/u/1174677?v=4" width="100px;" alt=""/><br /><sub><b>Bost</b></sub></a><br /><a href="https://github.com/ExpDev07/coronavirus-tracker-api/commits?author=Bost" title="Documentation">📖</a></td>
237254
<td align="center"><a href="https://github.com/gribok"><img src="https://avatars1.githubusercontent.com/u/40306040?v=4" width="100px;" alt=""/><br /><sub><b>GRIBOK</b></sub></a><br /><a href="https://github.com/ExpDev07/coronavirus-tracker-api/commits?author=gribok" title="Code">💻</a> <a href="https://github.com/ExpDev07/coronavirus-tracker-api/commits?author=gribok" title="Tests">⚠️</a></td>
255+
<td align="center"><a href="https://github.com/oliver-xapix-io"><img src="https://avatars0.githubusercontent.com/u/13470858?v=4" width="100px;" alt=""/><br /><sub><b>Oliver Thamm</b></sub></a><br /><a href="https://github.com/ExpDev07/coronavirus-tracker-api/commits?author=oliver-xapix-io" title="Documentation">📖</a></td>
256+
<td align="center"><a href="https://maurom.dev"><img src="https://avatars1.githubusercontent.com/u/22800592?v=4" width="100px;" alt=""/><br /><sub><b>Mauro M.</b></sub></a><br /><a href="https://github.com/ExpDev07/coronavirus-tracker-api/commits?author=MM-coder" title="Documentation">📖</a></td>
238257
</tr>
239258
</table>
240259

app/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ def create_app():
88
"""
99
Construct the core application.
1010
"""
11-
1211
# Create flask app with CORS enabled.
1312
app = Flask(__name__)
1413
CORS(app)

app/data/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from ..services.location.jhu import JhuLocationService
2+
from ..services.location.csbs import CSBSLocationService
3+
4+
# Mapping of services to data-sources.
5+
data_sources = {
6+
'jhu': JhuLocationService(),
7+
'csbs': CSBSLocationService()
8+
}
9+
10+
def data_source(source):
11+
"""
12+
Retrieves the provided data-source service.
13+
14+
:returns: The service.
15+
:rtype: LocationService
16+
"""
17+
return data_sources.get(source.lower())

app/location.py

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)