TypeScript typings for Google Classroom API v1
Manages classes, rosters, and invitations in Google Classroom.
For detailed description please check documentation.
Installing
Install typings for Google Classroom API:
npm install @types/gapi.client.classroom@v1 --save-dev
Usage
You need to initialize Google API client in your code:
gapi.load('client', () => {
});
Then load api client wrapper:
gapi.client.load('classroom', 'v1', () => {
});
Don't forget to authenticate your client before sending any request to resources:
var client_id = '',
scope = [
'https://www.googleapis.com/auth/classroom.announcements',
'https://www.googleapis.com/auth/classroom.announcements.readonly',
'https://www.googleapis.com/auth/classroom.courses',
'https://www.googleapis.com/auth/classroom.courses.readonly',
'https://www.googleapis.com/auth/classroom.coursework.me',
'https://www.googleapis.com/auth/classroom.coursework.me.readonly',
'https://www.googleapis.com/auth/classroom.coursework.students',
'https://www.googleapis.com/auth/classroom.coursework.students.readonly',
'https://www.googleapis.com/auth/classroom.courseworkmaterials',
'https://www.googleapis.com/auth/classroom.courseworkmaterials.readonly',
'https://www.googleapis.com/auth/classroom.guardianlinks.me.readonly',
'https://www.googleapis.com/auth/classroom.guardianlinks.students',
'https://www.googleapis.com/auth/classroom.guardianlinks.students.readonly',
'https://www.googleapis.com/auth/classroom.profile.emails',
'https://www.googleapis.com/auth/classroom.profile.photos',
'https://www.googleapis.com/auth/classroom.push-notifications',
'https://www.googleapis.com/auth/classroom.rosters',
'https://www.googleapis.com/auth/classroom.rosters.readonly',
'https://www.googleapis.com/auth/classroom.student-submissions.me.readonly',
'https://www.googleapis.com/auth/classroom.student-submissions.students.readonly',
'https://www.googleapis.com/auth/classroom.topics',
'https://www.googleapis.com/auth/classroom.topics.readonly',
],
immediate = true;
gapi.auth.authorize(
{ client_id: client_id, scope: scope, immediate: immediate },
authResult => {
if (authResult && !authResult.error) {
} else {
}
});
After that you can use Google Classroom API resources:
await gapi.client.classroom.courses.create({ });
await gapi.client.classroom.courses.delete({ id: "id", });
await gapi.client.classroom.courses.get({ id: "id", });
await gapi.client.classroom.courses.list({ });
await gapi.client.classroom.courses.patch({ id: "id", });
await gapi.client.classroom.courses.update({ id: "id", });
await gapi.client.classroom.invitations.accept({ id: "id", });
await gapi.client.classroom.invitations.create({ });
await gapi.client.classroom.invitations.delete({ id: "id", });
await gapi.client.classroom.invitations.get({ id: "id", });
await gapi.client.classroom.invitations.list({ });
await gapi.client.classroom.registrations.create({ });
await gapi.client.classroom.registrations.delete({ registrationId: "registrationId", });
await gapi.client.classroom.userProfiles.get({ userId: "userId", });