Back

Step by Step Guide to Building a Recruitee API Integration in JS

Aug 17, 20244 minute read

Introduction

Hey there, fellow code wrangler! Ready to supercharge your recruitment process? Let's dive into building a Recruitee API integration using JavaScript. This nifty tool will help you automate your hiring workflow and make your life a whole lot easier.

Prerequisites

Before we jump in, make sure you've got:

  • Node.js and npm (you're probably best friends with these already)
  • A Recruitee account with API credentials (if you don't have one, go grab it!)

Setting up the project

Let's get this party started:

mkdir recruitee-integration && cd recruitee-integration npm init -y npm install axios dotenv

Authentication

First things first, let's get you authenticated:

require('dotenv').config(); const axios = require('axios'); const api = axios.create({ baseURL: 'https://api.recruitee.com/c/YOUR_COMPANY_ID', headers: { 'Authorization': `Bearer ${process.env.RECRUITEE_API_TOKEN}` } });

Pro tip: Keep that API token safe in a .env file!

Making API requests

Now, let's make our first request:

async function getCandidates() { try { const response = await api.get('/candidates'); return response.data; } catch (error) { console.error('Oops!', error); } }

Core API endpoints

Recruitee's got your back with these main endpoints:

  • /candidates
  • /offers (that's Recruitee-speak for jobs)
  • /applications

Implementing key features

Let's put these endpoints to work:

async function createJob(jobData) { return await api.post('/offers', { offer: jobData }); } async function updateApplicationStatus(applicationId, status) { return await api.patch(`/applications/${applicationId}`, { application: { status } }); }

Error handling and rate limiting

Be nice to the API, and it'll be nice to you:

const axiosRetry = require('axios-retry'); axiosRetry(api, { retries: 3, retryDelay: axiosRetry.exponentialDelay, retryCondition: (error) => error.response.status === 429 });

Testing the integration

Don't forget to test! Here's a quick Jest example:

test('getCandidates returns data', async () => { const candidates = await getCandidates(); expect(candidates).toBeDefined(); });

Best practices

  • Cache responses when you can
  • Use environment variables for sensitive info
  • Keep your requests efficient to avoid hitting rate limits

Conclusion

And there you have it! You've just built a sleek Recruitee API integration. With this foundation, you can expand and customize to your heart's content. Happy coding, and may your applicant tracking be ever in your favor!