Get all open jobs from Sage Recruitment API

Introduction

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

Get all open jobs from Sage Recruitment API

Overview

To retrieve all open jobs from the Sage Recruitment API, you need to make a GET request to the /api/recruitment/positions endpoint with the appropriate query parameters. Below is a step-by-step guide on how to achieve this using Python.

Step-by-Step Guide

1. Set Up Your Environment

Ensure you have the requests library installed. You can install it using pip:

pip install requests

2. Define the API Endpoint and Parameters

Set the API endpoint and the required headers, including the authorization token. Use the query parameter status=open to filter for open jobs.

import requests

# Define the API endpoint
url = "https://subdomain.sage.hr/api/recruitment/positions"

# Set the headers
headers = {
    "X-Auth-Token": "your_auth_token_here"
}

# Set the query parameters
params = {
    "status": "open",
    "per_page": 100  # Adjust as needed
}

# Make the GET request
response = requests.get(url, headers=headers, params=params)

# Check if the request was successful
if response.status_code == 200:
    open_jobs = response.json()
    print(open_jobs)
else:
    print(f"Failed to retrieve open jobs: {response.status_code}")

3. Handle Pagination

If there are multiple pages of results, you need to handle pagination to retrieve all open jobs. Below is an example of how to do this:

import requests

# Define the API endpoint
url = "https://subdomain.sage.hr/api/recruitment/positions"

# Set the headers
headers = {
    "X-Auth-Token": "your_auth_token_here"
}

# Initialize parameters
params = {
    "status": "open",
    "per_page": 100,  # Adjust as needed
    "page": 1
}

# Initialize a list to store all open jobs
all_open_jobs = []

while True:
    # Make the GET request
    response = requests.get(url, headers=headers, params=params)
    
    # Check if the request was successful
    if response.status_code == 200:
        data = response.json()
        all_open_jobs.extend(data["data"])
        
        # Check if there are more pages
        if data["meta"]["next_page"]:
            params["page"] = data["meta"]["next_page"]
        else:
            break
    else:
        print(f"Failed to retrieve open jobs: {response.status_code}")
        break

print(all_open_jobs)

Conclusion

By following these steps, you can retrieve all open jobs from the Sage Recruitment API. Adjust the parameters as needed to fit your specific requirements.

Knit for Sage Recruitment API Integration

For quick and seamless access to Sage Recruitment 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 Sage Recruitment API.

#1 in Ease of Integrations

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