Make Your First Call

You can run the following commands in your browser to test whether you have successfully installed the client package. Don’t forget, you will need your API key to make your first call. In the code below replace YOUR_API_KEY with your personal API key (the 32-digit alphanumeric sequence assigned to you when you registered with indico). You should get back a number between 0 and 1.

// Single Example
fetch('https://apiv2.indico.io/sentiment', {
  method: 'POST',
  body: JSON.stringify({
    api_key: 'YOUR_API_KEY',
    data: 'I love writing code'
  })
})
  .then(r => r.json())
  .then(response => {
    console.log(response);
  })
  .catch(err => console.log(err));

// Batch Example
fetch('https://apiv2.indico.io/sentiment/batch', {
  method: 'POST',
  body: JSON.stringify({
    api_key: 'YOUR_API_KEY',
    data: [
      'I love writing code',
      'Alexander and the Terrible, Horrible, No Good, Very Bad Day'
    ]
  })
})
  .then(r => r.json())
  .then(response => {
    console.log(response);
  })
  .catch(err => console.log(err));

Results

// Single Example Output
{ results: 0.9819219949985644 }

// Batch Example Output
{ results: [
    0.9819219949985644,
    0.00015202198176385973
]}