API Reference
REST API
All DDL operations (i.e. definitions of datasets/featuresets) can only be done via Python client. However, other operations that don't alter the definitions but just exchange data can also be done via a REST API in addition to the Python client.
/api/v1/log
Used to log data to a dataset. It's post call with the following properties:
webhook
: the name of the webhook to which the data should be loggedendpoint
: the endpoint of the webhook to which the data should be loggeddata
: json representing the dataframe that must be logged to the datasets. The json can either be a list of json rows, or a json object of columns where each key maps to a list of values.
Example
1url = "{}/api/v1/log".format(SERVER)
2headers = {"Content-Type": "application/json"}
3data = [
4 {
5 "user_id": 1,
6 "name": "John",
7 "age": 20,
8 "country": "Russia",
9 "timestamp": "2020-01-01",
10 },
11 {
12 "user_id": 2,
13 "name": "Monica",
14 "age": 24,
15 "country": "Chile",
16 "timestamp": "2021-03-01",
17 },
18 {
19 "user_id": 3,
20 "name": "Bob",
21 "age": 32,
22 "country": "USA",
23 "timestamp": "2020-01-01",
24 },
25]
26req = {
27 "webhook": "fennel_webhook",
28 "endpoint": "UserInfo",
29 "data": data,
30}
31response = requests.post(url, headers=headers, data=req)
32assert response.status_code == requests.codes.OK, response.json()
/api/v1/extract_features
Used to extract a set of output features given known values of some input features. It's a POST call with the following parameters:
input_features
: list of fully qualified names of input featuresoutput_features
: list of fully qualified names of desired output featuresdata
: json representing the dataframe of input feature values. The json can either be an array of json objects, each representing a row; or it can be a single json object where each key maps to a list of values representing a column. Strings of json are also accepted.log
: boolean, true if the extracted features should also be logged to serve as future training dataworkflow
: string describing the name of the workflow to which extract features should be logged (only relevant whenlog
is set to true)sampling_rate
: float between 0-1 describing the sampling to be done while logging the extracted features (only relevant whenlog
is true)
The response dataframe is returned as column oriented json.
Example
With column oriented data
1url = "{}/api/v1/extract_features".format(SERVER)
2headers = {"Content-Type": "application/json"}
3data = {"UserFeatures.userid": [1, 2, 3]}
4req = {
5 "output_features": ["UserFeatures"],
6 "input_features": ["UserFeatures.userid"],
7 "data": data,
8 "log": True,
9 "workflow": "test",
10}
11
12response = requests.post(url, headers=headers, data=req)
13assert response.status_code == requests.codes.OK, response.json()
With row oriented data
1url = "{}/api/v1/extract_features".format(SERVER)
2headers = {"Content-Type": "application/json"}
3data = [
4 {"UserFeatures.userid": 1},
5 {"UserFeatures.userid": 2},
6 {"UserFeatures.userid": 3},
7]
8req = {
9 "output_features": ["UserFeatures"],
10 "input_features": ["UserFeatures.userid"],
11 "data": data,
12 "log": True,
13 "workflow": "test",
14}
15
16response = requests.post(url, headers=headers, data=req)
17assert response.status_code == requests.codes.OK, response.json()