How to fetch employees from Rippling using Python

Rippling stands as a potent HRIS that helps businesses manage payroll, benefits, employee onboarding, and more. Given all its use cases, it likely stores rich data on employees.

We'll help you retrieve employee data from Rippling's API (using Python) by breaking down every step you need to follow.

Authentication configuration

To pull employee data from Rippling API, you first need to authenticate your application. Rippling uses the OAuth 2.0 protocol for authentication and authorization.

In the header of each HTTP request, include an authorization token in the following format: <code class="blog_inline-code">Authorization: Bearer {API-KEY}</code>. This <code class="blog_inline-code">{API-KEY}</code> is your unique application key provided by Rippling. Make sure to replace <code class="blog_inline-code">{API-KEY}</code> with your actual API key.

It's important to note that all API requests must be made over HTTPS. Calls made over plain HTTP will fail. Also, you must authenticate for all API requests. Also, remember to keep your API key secure. Do not share your secret API key in publicly accessible areas such GitHub, client-side code, and so forth.

Related: Recruiting integrations worth building

How to get employees

The Python code below fetches employees from Rippling API using <code class="blog_inline-code">requests</code> library. It uses a generator to yield employee data as it is fetched from the API. The function <code class="blog_inline-code">fetch_employees</code> takes an API key and a limit as arguments and fetches employee data in a paginated manner using an offset.

Moreover, the code fetches data from the API endpoint using a GET request. It includes an authorization header in the format <code class="blog_inline-code">Authorization: Bearer {API-KEY}`</code>. The function fetches data in pages of size <code class="blog_inline-code">limit</code> and increments the offset by <code class="blog_inline-code">limit</code> after each request to fetch the next page. It stops fetching when it encounters an empty page.

python
import requests
import json

Here'e an example of a response from the request.

[
    {
        "id": "1234",
        "dob": "1980-01-01",
        "ssn": "123-45-6789",
        "name": "John Doe",
        "level": "5",
        "phone": "+123456789",
        "photo": "https://example.com/photo.jpg",
        "teams": [],
        "title": "Software Engineer",
        "gender": "Male",
        "userId": "5678",
        "lastName": "Doe",
        "createdAt": "2021-01-01",
        "firstName": "John",
        "isManager": true,
        "roleState": "Active",
        "updatedAt": "2021-06-01",
        "workEmail": "john.doe@example.com",
        "department": "Engineering",
        "flsaStatus": "Exempt",
        "smallPhoto": "https://example.com/smallphoto.jpg",
        "phoneNumber": "+123456789",
        "compensation": {
            "currency": "USD",
            "salaryUnit": "Yearly",
            "annualSalary": "100000",
            "signingBonus": "5000",
            "bonusSchedule": "Quarterly",
            "salaryPerUnit": "25000",
            "equityNumShares": 1000,
            "relocationReimbursement": "2000"
        },
        "customFields": {},
        "filingStatus": "Single",
        "workLocation": {
            "zip": "12345",
            "city": "San Francisco",
            "phone": "+123456789",
            "state": "CA",
            "country": "US",
            "streetLine1": "123 Main St",
            "streetLine2": "",
            "steLocationCode": {
                "psdCode": "",
                "cityCode": "1",
                "stateCode": "2",
                "countyCode": "3",
                "schoolCode": "",
                "isOverridden": false,
                "locationCode": "123",
                "municipalityCode": "",
                "transitDistrictCode": ""
            },
            "_smartystreets_validity": "Valid"
        },
        "workSchedule": {
            "FRIDAY": {
                "hours": "8"
            },
            "MONDAY": {
                "hours": "8"
            },
            "SUNDAY": {
                "hours": 0
            },
            "TUESDAY": {
                "hours": "8"
            },
            "SATURDAY": {
                "hours": 0
            },
            "THURSDAY": {
                "hours": "8"
            },
            "WEDNESDAY": {
                "hours": "8"
            }
        },
        "payScheduleId": "123",
        "personalEmail": "john.doe@gmail.com",
        "employeeNumber": 12345,
        "employmentType": "Full-time",
        "workLocationId": "456",
        "isInternational": false,
        "identifiedGender": "Male",
        "preferredLastName": "Doe",
        "preferredFirstName": "John",
        "workLocationNickname": "Main Office",
        "companyEmploymentType": {
            "id": "789",
            "label": "Full-time",
            "company": "ABC Corp",
            "isHourly": false,
            "createdAt": "2021-01-01",
            "isDeleted": false,
            "updatedAt": "2021-06-01",
            "isFullTime": true,
            "isPartTime": false,
            "isSalaried": true,
            "displayName": "Full-time",
            "isTemporary": false,
            "isContractor": false,
            "external_on_changes": [],
            "possible_new_employment_types": []
        }
    }
]

Related: What you need to know to perform API integration in Python

Final thoughts

Your clients likely use a wide range of HRIS platforms—not just Rippling.

To cater to the varied landscape of HRIS tools, you can build to Merge's HRIS Unified API. Once you’ve built to it, you can offer dozens of ticketing integrations to clients, whether that’s Workday, Namely, UKG, etc.

You can learn more about Merge by scheduling a demo with one of our integration experts.