XPresso API

Getting Started
Before you start using the XPresso API, it is important to know that
  • The user needs to go the XPressoOnWeb homepage. Click on Sign up button.
  • The user will be redirected to Sign up page. Fill up the details required. On successful signup a verification token will be sent to the mail id provided during signup and the user will be redirected to Sign up verification page.
  • Get the token from the mail and use it in the verify account page.
  • The user will be redirected to success sign up page. From the my account page the user will get API Key and Secret Key which is required for XPresso API access.
  • Rest API endpoint
    The API functionality is available in the following endpoint
    http://xpresso.abzooba.com:9090/abzooba/engine/result/  "apikey=<API Key>#&#abz#&#apisecret=<API Secret>#&#abz#&#annotation=<ANNOTATION>#&#abz#&#domain=<DOMAIN>#&#abz#&#subject=<SUBJECT>#&#abz#&#feedback=<REVIEW>"
    (Please note that the subject field is optional. Also, if there is a need of a domain agnostic analysis, the domain field can also be ignored. eg. if there are not subjects and domain, the url becomes,
    http://xpresso.abzooba.com:9090/abzooba/engine/result/  "apikey=<API Key>#&#abz#&#apisecret=<API Secret>#&#abz#&#annotation=<ANNOTATION>#&#abz#&#feedback=<REVIEW>" )
      
  • It is a REST service that processes one document per request.
  • It uses POST method.
  • For every request you have to include your API key and Secret Key, the parameters for input text and the text you would like to analyze.
  • The API accepts documents as plain text and returns a response using the JSON format.
  • In case of errors and exception, error message is returned as plain text.
  • Request parameters
    These are the parameters you have to include in your POST request:
    apikey=<your api key>#&#abz#&#apisecret=<your api secret>#&#abz#&#domain=<domain>#&#abz#&#annotation=<annotation>#&#abz#&#feedback=<review string>
      
    Name Description Possible Values
    apikey License apikey. You will get your apikey once you signup. You can access the apikey and the apisecret from the My Account Page
    apisecret License apisecret. You will get your apisecret once you signup. You can access the apikey and the apisecret from the My Account Page
    annotation The text annotation that the user seeking for. pos,lemma,senti,parse,ner,emo
    domain The domain in which the input text belong.
    (For the need of domain agnostic analysis, this field should not be used)
    hospitality,retail,insurance,entertainment,toys,banking,telecom,pharmacy
    subject The subject the review is all about. It can be the retail chain name or hotel name or toy name the review is about
    feedback The input review text that need to be analysed. The review text
    Response
    The API's response is a JSON object which contains the results of the semantic analysis of the text. Example of response JSON for input review "food is good" is given below:
    {
    "food is good":{
    "About":[
    {
    "Entity":"food",
    "Aspect":"FOOD AND BEVERAGES",
    "Sentiment":"Positive",
    "StatementType":"Advocacy",
    "Indicative Snippet":"food is good",
    },
    {
    "Entity":"Overall",
    "Aspect":"Overall",
    "Sentiment":"Positive",
    "StatementType":"Advocacy",
    "Indicative Snippet":"food is good",
    }
    ]
    }
    }
    Use XPresso REST API from JAVA
    Sample code for using XPresso REST API from java code is given below.
    private static final String DELIMITER = "#&#abz#&#";
    String URL_LINK = "http://xpresso.abzooba.com:9090/abzooba/engine/result";
    URL url = new URL(URL_LINK);
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setRequestMethod("POST");
    connection.setDoOutput(true);
      
    BufferedWriter httpRequestBodyWriter = new BufferedWriter(new
    OutputStreamWriter(connection.getOutputStream()));
    String api_key = "<your api_key>";
    String api_secret = "<your api_secret>";
    String annotation = "<annotation>";
    String domain_name = "<domain_name>";  /*can be left null, if the need is so*/
    String subject = "<subject>"; /*can be left null*/
    String review = "<review_text>";
      
    BufferedWriter httpRequestBodyWriter = new BufferedWriter(new
    InputStreamWriter(connection.getInputStream()));
    StringBuilder requestQuery = new StringBuilder(
    "apikey=" + apiKey +DELIMITER +"apisecret="+ apiSecret +DELIMITER +"annotation=" + annotation);
      
    if (domainName != null) {
    requestQuery.append(DELIMITER).append("domain=" +domain_name);
    }
      
    if (subject != null) {
    requestQuery.append(DELIMITER).append("subject=" +subject);
    }
      
    requestQuery.append(DELIMITER).append("feedback=" + review);
    httpRequestBodyWriter.write(requestQuery.toString());
    httpRequestBodyWriter.close();
      
    Use XPresso REST API from Python
    Sample code for using XPresso REST API from python code is given below. It will require Python version 3 onwards.
    url_str = 'http://xpresso.abzooba.com:9090/abzooba/engine/result'
    data = 'apikey=<your api_key>#&#abz#&#apisecret=<your api_secret>#&#abz#&#annotation=<annotation>#&#abz#&#domain=<domain_name>#&#abz#&#subject=<subject>#&#abz#&#feedback=<review_text>'
    response = requests.post(url_str,data)
    print(response.status_code)
    print(response.text)
      
    Use XPresso REST API from CURL
    curl -X POST http://xpresso.abzooba.com:9090/abzooba/engine/result/ -d "apikey=<your api_key>#&#abz#&#apisecret=<your api_secret>#&#abz#&#annotation=<annotation>#&#abz#&#domain=<domain_name>#&#abz#&#subject=<subject>#&#abz#&#feedback=<review_text>"