Skip to main content

Get Timetable Data

Retrieve complete timetable data for a specific timetable by ID. This endpoint returns all timetable information including subjects, teachers, classes, rooms, lessons, and lesson units (schedule data).

Endpoint

GET /api/v1/timetables/{id}

Authentication

This endpoint requires authentication. Include your API key in the Authorization header.

Authorization: Bearer YOUR_API_KEY

Request

Path Parameters

ParameterTypeRequiredDescription
idstringYesThe timetable ID obtained from the list timetables endpoint

Headers

HeaderValueRequired
AuthorizationBearer YOUR_API_KEYYes
Content-Typeapplication/jsonYes

Response

Success Response

Status Code: 200 OK

{
"success": true,
"data": {
"id": "tt_67890",
"name": "Term 1 2025 Timetable",
"orgId": "org_12345",
"schedulingMode": "standard",
"basicInfo": {
"name": "Term 1 2025 Timetable",
"description": "Main timetable for the first term",
"academicSession": {
"name": "2025-26",
"startDate": "2025-04-01T00:00:00.000Z",
"endDate": "2026-03-31T00:00:00.000Z"
}
},
"bellSchedule": {
"scheduleType": "weekly",
"cycleLength": 1,
"name": "Default Schedule",
"dayConfigurations": [
{
"id": "dconf_abc123",
"days": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
"weekIndex": null,
"periods": [
{
"id": "prd_001",
"name": "Period 1",
"start_time": "08:00",
"end_time": "08:45"
},
{
"id": "prd_002",
"name": "Period 2",
"start_time": "08:45",
"end_time": "09:30"
},
{
"id": "prd_003",
"name": "Period 3",
"start_time": "09:30",
"end_time": "10:15"
},
{
"id": "prd_004",
"name": "Period 4",
"start_time": "10:30",
"end_time": "11:15"
}
],
"breaks": [
{
"id": "brk_001",
"name": "Short Break",
"start_time": "10:15",
"end_time": "10:30",
"followsPeriodIndex": 2
},
{
"id": "brk_002",
"name": "Lunch Break",
"start_time": "12:30",
"end_time": "13:15",
"followsPeriodIndex": 5
}
]
}
]
},
"cycleConfig": null,
"subjects": [
{
"id": "math_001",
"resourceId": "res_sub_001",
"name": "Mathematics",
"shortName": "Math",
"color": "#FF5733"
},
{
"id": "eng_001",
"resourceId": "res_sub_002",
"name": "English",
"shortName": "Eng",
"color": "#33FF57"
}
],
"teachers": [
{
"id": "teacher_001",
"memberId": "mem_001",
"name": "John Smith",
"shortName": "J.Smith",
"color": "#3357FF",
"maxPeriods": null
},
{
"id": "teacher_002",
"memberId": "mem_002",
"name": "Sarah Johnson",
"shortName": "S.Johnson",
"color": "#FF33F5",
"maxPeriods": 30
}
],
"classes": [
{
"id": "class_9a",
"resourceId": "res_cls_001",
"name": "Grade 9A",
"shortName": "9A",
"color": "#F5FF33",
"classTeacher": "teacher_001"
},
{
"id": "class_9b",
"resourceId": "res_cls_002",
"name": "Grade 9B",
"shortName": "9B",
"color": "#33FFF5",
"classTeacher": "teacher_002"
}
],
"rooms": [
{
"id": "room_101",
"resourceId": "res_room_001",
"name": "Mathematics Room 1",
"shortName": "M101",
"color": "#FF5733",
"capacity": 40,
"buildingName": "Main Building",
"groupName": "Math Rooms"
},
{
"id": "room_102",
"resourceId": "res_room_002",
"name": "English Room 1",
"shortName": "E101",
"color": "#33FF57",
"capacity": 35,
"buildingName": "Language Block",
"groupName": null
}
],
"lessons": [
{
"id": "lesson_001",
"teacherIds": ["teacher_001"],
"classIds": ["class_9a"],
"subjectIds": ["math_001"],
"roomIds": ["room_101"],
"roomGroupName": null,
"groups": []
},
{
"id": "lesson_002",
"teacherIds": ["teacher_002"],
"classIds": ["class_9b"],
"subjectIds": ["eng_001"],
"roomIds": ["room_102"],
"roomGroupName": null,
"groups": []
}
],
"lessonUnits": [
{
"id": "unit_001",
"lessonId": "lesson_001",
"day": "Monday",
"weekIndex": null,
"periodIndex": 0,
"length": 1,
"classIds": ["class_9a"],
"subjectIds": ["math_001"],
"teacherIds": ["teacher_001"],
"roomIds": ["room_101"],
"groups": [],
"locked": false,
"lockReason": null,
"sectionIds": null,
"studentIds": null
},
{
"id": "unit_002",
"lessonId": "lesson_002",
"day": "Monday",
"weekIndex": null,
"periodIndex": 1,
"length": 1,
"classIds": ["class_9b"],
"subjectIds": ["eng_001"],
"teacherIds": ["teacher_002"],
"roomIds": ["room_102"],
"groups": [],
"locked": true,
"lockReason": "user_fixed",
"sectionIds": null,
"studentIds": null
},
{
"id": "unit_003",
"lessonId": "lesson_001",
"day": null,
"weekIndex": null,
"periodIndex": null,
"length": 1,
"classIds": ["class_9a"],
"subjectIds": ["math_001"],
"teacherIds": ["teacher_001"],
"roomIds": [],
"groups": [],
"locked": false,
"lockReason": null,
"sectionIds": null,
"studentIds": null
}
],
"status": "published",
"createdAt": "2025-01-15T08:00:00.000Z",
"updatedAt": "2025-01-20T14:30:00.000Z"
},
"timestamp": "2025-01-15T10:30:00.000Z"
}

