REST APIs

JavaScriptAPIJSON

A REST API is a Representational State Transfer Application Programming Interface. That may sound daunting, but let's break it down in an eLearning scenario. "Representational State" means that you are taking some piece of content and creating a snapshot of it in time. "Transfer" means that you are taking that snapshot and moving it to a new location on the internet. "Application Programming Interface" means that you are using the new location's programming interface to tell it what to do with the snapshot once it's transferred. So, a REST API simply means that we are taking a snapshot of some piece of data and transferring it to a new location on the internet in a way that the new location can understand what to do with it.

Pull vs. Push

Pull means "give me your data so I can do something with it." So, a pull REST request in an eLearning scenario might be asking a content provider "give me your content so I can put it in my module" or asking a tool "give me my student's grade in your system."

Push means "take my data and do something with it." So, a push REST request in an eLearning scenario might be asking a gradebook "take this grade and add it to the student's gradebook" or asking a Learning Record Store "take this user xAPI data and store it for later analysis."

Security

Since most REST API requests involve multiple sites, there is often a need to ensure that the data being sent is coming from and going to the intended audience without being tampered with. This is typically done by including an API key or other security measure. Please note that when using an API key in client-side JavaScript that anyone can see your key in the inspector.

Data Format

When using JavaScript for REST API requests, the most common data format is JSON, which can then be parsed into JavaScript objects and manipulated on a web page, such as by placing it in an HTML element.

Examples

Pull Example

You can pull content directly from any EdTech Book publication into your eLearning module by using the ETB API. Here is an example of a JavaScript REST call that brings in the content of a chapter with ID 155:

Many content providers and other services have APIs that you can leverage, but most will require some form of secure transfer or login. Some examples include the following:

Push Example

You can push content to EdTech Books, such as xAPI experience data, by using the ETB API. Note that the push API requires an api_key, which you may find in your user settings.

This content is provided to you freely by EdTech Books.

Access it online or download it at https://edtechbooks.org/elearning_hacker/rest_apis.