Merge Python Client

2.6.3 · active · verified Mon Apr 13

The Merge Python library (SDK) provides convenient access to the Merge Unified APIs from Python. It allows developers to integrate with various categories such as ATS (Applicant Tracking System), HRIS (Human Resources Information System), CRM, Ticketing, Accounting, and File Storage. The library is actively maintained with regular updates and is currently at version 2.6.3.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate the Merge client using API key and account token, and perform a sample API call to create an activity in the ATS category and list employees from the HRIS category. Ensure `MERGE_API_KEY` and `MERGE_ACCOUNT_TOKEN` environment variables are set or replace placeholders. This SDK provides both synchronous and asynchronous clients for various API categories.

import os
from merge import Merge
from merge.resources.ats import ActivityRequest

# Instantiate the client with your API Key and Account Token
# For production, securely manage your credentials (e.g., environment variables)
client = Merge(
    api_key=os.environ.get('MERGE_API_KEY', 'YOUR_API_KEY'),
    account_token=os.environ.get('MERGE_ACCOUNT_TOKEN', 'YOUR_ACCOUNT_TOKEN')
)

try:
    # Example: Create an activity in the ATS category
    # Note: Replace with actual model data as required by your API call
    activity_data = ActivityRequest(
        subject="Initial Interview",
        activity_type="Interview",
        candidate_id="<YOUR_CANDIDATE_ID>", # Replace with a valid candidate ID
        # Add other required fields for ActivityRequest
    )
    
    response = client.ats.activities.create(
        model=activity_data,
        remote_user_id="<YOUR_REMOTE_USER_ID>" # Replace with a valid remote user ID
    )
    print("Activity created successfully:")
    print(response.to_dict())

    # Example: List employees from HRIS category (pagination example)
    # For real use, iterate through pages if 'next' is present
    employees_page = client.hris.employees.list(page_size=1)
    print("\nFirst employee page:")
    if employees_page.results:
        for employee in employees_page.results:
            print(employee.first_name, employee.last_name)
    else:
        print("No employees found.")

except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →