To install dmvic
using npm:
npm install dmvic
using yarn:
yarn install dmvic
import { initialize } from 'dmvic';
async function initializeDmvic() {
await initialize({
secrets: {
username: "your_dmvic_username",
password: "your_dmvic_password",
clientId: "your_dmvic_client_id",
environment: "staging",
},
certificates: {
sslCert: "./path/to/your/dmvic/cert.pem",
sslKey: "./path/to/your/dmvic/key.pem",
},
});
}
initializeDmvic();
Note: DMVIC requires that you cache your authentication token for 7 days. Make sure your authentication logic stores the token you receive in the response.
If you do not cache your token, your application will call the authentication API on every request. This can quickly lead to rate limiting and may result in your DMVIC account being locked.
import { authenticate } from 'dmvic';
import redis from 'redis';
const redisClient = redis.createClient({
url: 'redis://localhost:6379',
})
await redisClient.connect()
async function authenticateDMVICRequests() {
const dmvicAuthToken = await authenticate();
// store the token in a redis cache
await redisClient.set('dmvic:auth:token', dmvicAuthToken, { EX: 604800 });
}
authenticateDMVICRequests();
Note: The insurance company ID required as input in the
checkStockStatus()
function is provided by DMVIC and is not an arbitrary number. See below the list of supported companies and their matching DMVIC IDs.
import { checkStockStatus } from 'dmvic';
import redis from 'redis';
const redisClient = redis.createClient({
url: 'redis://localhost:6379',
})
await redisClient.connect()
async function checkInsuranceCompanyStockCount(insuranceCompanyId) {
// retrieve the token from your cache
const authToken = await redisClient.get('dmvic:auth:token');
return checkStockStatus(authToken, insuranceCompanyId);
}
checkInsuranceCompanyStockCount();
The stock count response is organised according to the types of motor vehicle insurance certificates.
{
"CertificateClassificationID": 1,
"ClassificationTitle": "Class A - PSV Unmarked",
"Stock": 100
},
Company Name | DMVIC Member Company ID |
---|---|
AIG | 12 |
AMACO | 11 |
APA | 14 |
Britam Insurance | 15 |
Cannon | 32 |
CIC | 16 |
Definite Insurance | 49 |
Directline | 18 |
Fidelity Insurance | 19 |
First Assurance | 20 |
GA Insurance | 21 |
Geminia | 22 |
Heritage | 42 |
ICEA Lion | 23 |
Kenindia | 27 |
Intraafrica | 24 |
Invesco | 29 |
Jubilee Allianz | 26 |
Kenya Alliance | 29 |
Kenya Orient | 28 |
Madison | 30 |
Mayfair | 31 |
MUA | 35 |
Monarch | 43 |
Old Mutual | 45 |
Occidental | 33 |
Pacis | 34 |
Pioneer | 36 |
Sanlam | 39 |
Star Discover | 47 |
Takaful | 40 |
Trident | 44 |
Xplico | 46 |
This function will retrieve a certificate PDF document given a certificate number. Certificate PDFs are printed and stuck on a motor vehicle's windscreen or other easily visible location on the motor vehicle. This document will contain the details of the insurance cover for the motor vehicle.
For a successful request, the API responds with a URL containing the link to a downloadable PDF file. Opening the link on a browser automatically downloads the certificate PDF document.
{
"URL": "https://insurancedevelopment.blob.core.windows.net/immutable-cancelled-cert/49935_0137372C3723135FD26E3A643C99C5F54FF811A8.pdf?sv=2021-08-06&st=2025-05-20T05%3A53%3A32Z&se=2025-05-20T18%3A53%3A32Z&sr=b&sp=r&sig=WnfcVyCLMLPcggpTimvDQEILUt%2FZYPm4XhzsOde5VDk%3D"
}
This library is licensed under the GNU License.
- Initialization
- Authentication
- Check Insurance Company Stock Status
- Get certificate PDF document