Hello, Guys welcome back to learn how Businesses can Check Health Status of Employees with Aarogya Setu. How employers can use the Aarogya Setu API to automatically check the health status and COVID-19 risk level of their staff members.

The Government of India recently launched an “open API” for Aarogya Setu, the world’s most popular contact tracing tool, which has over 110 million users across Android and iOS platforms. In layman’s terms, the Aarogya Setu API will assist enterprises in automatically checking the health status of their staff.
Currently, when an employee enters his or her office, they must show their Aarogya Setu app to the receptionist and are only permitted in if the status is green, indicating that they have not been in the presence of an infected person. Businesses may instantly know the risk level of their staff with the API in place.
How to Use the Aarogya Setu API
Register for the API at openapi.aarogyasetu.gov.in. This is not an easy process; you must write an email, and approval is granted only if your company has more than 50 employees. Assuming your company has been granted API access, here’s how to use it using Google Sheets and Google Scripts.
class AaryogyaSetu {
constructor({ apiKey, userName, password }) {
this.apiKey = apiKey;
this.userName = userName;
this.password = password;
this.api = "https://api.aarogyasetu.gov.in";
this.token = null;
}
/* Get the authorization token for the header
The token is valid for 1 hour */
getToken() {
if (this.token === null) {
const { token } = this.fetch("/token", {
username: this.userName,
password: this.password,
});
this.token = token;
}
return this.token;
}
/* Request Aarogya Setu status of a
user using phone number of the user */
getUserStatus(phone_number) {
const { request_id, request_status } = this.fetch("/userstatus", {
phone_number,
});
return request_status !== "Approved";
}
fetch(endpoint, payload) {
const mimeType = "application/json";
const headers = {
Accept: mimeType,
"Content-Type": mimeType,
"x-api-key": this.apiKey,
};
if (endpoint !== "/token") {
headers["Authorization"] = this.getToken();
}
const options = {
method: "POST",
contentType: mimeType,
headers: headers,
payload: JSON.stringify(payload),
};
const url = `${this.api}${endpoint}`;
const response = UrlFetchApp.fetch(url, options);
return JSON.parse(response.getContentText());
}
}
/* The API key can be found in your Aarogya Setu dashboard */
const main = () => {
const aarogyasetu = new AaryogyaSetu({
apiKey: "xyz1234",
username: "amit@labnol.org",
password: "India1234",
});
const phoneNumber = "9760008500";
const userStatus = aarogyasetu.getUserStatus(phoneNumber);
if (!userStatus) {
console.log(`The Aarogya Setu status of ${phoneNumber} was denied`);
}
};
A notification is issued to the Aarogya Setu user when you submit a request to the Aarogya Setu API asking the risk status of an employee identified by their phone number. If they approve the status (or if they have previously pre-approved the request), a POST request is made to your callback URL with the user’s help status.
With the doPost method, the Google Script may be published as a web app and used as a callback URL for the Open API.