Merge Python Client
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
- breaking Legacy SDKs (e.g., MergeATSClient, MergeHRISClient) were deprecated in August 2023 and stopped receiving updates/bug fixes after February 2024. Projects using these older, category-specific clients must migrate to the unified 'mergepythonclient' (v2 SDK) for continued support and new features.
- gotcha When using older, generated SDKs for Merge (like `MergeATSClient`), importing all APIs or models (e.g., `from MergeATSClient.apis import *`) might lead to a `RecursionError` with large OpenAPI documents.
- gotcha The first usage of a newly instantiated Merge client may experience additional latency due to internal initialization processes.
- gotcha API requests can fail due to 'CREDENTIAL_REFRESH_FAILED' if the linked account's credentials need to be refreshed, or 'DISABLED_MODEL_WRITE' if attempting to write to a model that has been disabled.
- gotcha Requests may encounter 'INCORRECT_FIELD_TYPE' errors or warnings if field values are not in the expected format. While warnings indicate Merge could convert the type, it's best to send correct types to avoid data alteration.
Install
-
pip install MergePythonClient
Imports
- Merge
from merge import Merge
- Merge (legacy clients)
from merge import Merge
- Resource models (e.g., ActivityRequest)
from merge.resources.ats import ActivityRequest
Quickstart
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}")