cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Learner

Adding attributes to links in returned HTML snippets to make it easier for API consumers to dig

Hi all,

Silly question, but I am hoping for examples of use-cases where our users and etc. would find benefit from course designers adding API endpoint attributes to HTML links in their front facing content.

I am referring to something similar to the guide here: https://canvas.instructure.com/doc/api/file.endpoint_attributes.html

We are in the process of updating a bunch of Canvas site front page templates for our faculties to roll out in their courses. In some cases we are already using API endpoint attributes in our HTML links, however, in the majority of cases, our front pages are just purely HTML with no reference to endpoint attributes.

I am trying to find an eloquent way to explain the benefit of adding API endpoint attributes to HTML links to our staff and provide some examples of why it's important and for what purpose(s).

E.g. 

<a style="font-size: 1rem;" title="Modules" href="{Your institution's Canvas domain}/courses/{canvas_course_id}/modules" data-api-endpoint="https://{Your institution's Canvas domain}/api/v1/courses/{canvas_course_id}/modules" data-api-returntype="[Module]">

OR

<a title="Class Resources" href="{Your institution's Canvas domain}/courses/{canvas_course_id}/pages/class-resources" data-api-endpoint="https://{Your institution's Canvas domain}/api/v1/courses/{canvas_course_id}/pages/class-resources" data-api-returntype="Page">

If anyone could provide me with some examples of how this data is harvested and by what or whom and why, that would be greatly appreciated.

Cheers,

Phil

 

 

 

 

 

 

Labels (5)
Tags (3)
0 Kudos
2 Replies
Highlighted
Adventurer

I have been doing some experimenting with generating indexes for content in a Canvas course. Thus far I have been working with pages that generally only have references to files in them (typically for images, PDFs, etc.) and I begin by fetching all pages - unfortunately, this means that I also get pages that are not actually reachable from the front page or from any published modules. In reality, what one would really want to do is to only index material that is reachable via the Front page and any visible navigation buttons (as this is the material that should be reachable by a student in the course). This means that as one traverses the graph(s) it is beneficial to know what the endpoint is as the data has a different structure and should or should not be indexed. Without the data-api-returntype one has to pattern match on the URL to know which function to call to decode the data that is returned.

 

Highlighted

Hi @maguire,

Thank you very much for providing your insight to my query. This now makes a lot more sense, and from your example, will save a fair amount of headache down the track. It also shows me that we there is a lot more we could be doing with our instance of Canvas.

Cheers,

Phil