Empathize Endpoint

Created by Iago Fernández · last update December 10, 2019

About this endpoint

The empathize endpoint will return the TopTrends for the query

GET https://api.empathybroker.com/search/v1/query/{instance_id}/empathize?{Input_Parameters}

Input Parameters

Parameter Data Type
q String
lang String
start Integer
rows Integer

Implementation

Here is an example of a simple implementation in Java to consume this service

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Client client;
WebTarget target;
public void init(){
    client = ClientBuilder.newClient();
    target = client.target("https://api.empathybroker.com/search/v1/query/{instance_id}/empathize")
        //Query parameters
        .queryParam("lang","ES")
        .queryParam("start",0)
        .queryParam("rows",5)
   
}
 
public JSON getResponse(String query){
    return target.queryParam("q",query).request(MediaType.APPLICATION_JSON).get(JSON.class)
}

Output

The empathize endpoint will return a single Json node with the TopTrends

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{
    topTrends: [
        {
            title: "<b>sams</b>ng",
            title_raw: "samsung",
            facets: [
                {
                    facet: "rootCategories_facet"
                    values: [
                        {
                             value: "Mobile Phones",
                             count: 5,
                             filter: "{!tag=rootFilter}rootCategories_facet:Mobile Phones"
                        },
                        {
                             value: "Phone Accessories",
                             count: 3,
                             filter: "{!tag=rootFilter}rootCategories_facet:Phone Accessories"
                        }
                    ]
                }
            ]
        },
        {
            title: "<b>sams</b>ung galaxy",
            title_raw: "samsung galaxy"
        },
        {
            title: "tablet <b>sams</b>ung",
            title_raw: "tablet samsung"
        }
    ]
}