API

Documentation

Version 1.0

Sorting

The AutoTechJobs API allows you to sort collection results according to various criteria. Sorting can be combined with filtering and pagination to help you efficiently retrieve and organize data.

Sort Parameters

Sorting is controlled using the sort query parameter. You can specify both the field to sort by and the direction (ascending or descending).

GET /v1/jobs?sort=posted_at:desc

Sort Syntax

The sort parameter uses the following syntax:

sort=field:direction

Where:

  • field is the name of the field to sort by
  • direction is either asc (ascending) or desc (descending)

If no direction is specified, ascending order is used by default:

GET /v1/jobs?sort=title

Multiple Sort Criteria

You can sort by multiple fields by separating them with commas. The sorting will be applied in the order specified.

GET /v1/jobs?sort=location,salary:desc

Sortable Fields

The following tables list the sortable fields for each resource type:

Jobs

FieldDescriptionDefault Direction
titleJob titleasc
posted_atPosting datedesc
locationJob locationasc
salaryJob salarydesc
company_nameCompany nameasc
application_countNumber of applicationsdesc

Employers

FieldDescriptionDefault Direction
nameCompany nameasc
locationCompany locationasc
created_atAccount creation datedesc
open_positionsNumber of open positionsdesc
employee_countNumber of employeesdesc

Example Requests

Sort jobs by most recently posted

GET /v1/jobs?sort=posted_at:desc

Sort jobs by salary (highest first) within a location

GET /v1/jobs?location=manchester&sort=salary:desc

Sort employers by number of open positions

GET /v1/employers?sort=open_positions:desc

Default Sorting

If no sort parameter is provided, each endpoint has its own default sorting:

  • /jobs: sorted by posted_at:desc (newest first)
  • /employers: sorted by name:asc (alphabetically)
  • /candidates: sorted by last_active:desc (most recently active first)

Response Format

When sorting is applied, the response format remains the same as the standard endpoint response, but the order of resources is changed. The meta section of the response includes information about the applied sorting.

{
  "data": [ ... ],  // Sorted results
  "meta": {
    "sort": {
      "fields": ["salary"],
      "directions": ["desc"]
    },
    "pagination": { ... }
  }
}

For more information on combining sorting with filtering, see the Filtering documentation.

To learn about paginating sorted results, see the Pagination documentation.