Introduction
The purpose of this document is to provide an introduction for NodeJS developers on how to utilize the PII Vault API along with code examples. This document should be consistent with what is seen in the corresponding repository, which is an open source program to help developers walk through how the API is used.
All requests in the API return a JSON response with some specific fields that make all API responses consistent regardless of what end point is called.
This document assumes the developer has some background in writing code in NodeJS along with Express and/or has experience calling REST APIs.
Setup
This accompanying project was set up in NodeJS using the latest version, 14.13. It is highly recommended to keep your environment up to date with the latest stable release. In addition, the following npm packages were used;
npm install express twilio -–save
npm install dotenv -–save
npm install axios -–save
These npm packages were used to put this example together.
Express
Standard web application framework normally used alongside node.
dotnev
Used to set up system environment variables.
Axios
Standard HTTP promise based library to make our HTTP calls.
Accompanying Classes
Several JavaScript classes were written in this project to assist in more mundane tasks of calling the API. This document will explain the points of interest so if a developer decides to write their own classes or methods, they fully understand what to expect.
utility.js
Hosts some of the more repetitive calls we will make across different end points in this example.
RequestApiToken
Used to call the end point to request the bearer token.
static RequestApiToken = async () => {
let tokenRequest = await axios.post(
“https://api.piivault.com/api/auth/login“,
{
AccountId: process.env[“ACCOUNT_ID”],
ApiKey: process.env[“API_KEY”],
}
);
let tokenResponse = tokenRequest.data;
if (tokenResponse.Success) {
return tokenResponse.Data.Token;
} else {
console.log(`Error Status = ${tokenResponse.Error.Status}\n`);
console.log(`Error Message = ${tokenResponse.Error.Message}\n`);
return “”;
}
};
GetSinglePerson and GetPeople
Get a single or array of a profile object represented in JSON.
End Points in this App
There are three requests we perform in this example, they are represented by the three routes
- /
- /get-poly-id
- /get-poly-id-bulk
When compiling, these are the three points the browser will navigate to.
The first end point simply gets the request token and prints it to the screen.
The second end point uses the token and calls the end point found at: https://api.piivault.com/api/profiles/GetPolyId
This endpoint can be called with the token via axios by the following command:
let polyIdRequest = await axios.put(
“https://api.piivault.com/api/profiles/GetPolyId”,
UtilityClass.GetSinglePerson(),
{ headers: { Authorization: `Bearer ${token}` } }
);
let polyIdResponse = polyIdRequest.data;
The response will be embodied in the “data” dot notation of the request object. All requests to the API will essentially look like this in this environment.
The final end point in this project will call the bulk poly id request.
Conclusion
This should get a developer started on how to use Python to call the PII Vault API. To get a full grasp of all of the possible end points with this API, you may consult the following URL: https://api.piivault.com/index.html. This should allow a developer to get started using this API and service to help with anonymizing sensitive data.