Skip to Content
API EndpointsClass Sizes

Class Sizes API

The Class Sizes API provides access to historical data on average class sizes across different departments and academic terms at Albion College.

Endpoint

GET /api/data/class-sizes

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
departmentIdIntegerNoFilter results by department ID
termStringNoFilter results by academic term (e.g., “Fall 2023”)
pageIntegerNoPage number for pagination (default: 1)
limitIntegerNoNumber of results per page (default: 100, max: 1000)
sortByStringNoField to sort by (term, department, average_class_size)
sortOrderStringNoSort order (asc or desc)

Note: If neither departmentId nor term is provided, the API returns data for all departments and terms.

Response Format

The API returns a JSON response with the following structure:

{ "success": true, "data": [ { "id": 1, "department": "Biology", "term": "Fall 2023", "average_class_size": 24.5 }, ], "pagination": { "total": 150, "page": 1, "limit": 100, "totalPages": 2 } }

Response Fields

FieldDescription
successBoolean indicating if the request was successful
dataArray of class size records
data[].idUnique identifier for the record
data[].departmentName of the academic department
data[].termAcademic term (e.g., “Fall 2023”)
data[].average_class_sizeAverage number of students per class
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 Class Sizes

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

Filter by Department

curl -X GET "https://openalbion.org/api/data/class-sizes?departmentId=5" \ -H "X-API-Key: your_api_key"

Filter by Term

curl -X GET "https://openalbion.org/api/data/class-sizes?term=Fall%202023" \ -H "X-API-Key: your_api_key"

Pagination and Sorting

curl -X GET "https://openalbion.org/api/data/class-sizes?page=2&limit=50&sortBy=average_class_size&sortOrder=desc" \ -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" }