The asynchronous endpoint is preferred for users who are submitting their volume in large batches as well as tasks containing large files (i.e. longer videos or audio clips).

Submit your request using only one of the three keys below:

  • Use media to stream a file through the post request.
  • Use url to send us a url where we can download the file.
  • Use text_data to submit raw text.

The asynchronous endpoint immediately sends a response acknowledging receipt of the task, along with a unique ‘task_id’. It then closes the connection. A callback response via POST will be sent to your callback_url once the task is finished processing.

Appropriate for both Model-Only and Model + Manual Review projects.

{
  "id": "dd52c0d0-9ec7-11ea-98a3-4b92424b8366",
  "project_id": 18416,
  "metadata": null,
  "status": [
    {
      "status": {
        "code": "0",
        "message": "SUCCESS"
      },
      "response": {
        "input": {
          "hash": "a71690e72e5cabafc73dc2717818fc6d",
          "inference_client_version": "4.0.8",
          "model": "textmod_svs_2langs_release_test2",
          "model_type": "TEXT_CLASSIFICATION",
          "model_version": 1,
          "text": "\"test data \"",
          "id": "b9388470-a078-11ea-a390-db89c3c0393a",
          "created_on": "2020-05-28T00:18:15.223Z",
          "user_id": 6994,
          "project_id": 18416,
          "charge": "0.00100",
          "media": {
            "mimetype": null
          },
          "config_version": 1,
          "config_tag": "default"
        },
        "output": [
          {
            "time": 0,
            "classes": [
              {
                "class": "suggestive",
                "score": 0.0014467007812158782
              },
              {
                "class": "sexual",
                "score": 0.0030431869985264462
              },
              {
                "class": "no_sexual",
                "score": 0.9955101122202576
              },
              {
                "class": "self_harm",
                "score": 0.00024444394045842647
              },
              {
                "class": "violence",
                "score": 0.0006280777110160782
              },
              {
                "class": "no_violence",
                "score": 0.9991274783485254
              },
              {
                "class": "yes_spam",
                "score": 0.0007537542650119708
              },
              {
                "class": "no_spam",
                "score": 0.999246245734988
              }
            ],
            "start_char_index": 0,
            "end_char_index": 18
          }
        ]
      }
    }
  ],
  "resent_on": "2020-05-28T00:19:40.769Z",
  "resent_by": "manual",
  "from_cache": true
}

EXAMPLES


curl --request POST \
  --url https://api.thehive.ai/api/v1/task/async \
  --header 'accept: application/json' \
  --header 'authorization: token <API_KEY>' \
  --form 'url=http://hive-public.s3.amazonaws.com/demo_request/gun1.jpg' \
  --form 'callback_url=https://webhook.site/#!/3f2cca3e-d386-44d8-9548-63275021a443'
var request = require("request");

var options = {
  method: 'POST',
  url: 'https://api.thehive.ai/api/v1/task/async',
  headers: {
    accept: 'application/json',
    authorization: 'token <API_KEY>'
  },
  form: {url:"http://hive-public.s3.amazonaws.com/demo_request/gun1.jpg",
        callback_url:"https://webhook.site/#!/3f2cca3e-d386-44d8-9548-63275021a443"}
};  

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
import requests
url = 'https://api.thehive.ai/api/v1/task/async'
headers = {"authorization": "token <API_KEY>", "accept": "application/json"}
data = {'url': 'http://hive-public.s3.amazonaws.com/demo_request/gun1.jpg', 'callback_url': 'https://webhook.site/#!/3f2cca3e-d386-44d8-9548-63275021a443'}
response = requests.post("https://api.thehive.ai/api/v1/task/async", headers = headers, data = data)

RESULTS


{
  "id":"dd52c0d0-9ec7-11ea-98a3-4b92424b8366",
  "message":"We received your task.",
  "project_id":14621,
  "user_id":5822,
  "task_id":"dd52c0d0-9ec7-11ea-98a3-4b92424b8366",
  "upload_history_id":"c5763977-8044-4aaa-a087-57d0c8146a03",
  "image_url":"https://thehive.ai/images/e7a7d72.jpg",
  "callback_url":"https://webhook.site/#!/a79037b9-10df-495e-bf15-940025fa9101",
  "queue_priority":3,
  "task_priority":3
}
{
"return_code":400,
"message":"Invalid Auth Method. 'Token' authentication required."
}
Form Data
file

Use this key to send a binary file through a post request.

string

Use this key to send your file using a publicly accessible url to a hosted media file.

string

Use text_data to submit raw text for text moderation projects.

string

Callback URL where Hive will post the response to.

string

User specified metadata the will be included in the callback response.

HEADERS
string
required

Project API Token from hive customer dashboard. Prepend with 'token'