NIF API

GET /api

Basic endpoint for sentiment/emotion analysis.

Example request:

GET /api?input=I%20love%20GSI HTTP/1.1
Host: localhost
Accept: application/json, text/javascript

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/javascript

{
  "@context":"http://127.0.0.1/api/contexts/Results.jsonld",
  "@id":"_:Results_11241245.22",
  "@type":"results"
  "activities": [
    "plugins/sentiment-140_0.1"
  ],
  "entries": [
    {
      "@id": "_:Entry_11241245.22"
      "@type":"entry",
      "emotions": [],
      "entities": [],
      "sentiments": [
        {
          "@id": "Sentiment0",
          "@type": "sentiment",
          "marl:hasPolarity": "marl:Negative",
          "marl:polarityValue": 0,
          "prefix": ""
        }
      ],
      "suggestions": [],
      "text": "This text makes me sad.\nwhilst this text makes me happy and surprised at the same time.\nI cannot believe it!",
      "topics": []
    }
  ]
}
Query Parameters:
  • input (i) – No default. Depends on informat and intype

  • informat (f) – one of turtle (default), text, json-ld

  • intype (t) – one of direct (default), url

  • outformat (o) – one of turtle (default), text, json-ld

  • prefix (p) – prefix for the URIs

  • algorithm (algo) – algorithm/plugin to use for the analysis. For a list of options, see GET /api/plugins. If not provided, the default plugin will be used (GET /api/plugins/default).

  • emotionModel (algo) – desired emotion model in the results. If the requested algorithm does not use that emotion model, there are conversion plugins specifically for this. If none of the plugins match, an error will be returned, which includes the results as is.

Request Headers:
  • Accept – the response content type depends on Accept header

Response Headers:
Status Codes:
POST /api

The same as GET /api.

GET /api/plugins

Returns a list of installed plugins. Example request and response:

GET /api/plugins HTTP/1.1
Host: localhost
Accept: application/json, text/javascript


{
  "@id": "plugins/sentiment-140_0.1",
  "@type": "sentimentPlugin",
  "author": "@balkian",
  "description": "Sentiment classifier using rule-based classification for English and Spanish. This plugin uses sentiment140 data to perform classification. For more information: http://help.sentiment140.com/for-students/",
  "extra_params": {
    "language": {
      "@id": "lang_sentiment140",
      "aliases": [
        "language",
        "l"
      ],
      "options": [
        "es",
        "en",
        "auto"
      ],
      "required": false
    }
  },
  "is_activated": true,
  "maxPolarityValue": 1.0,
  "minPolarityValue": 0.0,
  "module": "sentiment-140",
  "name": "sentiment-140",
  "requirements": {},
  "version": "0.1"
},
{
  "@id": "plugins/ExamplePlugin_0.1",
  "@type": "sentimentPlugin",
  "author": "@balkian",
  "custom_attribute": "42",
  "description": "I am just an example",
  "extra_params": {
    "parameter": {
      "@id": "parameter",
      "aliases": [
        "parameter",
        "param"
      ],
      "default": 42,
      "required": true
    }
  },
  "is_activated": true,
  "maxPolarityValue": 1.0,
  "minPolarityValue": 0.0,
  "module": "example",
  "name": "ExamplePlugin",
  "requirements": "noop",
  "version": "0.1"
}
GET /api/plugins/<pluginname>

Returns the information of a specific plugin. Example request and response:

GET /api/plugins/sentiment-random/ HTTP/1.1
Host: localhost
Accept: application/json, text/javascript

{
  "@context": "http://127.0.0.1/api/contexts/ExamplePlugin.jsonld",
  "@id": "plugins/ExamplePlugin_0.1",
  "@type": "sentimentPlugin",
  "author": "@balkian",
  "custom_attribute": "42",
  "description": "I am just an example",
  "extra_params": {
    "parameter": {
      "@id": "parameter",
      "aliases": [
        "parameter",
        "param"
      ],
      "default": 42,
      "required": true
    }
  },
  "is_activated": true,
  "maxPolarityValue": 1.0,
  "minPolarityValue": 0.0,
  "module": "example",
  "name": "ExamplePlugin",
  "requirements": "noop",
  "version": "0.1"
}
GET /api/plugins/default

Return the information about the default plugin.