Fetch all Employee Details from Rippling API

Introduction

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

Fetch all Employee Details from Rippling API

Step 1: Get Current User Information

First, retrieve the current user information to ensure you have the correct access token and company ID.

import requests

url = "https://api.rippling.com/platform/api/me"
headers = {
    "Accept": "application/json",
    "Authorization": "Bearer YOUR_ACCESS_TOKEN"
}

response = requests.get(url, headers=headers)
current_user = response.json()
company_id = current_user['company']

Step 2: Fetch All Employees Including Terminated

Next, use the company ID to fetch all employees, including terminated ones. Ensure pagination for optimal performance.

def fetch_employees(company_id, limit=100, offset=0):
    url = "https://api.rippling.com/platform/api/employees/include_terminated"
    headers = {
        "Accept": "application/json",
        "Authorization": "Bearer YOUR_ACCESS_TOKEN"
    }
    params = {
        "EIN": company_id,
        "limit": limit,
        "offset": offset
    }
    response = requests.get(url, headers=headers, params=params)
    return response.json()

employees = []
offset = 0
while True:
    batch = fetch_employees(company_id, limit=100, offset=offset)
    if not batch:
        break
    employees.extend(batch)
    offset += 100

Step 3: Extract Required Employee Details

Finally, extract the first name, last name, email ID, and manager name for each employee.

employee_details = []
for employee in employees:
    details = {
        "first_name": employee.get("firstName"),
        "last_name": employee.get("lastName"),
        "email_id": employee.get("workEmail"),
        "manager_name": None
    }
    manager_id = employee.get("manager")
    if manager_id:
        manager_response = requests.get(f"https://api.rippling.com/platform/api/employees/{manager_id}", headers=headers)
        manager = manager_response.json()
        details["manager_name"] = manager.get("name")
    employee_details.append(details)

print(employee_details)

Knit for Rippling API Integration

For quick and seamless access to Rippling data, the 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 Rippling data.

#1 in Ease of Integrations

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