API operations
Sending a JSON with an event
Example of a file containing a package of statements:
[
{"userId":1,"eventId":1,"time":1463988845701,"zm1":5,"zm2":8},
{"userId":1,"eventId":1,"time":1463988845709,"zm1":55,"zm2":55}
]
Example of a client query:
wget -q -O - --post-file=test.json https://localhost:8321/event?appid=3697
Example of a response:
[
{"userId":1,"scores":[{"modelId":1,"score":1.0}]},
{"userId":1,"scores":[{"modelId":1,"score":0.6}]}
]
Parameters
Name |
Description |
Obligatory |
appid |
Client id |
Yes |
ts |
Time in miliseconds (field name can be modified in config file) |
Yes |
event_id |
Event type (field name can be modified in config file) |
Yes |
user_id |
User id (field name can be modified in config file) |
Yes |
Response codes
Name |
Output JSON |
Cause |
403 Forbidden |
|
No appid |
200 |
"error": "Error during json parsing" |
Error during json parsing |
Query about user's profile (list of aggregates)
Example of a client query:
wget -q -O - "https://178.33.61.90:8323/profile?appid=3697&userid=AB123"
Example of a response:
{"agg1_last_value_all":5.0,"agg2_last_value_all":"AAA","agg3_cnt_all":3.0," agg3_sum_all":2330.0}
Parameters
Name |
Description |
Obligatory |
appid |
Client id |
Yes |
userid |
User id |
Yes |
Response codes
Name |
Output JSON |
Cause |
403 Forbidden |
|
No appid |
400 Bad request |
|
No userid |
Adding a model
Example of a client query:
wget -qO- --post-data='{"use_category":0, "value":0.6, "category_id":0.6, "client_value":0.6, "positive_target_cnt":0.6, "excluded":["www.wp.pl", "www.onet.pl"]}' http:// localhost:8323/models?appid=3697&modelid=123
Example of a response:
{} - no error
Parameters
Name |
Description |
Obligatory |
appid |
Client id |
Yes |
modelid |
Model id |
Yes |
value |
CPC (in programmatic) |
Yes |
client_value |
Client CPC (in programmatic) |
No |
use_category |
If 1 - model will be buid on categories, if 0 - model will be build on campaigns |
Yes |
category_id |
Model category id (in programmatic - campaign category) |
Yes, if use_category=1 |
positive_target_cnt |
In programmatic - a number of ordered clicks |
No |
excluded or included |
List of urls to exclude or include in a model (it could be either exclude or include field) |
No |
Response codes
Name |
Output JSON |
Cause |
403 Forbidden |
|
No appid |
404 Not Found |
|
No modelid |
400 Bad request |
|
Invalid format of modelid |
200 |
"error": "Parameter use_category must be set and must be an integer (0 or 1)" |
No use_category or invalid format |
200 |
"error": "Parameter value must be set and must be numeric" |
No value or invalid format |
200 |
"error": "Parameter category_id must be provided if use_category=1" |
No category_id while use_category=1 |
200 |
"error": "Exactly one parameter must be set (either included or excluded)" |
No excluded/included set or both excluded and included set |
Model desactivation
Example of a client query:
wget -qO- --delete http:// localhost:8323/models?appid=3697&modelid=123
Example of a response:
{} - no error
Parameters
Name |
Description |
Obligatory |
appid |
Client id |
Yes |
modelid |
Model id |
Yes |
Response codes
Name |
Output JSON |
Cause |
403 Forbidden |
|
No appid |
404 Not Found |
|
No modelid |
400 Bad request |
|
Invalid format of modelid |
200 |
"error": "model does not exist." |
The model does not exist |
Adding urls to exclude/include during modeling (in programmatic)
Example of a client query:
wget -qO- --post-data='{"excluded":["www.wp.pl", "www.onet.pl"]}' http:// localhost:8323/urls?appid=3697&modelid=123
Example of a response:
{} - no error
Parameters
Name |
Description |
Obligatory |
appid |
Client id |
Yes |
modelid |
Model id |
Yes |
excluded or included |
A list of urls to exclude or include during modeling |
Yes |
Response codes
Name |
Output JSON |
Cause |
403 Forbidden |
|
No appid |
404 Not Found |
|
No modelid |
400 Bad request |
|
Invalid format of modelid |
200 |
"error": "Exactly one parameter must be set (either included or excluded)"" |
No excluded/included set or both excluded and included set |
Example of a client query:
wget -qO- --get http:// localhost:8323/models?appid=3697&modelid=115
Example of a response:
{
"model_id": 115,
"active": 1,
"used": 0,
"first_model_time": null,
"saved_model_time": null,
"value": 6,
"client_value": 0.3,
"positive_target_cnt": 10000,
"category_id": 9,
"use_category": 0,
"end_date": "1970-01-01 00:00:00"
}
Parameters
Name |
Description |
Obligatory |
appid |
Client id |
Yes |
modelid |
Model id |
No - if empty, all models will be returned |
Response codes
Name |
Output JSON |
Cause |
403 Forbidden |
|
No appid |
400 Bad request |
|
Invalid format of modelid |
200 |
{} |
The model does not exist |
Example of a client query:
wget -qO- --get http:// localhost:8323/models?appid=3697
Example of a response:
[
{
"model_id": 111,
"active": 1,
"used": 0,
"first_model_time": null,
"saved_model_time": null,
"value": 6,
"client_value": 0.2,
"positive_target_cnt": 10000,
"category_id": 5,
"use_category": 1,
"end_date": null
},
{
"model_id": 112,
"active": 1,
"used": 0,
"first_model_time": null,
"saved_model_time": null,
"value": 6,
"client_value": 0.2,
"positive_target_cnt": 10000,
"category_id": 0,
"use_category": 0,
"end_date": "2018-02-28 04:00:02"
}
]
Parameters
Name |
Description |
Obligatory |
appid |
Client id |
Yes |
Response codes
Name |
Output JSON |
Cause |
[] |
|
There are no models for chosen appid |
Example of a client query:
wget -qO- --get http:// localhost:8323/models?appid=3697&used=1
Example of a response:
[1018,1312,1314,1315,1319,1355,1378,1379,1391,1398]
Parameters
Name |
Description |
Obligatory |
appid |
Client id |
Yes |
used |
1 - list of used models in on-line scoring (active=1 and used=1 in metadata), 0 - list of active models, but with used=0 |
|
Response codes
Name |
Output JSON |
Cause |
[] |
|
There are no models for chosen appid and used value |