---
title: "How to get employee dependent data from BambooHR API (Python Example)"
description: "Learn how to build a BambooHR API integration to get employee dependent details with code examples."
source_url: "https://www.getknit.dev/blog/get-employee-dependent-data-using-bamboohr-api-python-example"
page_type: "blog"
---

_This is an educational blog post from Knit's blog: “How to get employee dependent data from BambooHR API (Python Example)”._

# How to get employee dependent data from BambooHR API (Python Example)

## Introduction

This article is a part of a series of articles covering the [BambooHR](https://md.getknit.dev/integration/bamboohr) API in depth, and covers the specific use case of using the [BambooHR](https://md.getknit.dev/integration/bamboohr) API to Get employee details.

> If you are looking for a comprehensive directory of BambooHR API endpoints to discover what endpoints will fit best for your use case, check our [BambooHR API Directory](http://www.getknit.dev/blog/bamboohr-api-directory-qdlfBw).

### 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 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
```

##### 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
```

##### 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](https://www.getknit.dev/integration/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](https://www.getknit.dev/integration/bamboohr) API.


## Related pages

- [How Knit works](https://md.getknit.dev/how-knit-works)
- [Unified API product](https://md.getknit.dev/products/unified-api)
