Skip to Content
API EndpointsHeadcounts

Headcounts API

The Headcounts API provides access to historical student headcount data at Albion College.

Endpoint

GET /api/data/headcounts

Authentication

All requests to this endpoint require authentication using an API key. You can provide your API key in one of the following ways:

  • HTTP Header: X-API-Key: your_api_key
  • Bearer Token: Authorization: Bearer your_api_key
  • Query Parameter: ?apiKey=your_api_key

If you don’t have an API key, you can obtain one from your dashboard settings.

Query Parameters

ParameterTypeRequiredDescription
yearIntegerNoFilter results by a specific year
startYearIntegerNoStart of year range for filtering (must be used with endYear)
endYearIntegerNoEnd of year range for filtering (must be used with startYear)
pageIntegerNoPage number for pagination (default: 1)
limitIntegerNoNumber of results per page (default: 100, max: 1000)
sortByStringNoField to sort by (year, headcount)
sortOrderStringNoSort order (asc or desc)

Note: If none of the filter parameters (year, startYear/endYear) are provided, the API returns data for all available years.

Response Format

The API returns a JSON response with the following structure:

{ "success": true, "data": [ { "id": 1, "year": 2023, "headcount": 1450 }, { "id": 2, "year": 2022, "headcount": 1425 }, ], "pagination": { "total": 20, "page": 1, "limit": 100, "totalPages": 1 } }

Response Fields

FieldDescription
successBoolean indicating if the request was successful
dataArray of headcount records
data[].idUnique identifier for the record
data[].yearAcademic year of the headcount data
data[].headcountTotal number of students enrolled
pagination.totalTotal number of records available
pagination.pageCurrent page number
pagination.limitNumber of records per page
pagination.totalPagesTotal number of pages available

Examples

Get All Headcount Data

curl -X GET "https://openalbion.org/api/data/headcounts" \ -H "X-API-Key: your_api_key"

Filter by Specific Year

curl -X GET "https://openalbion.org/api/data/headcounts?year=2023" \ -H "X-API-Key: your_api_key"

Filter by Year Range

curl -X GET "https://openalbion.org/api/data/headcounts?startYear=2018&endYear=2023" \ -H "X-API-Key: your_api_key"

Sorting and Pagination

curl -X GET "https://openalbion.org/api/data/headcounts?sortBy=headcount&sortOrder=desc&page=1&limit=10" \ -H "X-API-Key: your_api_key"

Error Responses

Status CodeDescription
401Authentication error (missing or invalid API key)
500Server error

Example error response:

{ "success": false, "error": "API key missing", "message": "Please provide an API key via X-API-Key header, Authorization: Bearer header, or apiKey query parameter.", "docs": "https://docs.openalbion.org" }