Stay organized with collections
Save and categorize content based on your preferences.
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.
/** * 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 APIconsole.log('Failed with error %s',err.message);}}
[null,null,["Last updated 2025-08-28 UTC."],[[["\u003cp\u003eThe Google Classroom API within Apps Script allows admins, teachers, and students to manage courses and rosters.\u003c/p\u003e\n"],["\u003cp\u003eThis is an advanced service requiring prior enabling and provides functionalities mirroring the public API.\u003c/p\u003e\n"],["\u003cp\u003eComprehensive documentation, support resources, and sample code are available for guidance and troubleshooting.\u003c/p\u003e\n"],["\u003cp\u003eYou can find sample code demonstrating functionalities like listing the user's accessible courses.\u003c/p\u003e\n"]]],[],null,["# Classroom Service\n\nThe Classroom service allows you to use the\n[Google Classroom API](/classroom) in Apps Script. This API gives admins,\nteachers, and students the ability to view and manage their courses and rosters.\n| **Note:** This is an advanced service that must be [enabled before use](/apps-script/guides/services/advanced). Follow along with the [quickstart](/classroom/quickstart/apps-script) for step-by-step instructions on how to get started.\n\nReference\n---------\n\nFor detailed information on this service, see the\n[reference documentation](/classroom/reference/rest) for the Google Classroom API.\nLike all advanced services in Apps Script, the Classroom service uses the same\nobjects, methods, and parameters as the public API. For more information, see [How method signatures are determined](/apps-script/guides/services/advanced#how_method_signatures_are_determined).\n\nTo report issues and find other support, see the\n[Classroom support guide](/classroom/support).\n\nSample code\n-----------\n\nThe sample code below uses [version 1](/classroom/reference/rest) of the API.\n\n### List courses\n\nThis sample lists the first ten courses the user has access to. \nadvanced/classroom.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/classroom.gs) \n\n```javascript\n/**\n * Lists 10 course names and IDs.\n */\nfunction listCourses() {\n /**\n * @see https://developers.google.com/classroom/reference/rest/v1/courses/list\n */\n const optionalArgs = {\n pageSize: 10\n // Use other query parameters here if needed.\n };\n try {\n const response = Classroom.Courses.list(optionalArgs);\n const courses = response.courses;\n if (!courses || courses.length === 0) {\n console.log('No courses found.');\n return;\n }\n // Print the course names and IDs of the available courses.\n for (const course in courses) {\n console.log('%s (%s)', courses[course].name, courses[course].id);\n }\n } catch (err) {\n // TODO (developer)- Handle Courses.list() exception from Classroom API\n console.log('Failed with error %s', err.message);\n }\n}\n```"]]