Sometimes getting a good night's sleep gives you clarity of thought -- and yesterday was a day where I hadn't had much sleep but I went to bed early last night.
I forgot to mention that with the Provisioning Report, you can specify the Enrollment Term so you just get the information for a specific term. That assumes that you're putting courses into terms, which it sounds like you were. So if you go into the provisioning report and configure it, you can select just the term you want. The users table will select just the current users, but not which ones are students. The enrollment report will give you the roles so you can limit it to just students.
None of that changes that you would have to go through the web-interface, but if you are just after a count, you could pull just the enrollments.csv file into a spreadsheet and get a count of unique values.
The Provisioning Report is available through the API, but it because it takes time to generate the report, it will be a delayed process, but a lot less network traffic. Since you're spending time getting your list of students anyway, you're probably used to waiting. But we're talking a two-part process here, not a run it all at once one.
The Account Reports API is what you'll want to use.
List Available Reports gives you a list of the reports and what the parameters are.
GET /api/v1/accounts/:account_id/reports
You'll want the Provisioning Report, and the relevant parameters are
- enrollment_term_id: The canvas id of the term of courses to report on
- users: Get the Provisioning file for users
- enrollments: Get the Provisioning file for enrollments
You can select other information if you like.
The other important thing is the name of the report, provisioning_csv, which you'll need later.
You can get the Canvas ID of the term using the List enrollment terms endpoint of the Enrollment Terms API
GET /api/v1/accounts/:account_id/terms
For us, Fall 2015 has name:"Fall 2015", sis_term_id:"2015c", and id:6937. Make sure you use the id and not the sis_term_id
Putting those two together, you would make a call to the Start a Report endpoint of the Account Reports API
POST /api/v1/accounts/:account_id/reports/:report
So, assuming you're using our enrollment id, you would make this API request, sending the indicated data:
POST /api/v1/accounts/:account_id/reports/provisioning_csv
{
enrollment_term_id: 6937,
users: true,
enrollments: true
}
Edit: Although that's the information you need to send, you need to send it as a single string under the parameters key.
parameters:enrollment_term_id=6937&users=1&enrollments=1
Once you submit that, you'll get a JSON return that has an ID in it. You need that id for later.
Now we wait for the report to finish. How long it takes depends on a lot of factors like how busy the system is and how many students you have.
You can check the Status of the Report and see how it's doing.
GET /api/v1/accounts/:account_id/reports/:report/:id
The :report is provisioning_csv and the :id is the id returned when you created the report.
When the report is generated, you'll have a progress of 100 and there will be an extra section called attachment. If there isn't, then you wait longer and try again (unless there's an error).
The attachment information will contain an URL that you can use to download the file. Really important note -- the URL is not part of the API, do NOT send your Authorization: Bearer header with the request or it will fail. Just download the file from the supplied URL.
I don't know what SIS you're using, so I don't understand your statement about there being too many students. I've heard of cases where one group doesn't have access to the SIS directly and so they have to use Canvas to get the data or where you have to justify that you need the list of students and without it they won't give it to you, But If you, or someone you know, has direct access to the SIS, it should contain the enrollments and someone should be able to write some SQL code or perform similar filtering to get just the students for a current term.
Thankfully, I'm at a small college and have access to the SIS directly, so it's faster for me to just query it.
Anyway, good luck.