Tutorial 2 - Fetch applications

In this tutorial, we will continue the process we started in Tutorial 1 where we have created and published a new job and will now show how to:

1. Fetch application data

1. Fetch application data

In this section, we will guide you through the process of fetching job applications using the ATS-API's "getApplicationsBySourceId" endpoint. This API call allows you to retrieve a list of applications for a specific job based on its sourceId. To use this endpoint, you need to provide the appropriate access_token obtained from the authentication process.


The endpoint requires the following parameters:

(For complete documentation of the endpoint, please refer to the Swagger Definition that is auto-generated and up-to-date!)

TypeScript example

Here's an example of how to fetch applications using TypeScript and node-fetch:


async function getApplicationsBySourceId(sourceId: string): Promise<void> {

const apiUrl = new URL('https://hokify.com/ats-api/application/getApplicationsBySourceId');

apiUrl.searchParams.set('sourceId', sourceId);

// more params for pagination, date filtering etc.


const headers = {

Authorization: `Bearer ${access_token}`,

'Content-Type': 'application/json'

};


try {

const response = await fetch(apiUrl, {

method: 'GET',

headers

});


if (response.ok) {

const responseData = await response.json();

console.log('Fetched applications:', responseData);

} else {

console.error('Failed to fetch applications');

}

} catch (error) {

console.error('Error:', error);

}

}


await getApplicationsBySourceId('hy13720954');


Which would result in a response output like:

Fetched applications: [

  {

    "applications": [

      {

        "_id": "636b5e00a1b2c3d4e5f6789b",

        "contactStage": "newapplicant",

        "user": {

          "_id": "636b5e00a1b2c3d4e5f6789c",

          "displayName": "Birgit Mayr",

          "general": {

            "firstName": "Birgit",

            "lastName": "Mayr",

            "email": "birgit.mayr@hokify.com",

            // [...] more user details in structured form

            // depending on what the user provided (or what was asked via requiredFields)

          },

          "extras": [

            // [...] user's files

          ]

        },

        "interviewQuestions": [

          // [...] answers to questions / requiredFields

        ],

        // [...] more details

      },

      {

      // [...] multiple applications eventually

      }

    ],

    "hasMoreApplications": false,

    "relationType": "job",

    "relationId": "636b5e00a1b2c3d4e5f6789a",

    "sourceId": "hy13720954"

  }

]

(Note the relationId being of the job object, and other objects also having their unique IDs (application and user) to eventually de-duplicate on your end, if you need.)

Alternative methods

Our used GET /application/getApplicationsBySourceId endpoint fetches all applications for a specific job (by sourceId) for the current logged in mandator. Use other methods if they suit your use-cases better! For example: