The profile API allows you to add additional meta data (i.e. a profile) in JSON format to items which can be used for analysis in more sophisticated recommendation strategies.
Other than all the older REST style easyrec APIs (actions, recommendations,rankings,...) which all use HTTP GET requests exclusively, the new JSON profile API uses the appropriate HTTP functions depending on the type of call, so please pay attention to this fact when reading the documentation below.
All API calls accept data sent in either application/json or application/x-www-form-urlencoded.
The API allows for storing of complete profiles as well as adding and retrieving specific JSON fields to/from already existing profiles. To address specific fields in a profile JSONPath notations are used. You can find a description of JSONPath here and specifics of the implementation used in easyrec at Jayway JSONPath. To give you an easier start we copied some path examples from the latter source.
operator | description |
---|---|
$ |
The root element to query. This starts all path expressions. |
@ |
The current node being processed by a filter predicate |
* |
Wildcard. Available anywhere a name or numeric are required. |
.. |
Deep scan. Available anywhere a name is required. |
.<name> |
Dot-notated child |
['<name>' (, '<name>')] |
Bracket-notated child or children |
[<number> (, <number>)] |
Array index or indexes |
[start:end] |
Array slice operator |
[?(<expression>)] |
Filter expression. Expression must evaluate to a boolean value. |
Given the json
{ "store": { "book": [ { "category": "reference", "author": "Nigel Rees", "title": "Sayings of the Century", "price": 8.95 }, { "category": "fiction", "author": "Evelyn Waugh", "title": "Sword of Honour", "price": 12.99 }, { "category": "fiction", "author": "Herman Melville", "title": "Moby Dick", "isbn": "0-553-21311-3", "price": 8.99 }, { "category": "fiction", "author": "J. R. R. Tolkien", "title": "The Lord of the Rings", "isbn": "0-395-19395-8", "price": 22.99 } ], "bicycle": { "color": "red", "price": 19.95 } }, "expensive": 10 }
JsonPath | Result |
---|---|
$.store.book[*].author |
The authors of all books |
$..author |
All authors |
$.store.* |
All things, both books and bicycles |
$.store..price |
The price of everything |
$..book[2] |
The third book |
$..book[(@.length-1)] |
The last book |
$..book[0,1] |
The first two books |
$..book[:2] |
All books from index 0 (inclusive) until index 2 (exclusive) |
$..book[1:2] |
All books from index 1 (inclusive) until index 2 (exclusive) |
$..book[-2:] |
Last two books |
$..book[2:] |
Book number two from tail |
$..book[?(@.isbn)] |
All books with an ISBN number |
$.store.book[?(@.price < 10)] |
All books in store cheaper than 10 |
$..book[?(@.price <= $['expensive'])] |
All books in store that are not "expensive" |
$..book[?(@.author =~ /.*REES/i)] |
All books matching regex (ignore case) |
$..* |
Give me every thing |
This method stores the given profile to the item defined by the tenantid,itemid and the itemtypeid. If there is already a profile it will be overwritten.
HTTP POST
{yourServerURL}/api/1.1/json/profile/store
parameter | occurrence | description |
---|---|---|
apikey | required | The required API Key to access this service. (e.g. "8ab9dc3ffcdac576d0f298043a60517a") |
tenantid | required | tenant id to identify your website. (e.g. "EASYREC_DEMO") |
This method creates a new item and stores the given profile for this item.
HTTP POST
{yourServerURL}/api/1.1/json/profile/storeitemwithprofile
parameter | occurrence | description |
---|---|---|
apikey | required | The required API Key to access this service. (e.g. "8ab9dc3ffcdac576d0f298043a60517a") |
tenantid | required | tenant id to identify your website. (e.g. "EASYREC_DEMO") |
This method deletes the profile of the item defined by the tenantid, itemid and the itemtypeid.
HTTP DELETE
{yourServerURL}/api/1.1/json/profile/delete?apikey=8ab9dc3ffcdac576d0f298043a60517a&itemid=42&itemtype=ITEM&tenantid=EASYREC_DEMO
parameter | occurrence | description |
---|---|---|
apikey | required | The required API Key to access this service. (e.g. "8ab9dc3ffcdac576d0f298043a60517a") |
tenantid | required | tenant id to identify your website. (e.g. "EASYREC_DEMO") |
This method deletes a specific field of the profile which belongs to the item defined by the tenantid, itemid and the itemtypeid. The field can be addressed by a JSONPath expression.
HTTP DELETE
{yourServerURL}/api/1.1/json/profile/field/delete?apikey=8ab9dc3ffcdac576d0f298043a60517a&itemid=42&itemtype=ITEM&path=$.store.book.price&tenantid=EASYREC_DEMO
parameter | occurrence | description |
---|---|---|
apikey | required | The required API Key to access this service. (e.g. "8ab9dc3ffcdac576d0f298043a60517a") |
tenantid | required | tenant id to identify your website. (e.g. "EASYREC_DEMO") |
This method returns the profile of the item defined by the tenantid, itemid and the itemtypeid
HTTP GET
{yourServerURL}/api/1.1/json/profile/load?apikey=8ab9dc3ffcdac576d0f298043a60517a&itemid=42&itemtype=ITEM&tenantid=EASYREC_DEMO
parameter | occurrence | description |
---|---|---|
apikey | required | The required API Key to access this service. (e.g. "8ab9dc3ffcdac576d0f298043a60517a") |
tenantid | required | tenant id to identify your website. (e.g. "EASYREC_DEMO") |
This method loads the values from a specific field of the profile which belongs to the item defined by the tenantid, itemid and the itemtypeid. The field can be addressed by a JSONPath expression.
HTTP GET
{yourServerURL}/api/1.1/json/profile/field/load?apikey=8ab9dc3ffcdac576d0f298043a60517a&itemid=42&itemtype=ITEM&path=$.store.book.price&tenantid=EASYREC_DEMO
parameter | occurrence | description |
---|---|---|
apikey | required | The required API Key to access this service. (e.g. "8ab9dc3ffcdac576d0f298043a60517a") |
tenantid | required | tenant id to identify your website. (e.g. "EASYREC_DEMO") |
This method stores a value into a specific field of the profile which belongs to the item defined by the tenantid, itemid and the itemtypeid. The field can be addressed by a JSONPath expression.
HTTP PUT
{yourServerURL}/api/1.1/json/profile/field/store
parameter | occurrence | description |
---|---|---|
apikey | required | The required API Key to access this service. (e.g. "8ab9dc3ffcdac576d0f298043a60517a") |
tenantid | required | tenant id to identify your website. (e.g. "EASYREC_DEMO") |
This method adds a value to a specific ARRAY field of the profile which belongs to the item defined by the tenantid, itemid and the itemtypeid. The field can be addressed by a JSONPath expression.
HTTP PUT
{yourServerURL}/api/1.1/json/profile/field/push
parameter | occurrence | description |
---|---|---|
apikey | required | The required API Key to access this service. (e.g. "8ab9dc3ffcdac576d0f298043a60517a") |
tenantid | required | tenant id to identify your website. (e.g. "EASYREC_DEMO") |