API Connector Documentation
Import Google Classroom Data to Google Sheets
In this guide, we’ll walk through how to pull Google Classroom API data data directly into Google Sheets, using the API Connector add-on for Sheets.
Contents
- Before You Begin
- Part 1: Pull Google Classroom API Data into Sheets
- Part 2: More Example API Requests
- Part 3: Handle Pagination
- Part 4: API Documentation
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: Pull Google Classroom API Data into Sheets
For this example, we'll pull in a list of the courses you have access to.
- Open up Google Sheets and click Extensions > API Connector > Open > Create request.
- In the request form enter the following:
- Application:
Custom
- Method:
GET
- Request URL:
https://classroom.googleapis.com/v1/courses
- OAuth:
Google Classroom
- Application:
- When you select Google Classroom from the OAuth menu, you'll see a blue Connect button if you haven't already authorized the connection. Click through to enable.
- Create a new tab and click Set current to use that tab as your data destination.
- Name your request and click Run. A moment later you’ll see a list of your courses populate your sheet.
Part 2: More Example API Requests
For the full set of endpoints check the API documentation here. If you want to get an idea how it works, you can also check these examples:
- List course announcements (get your courseId value from the previous request):
https://classroom.googleapis.com/v1/courses/{courseId}/announcements
- List class coursework
https://classroom.googleapis.com/v1/courses/{courseId}/courseWork
Part 3: Handle Pagination
By default, Google will limit records to 30 unless the pageSize
parameter is used.
To cycle through additional pages of data, set up pagination handling like this:
- Pagination:
cursor
- Next token parameter:
pageToken
- Next token path:
nextPageToken
Part 4: API Documentation
Official API documentation: https://developers.google.com/classroom/reference/rest
Hello,
Could you help me please, where should I put "
https://www.googleapis.com/auth/classroom.profile.emails
" in my API Connector to get emails to user profile (https://classroom.googleapis.com/v1/userProfiles/{userId}
) ?Thank you in advance,
Anastasiya
Hey Anastasiya, sorry, API Connector doesn't provide access to this scope. Just for context, the
/auth/classroom.profile.emails
scope is used to view the email addresses of people in your classes. Emails are considered sensitive information, so Google requires that any apps requesting this scope need to apply for access first, and we opted to instead provide access to non-sensitive data only. That means API Connector doesn't support queries to view email addresses. Maybe we'll apply for access in the future (now that I know at least one person is looking for this information), but for now you'd need to use a different tool or create your own custom OAuth connection and apply for access yourself. Sorry for the inconvenience but I hope that clarifies.Thank you very much for your quick response an explanation!
Hello Ana,
I have one more question.
Do you know if there is a way to add a new student to Google Classroom thru API Connector?
Thank you in advance,
Anastasiya
Sorry, this is again a sensitive scope that we don't have access to. You can see all the Google Classroom-related scopes here; if you want to check and let me know which ones you'd like to use, I can submit a request for access: https://developers.google.com/classroom/guides/auth
I'm getting Completed with errors
-
We received an error from googleapis.com (403) show response
{ "error": { "code": 403, "message": "Request had insufficient authentication scopes.", "status": "PERMISSION_DENIED", "details": [ { "@type": "type.googleapis.com/google.rpc.ErrorInfo", "reason": "ACCESS_TOKEN_SCOPE_INSUFFICIENT", "domain": "googleapis.com", "metadata": { "method": "google.classroom.v1.Courses.ListCourses", "service": "classroom.googleapis.com" } } ] } }
Generally that means you need to disconnect and reconnect, making sure to enable all requested permissions. Please see here for more info, or let me know if you’re still having issues after that.
I did that and it worked. I don't know why I didn't think of it. I thought it was a chrome profiles issue. TY!