Batch Requests

Each indicoio function can be called with a batch of data for analyzing many examples with a single network request. This can improve the speed of using the indico APIs significantly. Simply pass in a list of inputs and receive a list of results in return. The optimal balance between the size of the batch requests and the amount of network requests varies case by case, but performance is usually optimal between 20-100 examples.

// 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

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