Project 3: Web APIs
Write a Ruby program that uses the Carmen REST API to do something interesting and useful.
CarmenCanvas is the OSU-branded version of Canvas, a popular learning management system. The Canvas REST API provides access to course data, such as rosters, schedules, and assignments. For example, the Courses endpoint allows you to list all of the active courses in which you participate. The documentation describes the parameters of the request, as well as the JSON returned in the response.
To use this API, you will need to obtain an access token. To do so, log in to Carmen and click on "Account" in the left-hand navigation bar. Then click on "Settings" and then on "New Access Token". You will be prompted to enter a description for the token. You can enter anything you like, such as "CSE 3901 Project 3". Click on "Generate Token" and copy the token that is displayed. You will need to include this token in the header of each request you make to the API. For example:
$ curl -H "Authorization: Bearer <YOUR-ACCESS-TOKEN>" "https://osu.instructure.com/api/v1/courses"
Important: Protect your access token! Treat it like a password. Anyone who has your token can access your account and do anything you can do, including changing and deleting information.
In particular, never commit your access token to your git history.
Instead, store it in a file that is not tracked by git.
Create a file called .env
in the root
directory of your repository, then add this file to your
.gitignore
file.
The dotenv
gem can be used to
load the contents of this file into the environment
when you run your program.
Some starting ideas of possible projects are:
- A listing of all courses you have taken at OSU, along with relevant information such as the course number, title, and semester of enrollment.
- A listing of all courses you and another person took together.
- An HTML page that displays the Avatars of all the students in a given course in which you are enrolled.
You are not limited to these examples. But to be interesting and useful, your tool should do more than a single API request and display the returned JSON. Your project could do multiple requests, could use multiple APIs (e.g., see this list), and/or could do some processing of the returned data.
If you use an API beyond the Canvas API, it should be open (ie not require an access token). If your project will require API access tokens beyond one from Canvas, please contact the instructor to discuss.