Understanding the xAPI Specification: Agent Profile API

07 July 2016 by Ryan Smith

This second post taking a look at the Document APIs explores the Agent Profile API; the component of the xAPI that allows you to store some additional data against a profile, such as whether that profile is part of a specific group that has access to additional settings or information.

In this post, we’ll look at how to use an API querying tool such as Postman to query the Agent Profile API using a practical example.

Querying the Agent Profile API

If you’ve not used Postman before, you may find it helpful to watch this video walkthrough as you work through the steps below:

Creating an Agent Profile

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

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

URL Parameters

agent:{“objectType”: “Agent”, “name”: “John Smith”, “account”:{“name”: “123”, “homePage”: “https://www.example.com/users/”}}

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 an Agent Profile

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

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

URL Parameters

agent:{“objectType”: “Agent”, “name”: “John Smith”, “account”:{“name”: “123”, “homePage”: “https://www.example.com/users/”}}

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 Agent Profiles

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

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

URL Parameters

agent:{“objectType”: “Agent”, “name”: “John Smith”, “account”:{“name”: “123”, “homePage”: “https://www.example.com/users/”}}

Headers

Authorization:Basic YOUR_BASIC_AUTH

X-Experience-API-Version:1.0.0

Response

[

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

]

Deleting an Agent Profile

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

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

URL Parameters

agent:{“objectType”: “Agent”, “name”: “John Smith”, “account”:{“name”: “123”, “homePage”: “https://www.example.com/users/”}}

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

Headers

Authorization:Basic YOUR_BASIC_AUTH

X-Experience-API-Version:1.0.0

The final post in our Document API series looks at the Activity Profile API.

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.