ARTICLE

Intelligent Tagging | Extract Information from API Response

    Chavalit Jintamalit
    Developer Advocate

Introduction

This article will walk you through steps to make an API call to Intelligent Tagging(TRIT) with an unstructured text.

It then guides you to extract useful information from the Intelligent Tagging response.

This article provides a Python sample code in Jupyter Notebook and explains how it works.

A sample Jupyter Notebook file is available for download at the GitHub repository.

 

Prerequisites reading

Please read the Quick Start before reading this article.

You also need to register for an API key before you can make an API call. To do so, register for MyAccout. Then login to PermID.org with your new credentials. An Open Calais API Key is automatically e-mailed to you.

 

1. Make API calls to TRIT

This session provides guidance on how to make API calls using Python.

Please follow these detailed steps:

1.1 Import required libraries

1.2 Prepare content

1.3. Make an API calls to TRIT with the prepared content

2. Load content into JSON object

After step 1.3, you will get a response back into the TRITResponse variable and its content is in the text property.

You can load the content into a JSON object by following this sample code:

This is an example of the content.

Note that the content is quite large so only a few keys and value are being displayed here:

So we now have the TRIT response content in the JSONResponse variable and the datatype is JSON object.

3. Extract useful information from the JSON response

To extract the information the JSON response, you can follow these examples below:

3.1 Social Tag

Here is the sample JSON object:

Here is the sample code:

Here is the sample output

3.2 Topic

Here is the sample JSON object:

Here is the sample code:

Here is the sample output:

3.3 Entity

Here is the sample JSON object:

Here is the sample code:

Here is the sample output:

3.4 RIC

Here is the sample JSON object:

Here is the sample code:

Here is the sample output:

At this stage, you should be able to extract useful information from the Intelligent Tagging response.