API

Insert

Insert New Items

curl -X PUT -H 'Content-Type: application/json' 127.0.0.1:8080/items \
    -d '[{"ItemId":"2048","Timestamp":"2010-1-1"},{"ItemId":"2049","Timestamp":"2011-1-1"},{"ItemId":"2050","Timestamp":"2012-1-1"}]'

Insert three new items [{"ItemId":"2048","Timestamp":"2010-1-1"},{"ItemId":"2049","Timestamp":"2011-1-1"},{"ItemId":"2050","Timestamp":"2012-1-1"}].

{
    "ItemsBefore": 1682,
    "ItemsAfter": 1685,
    "UsersBefore": 221,
    "UsersAfter": 221,
    "FeedbackBefore": 100000,
    "FeedbackAfter": 100000
}

Insert New Feedback

curl -X PUT -H 'Content-Type: application/json' 127.0.0.1:8080/feedback \
    -d '[{"UserId":"2048","ItemId":"1000","Rating":3},{"UserId":"2049","ItemId":"1000","Rating":3},{"UserId":"2050","ItemId":"1000","Rating":3}]'

Insert three new ratings: <2048,1000,3>, <2049,1000,3> and <2050,1000,3>.

{
    "ItemsBefore": 1682,
    "ItemsAfter": 1682,
    "UsersBefore": 221,
    "UsersAfter": 224,
    "FeedbackBefore": 100000,
    "FeedbackAfter": 100003
}

Query

Get System Status

curl 127.0.0.1:8080/status

Get current system status.

{
    "FeedbackCount": 100000,
    "ItemCount": 1682,
    "UserCount": 221,
    "CommitCount": 100000,
    "CommitTime": "2019-12-07 14:47:53.657515767 +0800 CST m=+60.702418740"
}

Get Latest Items

curl 127.0.0.1:8080/latest?number=10

Get top 10 latest items.

  • number: number of returned items.
[
    {
        "ItemId": "315",
        "Popularity": 160,
        "Timestamp": "1998-10-23T00:00:00Z",
        "Score": 909100800
    },
    {
        "ItemId": "1432",
        "Popularity": 3,
        "Timestamp": "1998-10-09T00:00:00Z",
        "Score": 907891200
    },
    ...
    {
        "ItemId": "1648",
        "Popularity": 1,
        "Timestamp": "1998-03-20T00:00:00Z",
        "Score": 890352000
    }
]

Get Random Items

curl 127.0.0.1:8080/random?number=10

Get 10 random items.

  • number: number of returned items.
[
    {
        "ItemId": "42",
        "Popularity": 148,
        "Timestamp": "1994-01-01T00:00:00Z",
        "Score": 0
    },
    {
        "ItemId": "71",
        "Popularity": 220,
        "Timestamp": "1994-01-01T00:00:00Z",
        "Score": 0
    },
    ...
    {
        "ItemId": "1144",
        "Popularity": 3,
        "Timestamp": "1997-05-02T00:00:00Z",
        "Score": 0
    }
]

Get Similar Items

curl 127.0.0.1:8080/neighbors/100/?number=10

Get top 10 similar items for the 100th item.

  • number: number of returned items.
[
    {
        "ItemId": "1424",
        "Popularity": 3,
        "Timestamp": "1994-01-01T00:00:00Z",
        "Score": 1.0000000000000002
    },
    {
        "ItemId": "1234",
        "Popularity": 8,
        "Timestamp": "1998-01-01T00:00:00Z",
        "Score": 1
    },
    ...
    {
        "ItemId": "1554",
        "Popularity": 2,
        "Timestamp": "1994-01-01T00:00:00Z",
        "Score": 1
    }
]

Get User History

curl 127.0.0.1:8080/user/1/feedback

Get interaction history of user 1.

[
    {
        "UserId": "1",
        "ItemId": "1",
        "Rating": 5
    },
    ...
]

Get all users

curl 127.0.0.1:8080/users

List all users.

[
    "1",
    "2",
    ...
]