Developer guide to list ALL candidates using Ashby API (Python Example)

Introduction

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

List All Candidates from Ashby API

The Ashby API provides a robust method to list all candidates within an organization using the candidate.list endpoint. This endpoint supports pagination and incremental synchronization, allowing efficient data retrieval. Below is a step-by-step guide to using this API with Python code snippets.

API Endpoint

Endpoint: https://api.ashbyhq.com/candidate.list
HTTP Method: POST

Request Body

The request body should be a JSON object. You can specify parameters such as limit, cursor, and syncToken to control pagination and synchronization.

{
  "limit": 25,
  "cursor": "your-cursor-value",
  "syncToken": "your-sync-token"
}

Python Code Snippet

Below is a Python code snippet demonstrating how to list all candidates using the Ashby API:

import requests

url = "https://api.ashbyhq.com/candidate.list"
headers = {
    "Accept": "application/json",
    "Content-Type": "application/json"
}
data = {
    "limit": 25
}

response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
    result = response.json()
    print(result)
    while result.get("moreDataAvailable"):
        data["cursor"] = result.get("nextCursor")
        response = requests.post(url, headers=headers, json=data)
        result = response.json()
        print(result)
else:
    print("Error:", response.status_code, response.text)

Response

The response will include a list of candidates and pagination information. If moreDataAvailable is true, use nextCursor to fetch the next page.

{
  "success": true,
  "results": [
    // Array of candidate objects
  ],
  "moreDataAvailable": true,
  "nextCursor": "next-cursor-value",
  "syncToken": "new-sync-token-value"
}

If you are looking to learn how to get details on an individual candidate using Ashby API, read our developer guide here : Get candidate data using Ashby API (Python Example)

Knit for Ashby API Integration

For quick and seamless access to Ashby API, Knit API offers a convenient Unified API solution. By integrating with Knit just once, you can integrate with multiple ATS systems in on go. 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 Ashby API.

#1 in Ease of Integrations

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