How can I get grades of a specific student for a specific course using the API?
You asked about a single student in a single course, but I thought I'd throw in some additional information since this question might be viewed by other people in the future who want that information. I wasn't sure from your request if you were asking for where in the API you could get the grades or how to use the API in general. How to use the API has documentation elsewhere and is too difficult to explain in a reply here, so I chose to answer the where portion.
To get the grade for a single student in a single course, you can use the Get a single user endpoint of the Courses API.
To get it to return the scores, you need to add include=enrollments to the query string
For example, if your Canvas course ID is 123 and the student's Canvas ID is 1234567, you would use this API endpoint
You can also use a SIS student ID if you know. If the student's SIS Id was 7654321, then you would use
See the SIS IDs documentation for more information on using SIS IDs.
You can use the List your courses endpoint of the Courses API call to get the grades for all courses for a single student. This will return their grade for all of their courses and then you can pick out the one(s) that you want.
You need to add include=total_scores to the query string to get the scores.
Also, that only returns your scores. If you want scores for other people, you will need permission to masquerade as another user and add as_user_id=1234567 (where 1234567 is the Canvas User ID for the student) to query string as well. If you have SIS user Ids for the students, you can also use as_user_id=sis_user_id:7654321, where 7654321 is your SIS ID for the student. See the Masquerading documentation in the API for more information.
If you want to put them together, then you'll need to put an ampersand between the parameters in the query string, so it would look something like:
SALEEM, since James was able to provide a correct answer to your question I switched this from a "discussion" to a "question" and marked James' answer as correct. If you have follow questions for about this, feel free to respond and continue the conversation.
Thank you very much James. This is very helpful.
Retrieving data ...