I don't believe any API call will directly return the number of students in a course. This python script, which uses the requests module may accomplish what you need, but not in the way that you want. You'll need to add a bearer token and cookie and use your institution's url and the relevant course code...
You can run the request in Postman and generate code in a variety of languages from there.
You may need to change the per_page setting depending on the size of the class...
import requests
url = "https://yourschool.instructure.com/api/v1/courses/1234/enrollments?type[]=StudentEnrollment&per_page..."
payload={}
headers = {
'Authorization': 'Your bearer token',
'Cookie': 'Your cookie'
response = requests.request("GET", url, headers=headers, data=payload)
#print(response.text)
Enrollments=response.json()
k=len(Enrollments)
print(k)
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.