Response Fields

Root Fields

FieldTypeDescription
successbooleanIndicates if the request was successful
dataobjectThe timetable data
timestampstringISO timestamp of the API response

Timetable Data Fields

FieldTypeDescription
idstringUnique timetable identifier
namestringHuman-readable timetable name
orgIdstringOrganization identifier
schedulingModestringEither standard or student-level
basicInfoobjectBasic information about the timetable
bellScheduleobjectBell schedule configuration with periods, breaks, and days
cycleConfigobjectCycle configuration for multi-week schedules (null if not used)
subjectsarrayArray of subject objects
teachersarrayArray of teacher objects
classesarrayArray of class objects
roomsarrayArray of room objects
lessonsarrayArray of lesson definitions (what to schedule)
lessonUnitsarrayArray of lesson unit placements (scheduled and unscheduled)
statusstringTimetable status (draft or published)
createdAtstringISO timestamp when timetable was created
updatedAtstringISO timestamp when timetable was last updated

Basic Info Object

FieldTypeDescription
namestringTimetable name
descriptionstringOptional timetable description
academicSessionobjectAcademic session details (name, startDate, endDate)

Bell Schedule Object

FieldTypeDescription
scheduleTypestringType of schedule: weekly, cyclic, or fixed
cycleLengthnumberNumber of weeks in the cycle (1 for weekly)
namestringName of the bell schedule
dayConfigurationsarrayArray of day configuration objects

Day Configuration Object

FieldTypeDescription
idstringUnique identifier for this day configuration
daysarrayArray of day names (e.g., ["Monday", "Tuesday"])
weekIndexnumberWeek index for multi-week schedules (null for all weeks)
periodsarrayArray of period objects with id, name, start_time, end_time
breaksarrayArray of break objects with id, name, start_time, end_time, followsPeriodIndex

Subject Object

FieldTypeDescription
idstringUnique subject identifier
resourceIdstringReference to organization-level resource
namestringFull subject name
shortNamestringAbbreviated subject name
colorstringSubject display color (hex)

Teacher Object

FieldTypeDescription
idstringUnique teacher identifier
memberIdstringReference to organization member
namestringFull teacher name
shortNamestringAbbreviated teacher name
colorstringTeacher display color (hex)
maxPeriodsnumberMaximum periods per cycle (null if not limited)

Class Object

FieldTypeDescription
idstringUnique class identifier
resourceIdstringReference to organization-level resource
namestringFull class name
shortNamestringAbbreviated class name
colorstringClass display color (hex)
classTeacherstringTeacher ID of the class teacher

Room Object

FieldTypeDescription
idstringUnique room identifier
resourceIdstringReference to organization-level resource
namestringFull room name
shortNamestringAbbreviated room name
colorstringRoom display color (hex)
capacitynumberRoom capacity (number of students)
buildingNamestringBuilding where room is located
groupNamestringRoom group for interchangeable rooms

