@vergelijkdirect/insurance-transmission-client
v1.3.67
Published
Partner-facing JavaScript/TypeScript client for the Vergelijkdirect Insurance Transmission API.
Downloads
1,145
Maintainers
Keywords
Readme
Insurance Transmission Client
Partner-facing JavaScript/TypeScript client for the Vergelijkdirect Insurance Transmission API.
Use this client to request insurance rates from all partner-enabled providers in one flow, receive one combined RateCollection, work with normalized rate models, store selected offers, and call supporting API services for comparison sessions, vehicle data, documents, validation, packages, loans, partner data, and lookups.
What It Can Do
- Send one category request through the comparison API and collect rates from all enabled providers, such as Moneyview, RISK, Rolls, or Vergelijkdirect, based on the allowed partner/funnel configuration.
- Request rates for supported insurance categories and merge provider responses into a
RateCollection. - Read normalized rate data such as company name, price, coverage, documents, raw API data, and provider-specific additional coverages.
- Store selected rates in browser
localStoragethroughLocalStorageAdapter, or through any custom adapter implementingStorageInterface. - Create, retrieve, update, and recalculate comparison sessions.
- Calculate insurance packages and package discounts.
- Validate common data such as email/address, phone, IBAN, and zipcode.
- Retrieve supporting data such as vehicle details, license-plate checks, caravan catalog data, pet breeds/filters, KvK data, SBI data, loan files, Moneyview documents, Google reviews, and partner metadata.
API Version
Use API v2.1 for partner integrations:
const config = {
api: {
baseUrl: 'https://api.vergelijkdirect.com/api',
version: 'v2.1',
credentials: {
accessKey: 'your-partner-access-key',
secret: 'your-partner-secret',
},
},
};Category comparison services build their base URL from this value:
{baseUrl}/{version}/comparisons/{category}With the recommended configuration, moped rates are called through:
https://api.vergelijkdirect.com/api/v2.1/comparisons/mopedExisting v2 integrations can keep using the client without partner credentials:
await client.configure({
api: {
baseUrl: 'https://api.vergelijkdirect.com/api',
version: 'v2',
},
});Partner Credentials
Partner credentials are optional on the client. Use them for Partner API v2.1 integrations; omit them for existing v2 integrations that do not require partner authentication.
Partner API v2.1 uses the same credentials as the Vergelijkdirect Partner API documentation. Configure them once on the client and every service request will include the partner credential headers automatically:
await client.configure({
api: {
baseUrl: 'https://api.vergelijkdirect.com/api',
version: 'v2.1',
credentials: {
accessKey: 'your-partner-access-key',
secret: 'your-partner-secret',
},
},
});By default the client sends:
X-Partner-Access-Key: your-partner-access-key
X-Partner-Secret: your-partner-secretIf an integration needs HTTP Basic authentication instead, set authType to basic. Use both only when a gateway or migration flow requires both authentication formats.
credentials: {
accessKey: 'your-partner-access-key',
secret: 'your-partner-secret',
authType: 'basic', // headers, basic, or both
}Some helper resources still use fixed API paths in the client, for example /v2/data, /v2/package, /v2/user, /v2/comparison, /v1 validation and legacy endpoints, /partner, and /scripts/comparison-module. If those backend endpoints are migrated to v2.1, update the related resource base URL before sharing a new client build.
Installation
npm install @vergelijkdirect/insurance-transmission-clientFor private distribution, install from the package registry or Git URL provided by Vergelijkdirect.
The published package entry points to compiled CommonJS files in src/js, so run npm run compile before packaging or publishing a new build.
Quick Start
Initialize the client before creating API services:
import {
InsuranceTransmissionClient,
LocalStorageAdapter,
MopedService,
} from '@vergelijkdirect/insurance-transmission-client';
const storage = new LocalStorageAdapter('itc:selected-rates');
const client = new InsuranceTransmissionClient(storage);
await client.configure({
api: {
baseUrl: 'https://api.vergelijkdirect.com/api',
version: 'v2.1',
credentials: {
accessKey: 'your-partner-access-key',
secret: 'your-partner-secret',
},
},
});
const mopedService = new MopedService();
const rates = await mopedService.getRates({
CommencingDate: '2026-06-09',
LicensePlate: 'D251LG',
TypeOfMoped: '63',
MopedSignCode: '4872',
Coverage: '1',
CatalogValue: 1099,
ValueAccessories: 0,
DriverZipCode: '5803DE',
DriverHouseNumber: '41',
DriverBirthdate: '1980-06-16',
ClaimFreeYears: '0',
BrokerID: '05250',
ReturnProvision: '0,00',
IncludeXml: false,
});
const selectedRate = rates.first();
console.log(selectedRate.getCompanyName());
console.log(selectedRate.getPrice());
console.log(selectedRate.getCoverage());
client.saveNew(selectedRate);Use complete request payloads from the API contract for production calls. Example development payloads are available in src/requests.
Using the Service Factory
When the category is dynamic, use ApiServiceFactory:
import {
ApiServiceFactory,
InsuranceTransmissionClient,
LocalStorageAdapter,
} from '@vergelijkdirect/insurance-transmission-client';
const client = new InsuranceTransmissionClient(new LocalStorageAdapter('itc'));
await client.configure({
api: {
baseUrl: 'https://api.vergelijkdirect.com/api',
version: 'v2.1',
credentials: {
accessKey: 'your-partner-access-key',
secret: 'your-partner-secret',
},
},
});
const category = 'car';
const service = ApiServiceFactory.get(category);
const rates = await service.getRates(requestPayload);
for (const rate of rates) {
console.log(rate.getCompanyName(), rate.getPrice());
}Supported factory categories are:
moped, motor, pet, home, caravan, bike, household, liability,
legal-assistance, car-business, car, travel, package, housing, loanMost of these services expose getRates. PackageService is returned by the same factory, but uses package-specific methods such as calculatePackage, calculatePackages, requestPackage, and annualDiscount.
Rate Results
Most rate calls return a RateCollection.
const count = rates.count();
const first = rates.first();
const last = rates.last();
const all = rates.all();
const rawRates = rates.toObject();
for (const rate of rates) {
const company = rate.getCompanyName();
const price = rate.getPrice();
const coverage = rate.getCoverage();
const raw = rate.getData();
const documents = await rate.getDocuments();
console.log(company, price, coverage, raw, documents.getConditionUrls());
}Provider-specific rate models can expose additional helper methods such as getAdditionalCoverages. For strongly typed integrations, the matching service method can also be used directly, for example getRiskAdditionalCoverages, getMoneyviewAdditionalCoverages, or getVergelijkdirectAdditionalCoverages.
Selected Rate Storage
InsuranceTransmissionClient stores selected rate data through the adapter passed to its constructor.
client.save(rate); // append a selected rate for its category
client.saveNew(rate); // replace previous selected rates for that category
client.get('moped').first(); // read selected moped rate
client.get('moped').count(); // count selected moped rates
client.remove('moped'); // clear selected moped ratesLocalStorageAdapter is browser-oriented and uses window.localStorage. For Node, SSR, or custom persistence, provide an adapter with get, save, put, remove, and all methods.
Supported Categories and Providers
The comparison module can override the enabled provider list per funnel. If no remote configuration is available, the client falls back to these built-in providers:
| Category | Built-in providers | Notes |
| --- | --- | --- |
| moped | risk, moneyview, vergelijkdirect, enra, unigarant | Rates, coverage comparison, vehicle find/check, additional coverages |
| motor | risk, moneyview, rolls, voogd | Rates, coverage comparison, vehicle find/check, additional coverages |
| car | risk, moneyview, rolls, ominimo, voogd | Rates, vehicle find/check, additional coverages |
| car-business | risk, rolls, voogd | Rates, Rolls business info, additional coverages |
| bike | risk, laka, enra, vergelijkdirect, fietszeker | Rates and Enra rate lookup |
| caravan | risk | Rates, coverage comparison, brands, models, types, catalog price |
| pet | petsecur | Rates, additional coverages, breeds, filters |
| home | risk, moneyview, rolls | Rates, home amount, find, addition |
| household | risk, moneyview, rolls | Rates and insured amount |
| housing | risk, moneyview, rolls | Rates and direct Moneyview rates |
| liability | risk, moneyview, nn | Rates |
| legal-assistance | risk, moneyview, vergelijkdirect | Rates and additional coverages |
| travel | risk, vergelijkdirect, moneyview | Rates and additional coverages |
| loan | dkm | Rates, field values, loan request |
Other Services
| Service | Purpose |
| --- | --- |
| ComparisonService | Create, get, update, and persist comparison sessions |
| PackageService | Calculate packages, discounts, annual discounts, package requests, and package saves |
| DataService | Vehicle lookup/checks, IBAN validation, maximum loan amount, loan documents, KvK search/profile/SBI, Kickbite tracking |
| DataValidationService | Email/address, phone, IBAN, and zipcode validation |
| DocumentService | Moneyview document lists and document models |
| PartnerService | Partner info and partner API version |
| ComparisonModuleService | Comparison-module initialization data and script source |
| GoogleService | Google reviews |
| UserService | User creation |
| V1Service | Legacy pet, health, bike, and car endpoints |
Comparison Sessions
After client.configure(...), comparison sessions can be loaded and updated:
import { ComparisonService } from '@vergelijkdirect/insurance-transmission-client';
const comparisonService = new ComparisonService();
const comparison = await comparisonService.get('65a7942e29a57');
const data = comparison.getData();
const user = comparison.getUser();
console.log(comparison.getId(), comparison.getFunnel(), data.all(), user);
const updatedComparison = await comparisonService.update(comparison);When a comparison is loaded, the client stores the comparison funnel in the injector. Category calls made afterwards include the X-Comparison-Funnel header so the API can resolve funnel-specific provider configuration.
Development
Install dependencies:
npm installRun the TypeScript build:
npm run compileRun tests:
npm testRun one Jest test by name:
npm run test -- api --testNamePattern="VehicleData"Browser Testing
Some behavior should be verified in a real browser because browser fetch, CORS, and localStorage can differ from the Node/Jest environment.
Install Browserify if needed:
npm install -g browserifyCompile the client and build a browser test bundle:
npm run compile
npm run browserify --arg=comparisonOpen src/tests/browser/index.html in a browser, open the console, and call:
makeItcCall();Change the relevant src/tests/browser/*.webtest.js file or JSON payload in src/tests/browser/requests when testing a specific flow.
Partner Integration Checklist
- Configure
baseUrlfor the target API environment. - Configure
api.versionasv2.1. - Call
client.configure(...)before constructing API services. - Use complete payloads from the API contract, with category-specific PascalCase fields.
- Pass partner/broker fields required by the API, such as
BrokerID,PartnerId, and provision/payment fields where applicable. - Use
RateCollectionand rate model helpers for display and selection. - Store selected rates through
saveNewwhen only one selected rate per category should exist. - Browser integrations must provide
window,localStorage, and a CORS-enabled API endpoint. - Before publishing to partners, run
npm testandnpm run compile.
