Get employee details from BambooHR API

Introduction

This article is a part of a series of articles covering the BambooHR API in depth, and covers the specific use case of using the BambooHR API to Get employee details .
You can find all the other use cases we have covered for the BambooHR API along with a comprehensive deep dive on its various aspects like authentication, rate limits etc here.

BambooHR API: Get Employee Details

Overview

To retrieve detailed information about employees in BambooHR, you can utilize multiple APIs. This guide provides a step-by-step approach to get the first name and last name of all employees using the BambooHR API.

Step-by-Step Guide

Step 1: Get Employee Directory

First, you need to fetch the employee directory, which contains basic information about all employees.

Endpoint

GET https://api.bamboohr.com/api/gateway.php/{companyDomain}/v1/employees/directory

Headers
  • Accept: application/json
Path Parameters
  • companyDomain: The subdomain used to access BambooHR. For example, if you access BambooHR at https://mycompany.bamboohr.com, then the companyDomain is mycompany.
Sample Python Code
import requests

company_domain = 'your_company_domain'
url = f'https://api.bamboohr.com/api/gateway.php/{company_domain}/v1/employees/directory'
headers = {
    'Accept': 'application/json',
    'Authorization': 'Basic YOUR_API_KEY'
}

response = requests.get(url, headers=headers)
if response.status_code == 200:
    employees = response.json().get('employees', [])
    for employee in employees:
        print(f"First Name: {employee.get('firstName')}, Last Name: {employee.get('lastName')}")
else:
    print(f"Failed to retrieve employee directory: {response.status_code}")

Step 2: Get Employee Dependents (Optional)

If you need additional details such as employee dependents, you can use the following endpoint.

Endpoint

GET https://api.bamboohr.com/api/gateway.php/{companyDomain}/v1/employeedependents

Headers
  • Accept: application/json
Path Parameters
  • companyDomain: The subdomain used to access BambooHR.
Query Parameters
  • employeeid: The employee ID to limit the response to a specific employee.
Sample Python Code
employee_id = 'specific_employee_id'
url = f'https://api.bamboohr.com/api/gateway.php/{company_domain}/v1/employeedependents?employeeid={employee_id}'
response = requests.get(url, headers=headers)
if response.status_code == 200:
    dependents = response.json().get('Employee Dependents', [])
    for dependent in dependents:
        print(f"Dependent Name: {dependent.get('firstName')} {dependent.get('lastName')}")
else:
    print(f"Failed to retrieve employee dependents: {response.status_code}")

Knit for BambooHR API Integration

For quick and seamless access to BambooHR API, Knit API offers a convenient solution. By integrating with Knit just once, you can streamline the entire process. Knit takes care of all the authentication, authorization, and ongoing integration maintenance, this approach not only saves time but also ensures a smooth and reliable connection to your BambooHR API.

#1 in Ease of Integrations

Trusted by businesses to streamline and simplify integrations seamlessly with GetKnit.