Skip to main content

API Client / JavaScript Wrapper

The API Client is a JavaScript Wrapper for the Recruiting API. It provides a Promise-based wrapper that handles the communication with the recruiting API.

Usage

You can use the API Client directly in the browser or in Node.js. Please refer to the following parts that suit your use case.

info

The API Client requires you to set up CORS.

Customer ID

The API Client requires your customer ID. Please see the Web Components documentation for more information about the customer ID.

Browser

You can include the API Client via a script tag in your application. The API Client offers two versions:

The file for the ECMAScript module version is available at: https://recruiting.mindkey.com/api-client/api-client.mjs.

info

The ECMAScript version is recommended, because it will run in isolation and does not interfere with any existing JavaScript on your website.website.

Please note that this version is only compatible with modern browsers (all current browsers except Internet Explorer). For the latest information on browser support, please refer to "Can I use: JavaScript modules: dynamic import".

Non-module variant

In case you prefer a non-module variant, you can also use https://recruiting.mindkey.com/api-client/api-client.js. However, we recommend to use the module variant.

According to the documentation you can simply construct one of the clients and request data.

Examples
import { VacancyClient } from 'https://recruiting.mindkey.com/api-client/api-client.mjs';

const vacancyClient = new VacancyClient('https://recruiting.mindkey.com/api');
const vacancies = await vacancyClient.getVacancyList('<insert-your-customer-id-here>', 'en-US');
Full example
<!doctype html>
<html>
<head>
<title>Vacancies Table</title>
</head>
<body>
<table id="vacanciesTable">
<thead>
<tr>
<th>ID</th>
<th>Description</th>
</tr>
</thead>
<tbody></tbody>
</table>

<script type="module">
import { VacancyClient } from 'https://recruiting.mindkey.com/api-client/api-client.mjs';

let vacancies = [];

// Function to populate the table
function populateTable() {
const table = document.getElementById('vacanciesTable');
const tbody = table.getElementsByTagName('tbody')[0];

// Clear existing table rows
tbody.innerHTML = '';

// Add new rows with data from vacancies array
vacancies.forEach(function (vacancy) {
const row = tbody.insertRow();

const idCell = row.insertCell();
idCell.appendChild(document.createTextNode(vacancy.id));

const descriptionCell = row.insertCell();
descriptionCell.appendChild(document.createTextNode(vacancy.description));
});
}

const vacancyClient = new VacancyClient('https://recruiting.mindkey.com/api');

async function fetchVacancies() {
try {
vacancies = await vacancyClient.getVacancyList('<insert-your-customer-id-here>', 'en-US');
populateTable();
} catch (error) {
console.error('Error fetching vacancies:', error);
}
}

// Call the fetchVacancies function to retrieve and populate the table with vacancies
fetchVacancies();
</script>
</body>
</html>

Global version

<script src="https://recruiting.mindkey.com/api-client/api-client-global.js"></script>

Almost works like the ECMAScript module version but instead of constructing one of the clients directly, you can find them on window.mindkey.apiClient:

Examples
const vacancyClient = new window.mindkey.apiClient.VacancyClient('https://recruiting.mindkey.com/api');
const vacancies = await vacancyClient.getVacancyList('<insert-your-customer-id-here>', 'en-US');
Full example
<!doctype html>
<html>
<head>
<title>Vacancies Table</title>
<script src="https://recruiting.mindkey.com/api-client/api-client-global.js"></script>
</head>
<body>
<table id="vacanciesTable">
<thead>
<tr>
<th>ID</th>
<th>Description</th>
</tr>
</thead>
<tbody></tbody>
</table>

<script>
let vacancies = [];

// Function to populate the table
function populateTable() {
const table = document.getElementById('vacanciesTable');
const tbody = table.getElementsByTagName('tbody')[0];

// Clear existing table rows
tbody.innerHTML = '';

// Add new rows with data from vacancies array
vacancies.forEach(function (vacancy) {
const row = tbody.insertRow();

const idCell = row.insertCell();
idCell.appendChild(document.createTextNode(vacancy.id));

const descriptionCell = row.insertCell();
descriptionCell.appendChild(document.createTextNode(vacancy.description));
});
}

const vacancyClient = new window.mindkey.apiClient.VacancyClient('https://recruiting.mindkey.com/api');

async function fetchVacancies() {
try {
vacancies = await vacancyClient.getVacancyList('<insert-your-customer-id-here>', 'en-US');
populateTable();
} catch (error) {
console.error('Error fetching vacancies:', error);
}
}

// Call the fetchVacancies function to retrieve and populate the table with vacancies
fetchVacancies();
</script>
</body>
</html>

Node

We're offering a npm package @mindkey/recruiting-api-client. To install it use:

npm install @mindkey/recruiting-api-client

After that, you're ready to use it in Node either via CommonJS, ES-Module or TypeScript.

Examples

// Import for ES-Module/TypeScript
import { VacancyClient } from '@mindkey/recruiting-api-client';

// Import for CommonJS
const { VacancyClient } = require('@mindkey/recruiting-api-client');
Full example
const { VacancyClient } = require('@mindkey/recruiting-api-client');

async function main() {
const client = new VacancyClient('https://recruiting.mindkey.com/api');
const result = await client.getSimpleVacancyList('<insert-your-customer-id-here>', 'en-US');

console.log(result);
}

main();

Documentation

Take a look at the code documentation to learn about all available clients, methods and their responses.