Political Analysis

POST https://apiv2.indico.io/political?version=[version]
Gauge the political leanings of a phrase or document.

Current Version: 2

Private cloud endpoint

POST https://[cloud].indico.domains/political/[batch]/?version=[version]

Arguments

data – String | List – required – text to be analyzed
[top_n] – Integer – optional (defaults to 3) – only return this many of the most likely topics
[threshold] – Float – optional (defaults to .0) – only return topics with likelihood greater than this number

Output

This function will return a dictionary with 4 key-value pairs. These key-value pairs represent the likelihood that each of 4 political leanings are expressed in the analyzed text. The keys in the dictionary are strings containing the political leanings and the values are the probabilities that the analyzed text is expressing each political view.

Values less than 0.05 indicate that it is very unlikely the text is expressing that particular political leaning.

  # single output
  {
      'libertarian': 0.27192999211817354,
      'green': 0.06525078204908323,
      'liberal': 0.11033990553871972,
      'conservative': 0.5524793202940235
  }

  # batch output
  [
      {
          'libertarian': 0.27192999211817354,
          'green': 0.06525078204908323,
          'liberal': 0.11033990553871972,
          'conservative': 0.5524793202940235
      },
      {
          'libertarian': 0.02334343866477883,
          'green': 0.03302544570586526,
          'liberal': 0.9254000702504355,
          'conservative': 0.01823104537892042
      }
  ]

Example

// Single Example
fetch('https://apiv2.indico.io/political', {
  method: 'POST',
  body: JSON.stringify({
    api_key: 'YOUR_API_KEY',
    data: 'I have a constitutional right to bear arms!',
    threshold: 0.25
  })
})
  .then(r => r.json())
  .then(response => {
    console.log(response);
  })
  .catch(err => console.log(err));

// Batch Example
fetch('https://apiv2.indico.io/political/batch', {
  method: 'POST',
  body: JSON.stringify({
    api_key: 'YOUR_API_KEY',
    data: [
      'I have a constitutional right to bear arms!',
      'I wish more candidates cared about the environment.'
    ],
    threshold: 0.25
  })
})
  .then(r => r.json())
  .then(response => {
    console.log(response);
  })
  .catch(err => console.log(err));