Lesson Object

FieldTypeDescription
idstringUnique lesson identifier
teacherIdsarrayArray of teacher IDs assigned to lesson
classIdsarrayArray of class IDs for this lesson
subjectIdsarrayArray of subject IDs for this lesson
roomIdsarrayArray of room IDs for this lesson
roomGroupNamestringRoom group name for flexible room assignment
groupsarrayArray of group objects (for split classes)

Lesson Unit Object

FieldTypeDescription
idstringUnique lesson unit identifier
lessonIdstringReference to parent lesson
daystringDay of the week (null if unscheduled)
weekIndexnumberWeek index for multi-week schedules (null for all weeks)
periodIndexnumberPeriod slot index, 0-based (null if unscheduled)
lengthnumberDuration in consecutive periods
classIdsarrayArray of class IDs for this unit
subjectIdsarrayArray of subject IDs for this unit
teacherIdsarrayArray of teacher IDs for this unit
roomIdsarrayArray of room IDs for this unit
groupsarrayArray of group objects (for split classes)
lockedbooleanWhether this unit's position is locked
lockReasonstringReason for lock (user_fixed, user_locked, class_teacher)
sectionIdsarraySection IDs (student-level scheduling only)
studentIdsarrayStudent IDs (student-level scheduling only)

Student-Level Scheduling Fields

When schedulingMode is student-level, the response includes additional fields:

FieldTypeDescription
studentsarrayArray of student objects
coursesarrayArray of course objects
sectionsarrayArray of section objects
sectionSettingsobjectSettings for section auto-generation

Error Responses

404 Not Found

Timetable not found or access denied.

{
"success": false,
"error": {
"code": "TIMETABLE_NOT_FOUND",
"message": "Timetable not found or access denied"
}
}

401 Unauthorized

Missing or invalid API key.

{
"success": false,
"error": {
"code": "INVALID_API_KEY",
"message": "The provided API key is invalid or not found"
}
}

Code Examples

cURL

curl -X GET \
'https://www.timetablemaster.com/api/v1/timetables/tt_67890' \
-H 'Authorization: Bearer ttm_your_api_key_here' \
-H 'Content-Type: application/json'

JavaScript

const timetableId = "tt_67890";

const response = await fetch(
`https://www.timetablemaster.com/api/v1/timetables/${timetableId}`,
{
method: "GET",
headers: {
Authorization: "Bearer ttm_your_api_key_here",
"Content-Type": "application/json",
},
}
);

const data = await response.json();

if (data.success) {
const timetable = data.data;
console.log(`Timetable: ${timetable.name}`);
console.log(`Scheduling Mode: ${timetable.schedulingMode}`);
console.log(`Total lessons: ${timetable.lessons.length}`);
console.log(`Total lesson units: ${timetable.lessonUnits.length}`);

// Get scheduled vs unscheduled counts
const scheduled = timetable.lessonUnits.filter(u => u.day !== null);
const unscheduled = timetable.lessonUnits.filter(u => u.day === null);
console.log(`Scheduled: ${scheduled.length}, Unscheduled: ${unscheduled.length}`);
}

Python

import requests

timetable_id = 'tt_67890'
url = f'https://www.timetablemaster.com/api/v1/timetables/{timetable_id}'
headers = {
'Authorization': 'Bearer ttm_your_api_key_here',
'Content-Type': 'application/json'
}

response = requests.get(url, headers=headers)
data = response.json()

if data['success']:
timetable = data['data']
print(f"Timetable: {timetable['name']}")
print(f"Scheduling Mode: {timetable['schedulingMode']}")
print(f"Total subjects: {len(timetable['subjects'])}")
print(f"Total teachers: {len(timetable['teachers'])}")
print(f"Total classes: {len(timetable['classes'])}")
print(f"Total lessons: {len(timetable['lessons'])}")
print(f"Total lesson units: {len(timetable['lessonUnits'])}")

PHP

<?php
$timetableId = 'tt_67890';
$url = "https://www.timetablemaster.com/api/v1/timetables/{$timetableId}";
$headers = [
'Authorization: Bearer ttm_your_api_key_here',
'Content-Type: application/json'
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);

if ($data['success']) {
$timetable = $data['data'];
echo "Timetable: " . $timetable['name'] . "\n";
echo "Scheduling Mode: " . $timetable['schedulingMode'] . "\n";
echo "Lesson units: " . count($timetable['lessonUnits']) . "\n";
}
?>

