Skip to content

Understanding the xAPI Specification: Activity Profile API

Having looked at the Activity State API and Agent Profile API aspects of the Document API, we’re now looking at how to use the Activity Profile API.

As with the Agent Profile API, the Activity Profile API component of the xAPI allows you to store some additional information about an activity in a profile, that can later be queried and used in fairly simple things like leaderboards, or more complex things like language maps.

In this post, we’ll take a quick look at how to query and delete Activity Profiles using an API querying tool such as Postman.

Querying the Activity Profile xAPI

If you’re not familiar with Postman, you may find it useful to follow along with this video walkthrough:

Creating an Activity Profile

To create a activity profile, you can use a request similar to the one demonstrated below.

POST https://v2.learninglocker.net/v1/data/xAPI/actvities/profile

URL Parameters

activityId:https://www.example.com/activities/1

profileId:https://www.example.com/profiles/1

Headers

Authorization:Basic YOUR_BASIC_AUTH

X-Experience-API-Version:1.0.0

Content-Type:application/json

Body

{

“favourite”: “It’s a Wonderful Life”,

“cheesiest”: “Mars Attacks”


}

Retrieving a Activity Profile

To get a profile for an activity, you can use the Activity Profile  API as demonstrated below.

GET https://v2.learninglocker.net/v1/data/xAPI/actvities/profile

URL Parameters

activityId:https://www.example.com/activities/1

profileId:https://www.example.com/profiles/1

Headers

Authorization:Basic YOUR_BASIC_AUTH

X-Experience-API-Version:1.0.0

Response

{

“favourite”: “It’s a Wonderful Life”,

“cheesiest”: “Mars Attacks”


}

Retrieving All Activity Profiles

You may want to retrieve all of the profiles associated with an activity. The request below demonstrates how that can be done via the Activity Profile API.

GET https://v2.learninglocker.net/v1/data/xAPI/actvities/profile

URL Parameters

activityId:https://www.example.com/activities/1

Headers

Authorization:Basic YOUR_BASIC_AUTH

X-Experience-API-Version:1.0.0

Response

[

“https://www.example.com/profiles/1”


]

Deleting an Activity Profile

Finally, you may want to forget about the profile or remove an incorrect profile. This can be achieved with Activity Profile API as demonstrated in the request below.

DELETE https://v2.learninglocker.net/v1/data/xAPI/actvities/profile

URL Parameters

activityId:https://www.example.com/activities/1

profileId:https://www.example.com/profiles/1

Headers

Authorization:Basic YOUR_BASIC_AUTH

X-Experience-API-Version:1.0.0

For more practical xAPI advice and support, download our free Technology Manager’s Guide to xAPI

Got a learning problem to solve?

Get in touch to discover how we can help

CTA background