Classroom Service

  • The Google Classroom API within Apps Script allows admins, teachers, and students to manage courses and rosters.

  • This is an advanced service requiring prior enabling and provides functionalities mirroring the public API.

  • Comprehensive documentation, support resources, and sample code are available for guidance and troubleshooting.

  • You can find sample code demonstrating functionalities like listing the user's accessible courses.

The Classroom service allows you to use the Google Classroom API in Apps Script. This API gives admins, teachers, and students the ability to view and manage their courses and rosters.

Reference

For detailed information on this service, see the reference documentation for the Google Classroom API. Like all advanced services in Apps Script, the Classroom service uses the same objects, methods, and parameters as the public API. For more information, see How method signatures are determined.

To report issues and find other support, see the Classroom support guide.

Sample code

The sample code below uses version 1 of the API.

List courses

This sample lists the first ten courses the user has access to.

advanced/classroom.gs
/**
 * Lists 10 course names and IDs.
 */
functionlistCourses(){
/**
 * @see https://developers.google.com/classroom/reference/rest/v1/courses/list
 */
constoptionalArgs={
pageSize:10
// Use other query parameters here if needed.
};
try{
constresponse=Classroom.Courses.list(optionalArgs);
constcourses=response.courses;
if(!courses||courses.length===0){
console.log('No courses found.');
return;
}
// Print the course names and IDs of the available courses.
for(constcourseincourses){
console.log('%s (%s)',courses[course].name,courses[course].id);
}
}catch(err){
// TODO (developer)- Handle Courses.list() exception from Classroom API
console.log('Failed with error %s',err.message);
}
}

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年10月13日 UTC.