Use Cases

Display Weekly Timetable

Create a visual timetable grid from the lesson units:

function createTimetableGrid(timetableData) {
const { bellSchedule, lessonUnits, subjects, teachers, rooms, classes } =
timetableData;

// Get days and periods from bell schedule
const dayConfig = bellSchedule.dayConfigurations[0];
const dayNames = dayConfig.days;
const periodsPerDay = dayConfig.periods.length;

// Create lookup maps for easy reference
const subjectMap = new Map(subjects.map((s) => [s.id, s]));
const teacherMap = new Map(teachers.map((t) => [t.id, t]));
const roomMap = new Map(rooms.map((r) => [r.id, r]));
const classMap = new Map(classes.map((c) => [c.id, c]));

// Group lesson units by day and period (only scheduled ones)
const grid = {};
dayNames.forEach((day) => {
grid[day] = new Array(periodsPerDay).fill(null);
});

lessonUnits
.filter(unit => unit.day !== null && unit.periodIndex !== null)
.forEach((unit) => {
grid[unit.day][unit.periodIndex] = {
subject: subjectMap.get(unit.subjectIds[0]),
teacher: teacherMap.get(unit.teacherIds[0]),
room: roomMap.get(unit.roomIds[0]),
class: classMap.get(unit.classIds[0]),
locked: unit.locked,
};
});

return grid;
}

Extract Teacher Schedules

Get individual teacher schedules from the timetable data:

def extract_teacher_schedule(timetable_data, teacher_id):
lesson_units = timetable_data['lessonUnits']
teacher_slots = []

for unit in lesson_units:
# Skip unscheduled units
if unit['day'] is None:
continue

if teacher_id in unit['teacherIds']:
teacher_slots.append({
'day': unit['day'],
'period': unit['periodIndex'],
'weekIndex': unit['weekIndex'],
'subject': next((s['name'] for s in timetable_data['subjects']
if s['id'] in unit['subjectIds']), 'Unknown'),
'class': next((c['name'] for c in timetable_data['classes']
if c['id'] in unit['classIds']), 'Unknown'),
'room': next((r['name'] for r in timetable_data['rooms']
if r['id'] in unit['roomIds']), 'No room assigned'),
'locked': unit['locked']
})

return sorted(teacher_slots, key=lambda x: (x['day'], x['period']))

Room Utilization Analysis

Analyze room usage patterns:

function analyzeRoomUtilization(timetableData) {
const { lessonUnits, rooms, bellSchedule } = timetableData;

const dayConfig = bellSchedule.dayConfigurations[0];
const totalSlots = dayConfig.days.length * dayConfig.periods.length;

const roomUsage = {};

rooms.forEach((room) => {
roomUsage[room.id] = {
name: room.name,
building: room.buildingName,
capacity: room.capacity,
groupName: room.groupName,
usedSlots: 0,
utilization: 0,
};
});

// Only count scheduled lesson units
lessonUnits
.filter(unit => unit.day !== null)
.forEach((unit) => {
unit.roomIds.forEach((roomId) => {
if (roomUsage[roomId]) {
roomUsage[roomId].usedSlots += unit.length || 1;
}
});
});

Object.values(roomUsage).forEach((room) => {
room.utilization = (room.usedSlots / totalSlots) * 100;
});

return roomUsage;
}

Working with Multi-Week Schedules

Handle cyclic or fixed multi-week schedules:

function getLessonUnitsForWeek(timetableData, weekIndex) {
const { lessonUnits, bellSchedule } = timetableData;

// For weekly schedules, return all units
if (bellSchedule.scheduleType === 'weekly') {
return lessonUnits.filter(unit => unit.day !== null);
}

// For cyclic/fixed schedules, filter by weekIndex
return lessonUnits.filter(unit => {
if (unit.day === null) return false;
// null weekIndex means "all weeks"
return unit.weekIndex === null || unit.weekIndex === weekIndex;
});
}

Next Steps

With the complete timetable data, you can:

  • Build visual timetable displays for your application
  • Extract specific schedules for teachers, classes, or rooms
  • Analyze timetable patterns and utilization
  • Integrate the data with your school management system
  • Handle multi-week cyclic schedules
  • Work with locked/fixed lesson positions