Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/woojiahao/govid-19
Go API for retrieving Covid-19 statistics
https://github.com/woojiahao/govid-19
api covid-19 gin gin-gonic go golang
Last synced: about 1 month ago
JSON representation
Go API for retrieving Covid-19 statistics
- Host: GitHub
- URL: https://github.com/woojiahao/govid-19
- Owner: woojiahao
- License: mit
- Created: 2020-03-05T00:12:14.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-06-14T03:52:09.000Z (over 4 years ago)
- Last Synced: 2023-02-28T06:32:26.813Z (almost 2 years ago)
- Topics: api, covid-19, gin, gin-gonic, go, golang
- Language: Go
- Size: 126 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# govid-19
Go API for retrieving Covid-19 statistics
## Changelog
- Data structure (see below)
- Time series data is now stored globally at runtime and updated daily when fetching a new set of results
- Removed the `/all` endpoint and replaced it with separate endpoints to handle different levels of data
analysis## Endpoints
- `GET /latest` - retrieve the latest statistics
- `GET /countries` - retrieve all countries
- `GET /ping` - ping to see if the server is running
- `GET /all` - retrieve statistics of all countries### GET /ping
Test if the server is running.
### GET /stats?show=country,state,date
### GET /all
Returns all statistics.
#### Query parameters
- `country` - case sensitive search for the country to return
- `state` - case sensitive search for the state to return
- `first` - get the first *n* number of records
- `last` - get the last *n* number of records
- `sort-total` - sort the results by the total value of each category
- `sort-records` - sort the results by the total value of each category#### Response structure
```json
{
"": {
"": {
"long": 0.0,
"lat": 0.0,
"confirmed": {
"total": 0,
"data": {
"": 0
}
},
"recovered": {
"total": 0,
"data": {
"": 0
}
},
"deaths": {
"total": 0,
"data": {
"": 0
}
}
}
}
}
```### GET /countries
Returns all available countries and states.
## Deployment
### Local
Ensure that you have Docker installed
Run the Docker compose file to load all necessary information.
```bash
$ docker-compose up
```## TODO
- [X] Auto-pull the repository every day
- [X] Compute the overall changes of the data since the data is accumulative now
- [ ] Deployment guide
- [X] Endpoint for country information
- [X] Fully migrate to use database to query data
- [ ] Use middleware to handle errors thrown
- [ ] Use bubble chart for showing most prominent countries
- [ ] Endpoint for grouping countries that have states## Lessons
- CORS must be configured before any API routes are created otherwise the client will encounter CORS issues
- GORM is limited in its functionality with tags; for foreign keys, the association must be declared during table
creation and not during struct declaration