Understanding the xAPI Specification: Activity Profile API

07 July 2016 by Ryan Smith

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

blank
Ryan Smith
Software Development Team Lead

Starting as a placement student in 2014, Ryan re-joined the Learning Locker team after graduating from Oxford Brookes University where he won the John Birch prize for the highest grade average in the University.

From his minimalist desk, Ryan leads the Learning Locker team and consults with people on all things xAPI to conscientiously craft products and services that sustain and evolve training and performance.

When he’s not swimming or injuring himself on the cricket field, Ryan enjoys playing funny (and usually inappropriate) games with his family.

View more from Ryan Smith
blank
Read more about Learning Pool
Visit our Learn and Connect section

Get a free demo

Get in touch to find out how we can help

Start your learning journey

Get started by telling us what you need and one of our team will be in touch very soon.