[ARCHIVED] How to get assignment due dates?

Jump to solution
tg1802
Community Member

I'm a bit new to using canvasapi and I haven't found anything that will let me get the due date of an assignment. I'm a student and wanted to be able to get all my assignments to print ordered by due date. So far, I have been able to fetch and print out assignments, but all I can do is print every single assignment from my courses in order of when they were assigned. How can I get the assignments' due dates and possibly also whether I've already made submissions or not to order them with the most relevant assignments first?

Labels (2)
0 Likes
1 Solution
James
Community Champion

@tg1802 

It sounds like you're wanting the information from the assignments page, but returned through the API.

Canvas uses the Assignment Groups API call to fetch the data on the Assignments page.

GET /api/v1/courses/:course_id/assignment_groups?
exclude_response_fields[]=description
exclude_response_fields[]=rubric
include[]=assignments
include[]=discussion_topic
override_assignment_dates=true
per_page=50

That does not include any submission data, though. To see if you have already submitted the assignment, you would need to use the Submissions API.

GET /api/v1/courses/:course_id/students/submissions?
per_page=50

In both cases, you will need to use pagination if there are more than 50 items. You can increase the 50 to 100, but it will take a little longer to fetch if you have a lot of assignments.

Also note that I've split the query parameters to multiple lines to make it easier to read and that there are ampersands & before each of the query parameters except for the first one.

View solution in original post