Giter Site home page Giter Site logo

crosslibs / covid19-india-bigquery Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 255 KB

APIs for ingesting COVID 19 data into BQ and also fetching the data from BigQuery.

License: Apache License 2.0

Dockerfile 5.45% JavaScript 94.55%
covid-19 india mohfw ministry health family welfare government count api

covid19-india-bigquery's Introduction

API for COVID-19 India Data from official source, Ministry of Health and Family Welfare (mohfw.gov.in)

The APIs also help generate historical data by persisting changes into BigQuery. There are 4 APIs provided,

  • one to fetch data from historical data source (BQ)
  • one for writing provided data into the data source (BQ),
  • one for fetching current data from Ministry of Health and Family Welfare website and
  • one for ingesting the current data from Ministry of Health and Family Welfare website into the data source (BQ)

Please refer to the API documentation here to understand how to use them.

Create BigQuery table to store historical data

Setup

Create BigQuery dataset and table

Prerequisites

You need to have Google Cloud SDK installed and BigQuery and Deployment Manager enabled in your Google Cloud Platform project.

Create a BQ Dataset, Table and setup schema accordingly

# Set environment variables
export PROJECT_ID=<gcp-project-id-here>
export DATASET_NAME=<bq-dataset-name-here>
export TABLE_NAME=<bq-table-name-here>
export LOCATION=<insert-bq-location-here>

export BQ_DATASET=${PROJECT_ID}:${DATASET_NAME}
export BQ_TABLE=${BQ_DATASET}.${TABLE_NAME}

# Create a BQ dataset
bq mk -d --data_location=${LOCATION} --description="COVID-19 India historical data" ${BQ_DATASET}

# Create BQ table in the dataset
bq mk -t --description="COVID-19 India historical data" ${BQ_TABLE} ./schema.json

Now you can use this table to write data from MoHFW website or other historical data

Build and Start the APIs

Run locally

Prerequisites

You need to have Node.js version 12.0 or later installed in your machine. Please follow setup instructions from https://nodejs.org/en/download/ if you do not have Node.js installed already.

# Install dependencies
npm install

# Run the HTTP server (starts the HTTP server on PORT 8080)
GCP_PROJECT_ID=<project-id> BQ_LOCATION=<bq-location> BQ_DATASET_ID=<bq-dataset-id> BQ_TABLE_NAME=<bq-table-name> npm start

Run in Docker

# Build Docker image
docker build -t covid19-india-bigquery:latest .
# Start container
docker run -p 8080:8080 -e GCP_PROJECT_ID=<project-id> -e BQ_LOCATION=<bq-location> -e BQ_DATASET_ID=<bq-dataset-id> -e BQ_TABLE_NAME=<bq-table-name> -d covid19-india-bigquery:latest

API Documentation

You can view the documentation at http://localhost:8080/v1/api-docs once the server is up and running.

Alternatively, you can also view the API documentation by clicking here.

Access the number of COVID-19 cases in India and across the states as of a specific date/time through this API

HTTP GET http://localhost:8080/v1/data?date=

e.g.

HTTP GET http://localhost:8080/v1/data?date=2020-04-15T12:30:00Z

Ingest data of COVID-19 cases in India and across the states as of a specific date/time into BigQuery table created above through this API

HTTP PUT http://localhost:8080/v1/data

Please see the API documentation to understand the request body required.

Fetch current data of COVID-19 cases in India and across the states directly from MoHFW website.

HTTP GET http://localhost:8080/v1/data/current

Ingest current data of COVID-19 cases in India and across the states into BigQuery table directly from MoHFW website.

HTTP PUT http://localhost:8080/v1/data/current

Please see the API documentation to understand the request body required.

Contact

For any queries, please reach out to me at [email protected] or post an issue in the repo.

covid19-india-bigquery's People

Contributors

crosslibs avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.