What Is xAPI? What's a Webhook?
xAPI and webhooks are ways to transfer data from one software to another, similar to Learning's API. Whereas APIs can both push and pull data, xAPI and webhook are limited to pushing data, and they do this immediately.
Our pals at Zapier have contrived a sweet analogy by way of explanation:
"There are two ways your apps can communicate with each other to share information: polling and webhooks. Polling is like knocking on your friend's door and asking if they have any sugar (i.e., information), but you have to go and ask for it every time you want it. Webhooks are like someone tossing a bag of sugar at your house whenever they buy some. You don't have to ask—they just automatically punt it over every time it's available."
Ready to start punting your sugar... er, data? Read on, your instructions await!
How Do xAPI and Webhook Differ?
The primary difference between xAPI and a webhook is the output of the data. xAPI is an eLearning specification making it possible to collect data about the wide range of experiences a person has when completing training activities. A webhook is not specified to eLearning outcomes and can be used to send any type of event information.
Said another way, in order for a client to gather data through Learning's xAPI they must have an LRS (Learning Record Store). An LRS is is a data storage system serving as a repository for learning records collected from connected systems where learning activities are conducted.
If a client does not have an LRS they cannot gather data through Learning's xAPI.
xAPI and Webhook Events
Both xAPI and the Webhook send data from Learning to third-party platforms. More specifically, they send what are called events. Any time one of the following events occurs, information about that event is sent to a recipient system in real time.
Webhook Events
User-created
User-restored
User-updated
User-archived
xAPI Events
Lesson Completed
Lesson Disliked
Lesson Liked
Section Viewed
Lesson Viewed
Question Answered
In-Person Training Session Attended
Term Searched
Questions skipped
How to Implement xAPI or the Webhook
Open the admin menu by clicking the cog icon in the upper right corner of the Learning interface.
Select Settings.
Select the API & Webhook tab.
Select the New Subscription button for the push service you wish to enable.
Tip: Learning's xAPI can handle multiple setups. The reporting webhook, user action webhook, and xAPI can all be used simultaneously.
After selecting either xAPI or Webhook, you'll be presented with a form like the one pictured below.
Add your payload URL to the first field. This URL is where event information will be sent. Your payload URL can be found in the learning record store (LRS) you've chosen.
Important Note: you must add the subdirectory
/statements
to the end of the payload URL before adding it to the corresponding field in Learning. For example, suppose the payload URL ishttps://sandbox.watershedlrs.com/api/organizations/9541/lrs
. When adding the URL to Learning, it should be formatted as follows:https://sandbox.watershedlrs.com/api/organizations/9541/lrs/statements
Next, create the token. To do so, you'll need a base64 encoder such as this one.
Your LRS will provide Key and Secret columns to aid in the encoding process. Grab the keys from the LRS and type or paste them into the text field. The format of the encoding is key:secret.
For example, if the key is "1234" and the secret is "5678", the format would be "1234:5678."
Enable "Perform URL safe encoding (uses Base64URL format)." This checkbox is located above the "ENCODE" button.
Click the encode button. This will generate your token.
Copy the token, then return to the API & Webhook tab in Learning. Paste the token into the token field of the subscription form.
Select the events you want the webhook to push, then click Save to complete the process.
Finally, return to the LRS and refresh the page. Events should begin to populate. If not, contact the Learning Support team.
Questions? Contact the Support team at support@lessonly.com