Operation

Operations allow you to upload datasets to Product API for Social Understanding analytics.

[POST] /api/v2/products/api/operations
[GET] /api/v2/products/api/operations/:id
[POST] /api/v2/products/api/operations/upload

The operation object

Attributes

status string Current operation status. One of ready, pending, running, failed,invalid, or done.

query hash Query of operation request. query.type string Type of contents. Accepted values: - text: textual type contents. - file: file type contents (audio, images, or videos). query.analyses array of strings The analysis types applied to the operation. Accepted values: - sentiment-simple - sentiment-real - topic - spam-detection - personality-mb - intention - face-id - object-id - activity-id - logo-id - caption More info on supported analysis type.

query.contents array of strings or array of integers Contents to be analyzed depending on query.type. - Must be list of text entries if query.type is text. - Must be list of file IDs obtained through upload route or list of AWS S3 URLs for each file (publicly available) if query.type is file. Must be either file IDs or URLs per the same request.

query.contents_groups optional array of strings A list where each entry represents a group of indexes in query.contents. If not present, query.contents are treated as one group. Only works on analysis type personality-mb.

data hash (only if status is done, otherwise null) Results of analyzed query.contents. data.contents_count integer Total number of analyzed contents. data.contents array of hashes List of analyzed content object.

{
    "status": "done",
    "query": {
        "type": "text",
        "analyses": [
            "spam-detection", "topic", "intention"
        ],
        "contents": [
            "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
        ]
    },
    "data": {
        "contents": [
            {
                "type": "text",
                "content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
                "analyses": [
                    {
                        "data": {
                            "prob": 0.6,
                            "value": "spam"
                        },
                        "type": "spam-detection",
                        "source": "content",
                        "dimension": "textual"
                    },
                    {
                        "data": [
                            {
                                "value": "thesis",
                                "sub_type": null,
                                "topic_type": "noun-chunk"
                            }
                        ],
                        "type": "topic",
                        "source": "content",
                        "dimension": "textual"
                    },
                    {
                        "data": {
                            "prob1": 0.88,
                            "prob2": 0.74,
                            "prob3": 0.78,
                            "value": "palinode"
                        },
                        "type": "intention",
                        "source": "content",
                        "dimension": "textual"
                    }
                ],
                "dimensions": [
                    "textual"
                ],
                "analysis_types": [
                    "spam-detection",
                    "topic",
                    "intention"
                ]
            }
        ],
        "contents_count": 1
    }
}

The content object

Attributes

type string Type of content. One of text or file.

content string or integer Analyzed content. One of text entry, file ID or file URL.

dimensions array of strings Dimensions involved in this content. At least one of - textual - audial - visual-image - visual-gif - visual-video

analysis_type array of strings The analysis types applied to this content. At least one of - sentiment-simple - sentiment-real - spam-detection - personality-mb - topic - intention - face-id - object-id - activity-id - logo-id - caption

analyses array of hashes Content's result on analysis_type, if any. analyses[].source string Reference source leading to this result.

analyses[].type string Analysis type applied to this result. One of - sentiment-simple - sentiment-real - spam-detection - personality-mb - topic - intention - face-id - object-id - activity-id - logo-id - caption analyses[].dimension string Dimension involved in this result. One of - textual - audial - visual-image - visual-gif - visual-video

analyses[].group_index optional integer Index in query.contents_groups.

analyses[].data hash or array of hashes Analyzed result, if any. Data format varies from analyses[].type.

analyses[].data.value string Sentiment label. One of acceptance_self, acceptance, anger, annoyance, anxiety, calmness, contentment, disgust_self, disgust, dislike_self, dislike, eagerness, fear, joy, melancholy, pleasantness_self, pleasantness, responsiveness, sadness or serenity. analyses[].data.prob integer Probability of value occurrence. In range (0.0, 1.0).

analyses[].data[].value string Detected face label. analyses[].data[].prob integer Probability of value occurrence. In range (0.0, 1.0).

Create an operation

Creates and places new operation into queue. To check the status of an operation, use show route.

Request

[POST] /api/v2/products/api/operations

Payload

type string Type of contents. Accepted values: - text: textual type contents. - file: file type contents (audio, images, or videos).

analyses array of strings The analysis types applied to the operation. Accepted values: - sentiment-simple - sentiment-real - spam-detection - personality-mb - topic - intention - face-id - object-id - activity-id - logo-id - caption More info on supported analysis type. contents array of strings or array of integers Contents to be analyzed depending on type. - Must be list of text entries if type is text. - Must be list of file IDs obtained through upload route or list of AWS S3 URLs for each file (publicly available) if query.type is file. Must be either file IDs or URLs per the same request. contents_groups optional array of strings A list where each entry represents a group of indexes in contents. If not present, contents are treated as one group. Only works on analysis type personality-mb.

Indexing starts from 0.

{
    "type": "text",
    "analyses": [
        "spam-detection",
        "sentiment-real",
        "topic",
        "personality-mb"
    ],
    "contents_groups": [
        "1,2,3",
        "0,4,5"
    ],
    "contents": [
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
        "Praesent eget purus vel metus hendrerit vestibulum.",
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
        "Praesent eget purus vel metus hendrerit vestibulum.",
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
        "Praesent eget purus vel metus hendrerit vestibulum."
    ]
}

Example

curl -i -X POST 'https://product-api.redflagai.co/api/v2/products/api/operations' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer {{JWT_TOKEN}}' \
-d '{
    "type": "text",
    "analyses": [
        "spam-detection",
        "sentiment-real",
        "topic"
    ],
    "contents": [
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
        "Praesent eget purus vel metus hendrerit vestibulum."
    ]
}'

Response

The operation ID. To be used when retrieving operation.

{
    "id": 1
}

Retrieve an operation

Retrieves the operation with given operation ID.

Request

[GET] /api/v2/products/api/operations/:id

Example

curl -i -X GET 'https://product-api.redflagai.co/api/v2/products/api/operations/1' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H'Authorization: Bearer {{JWT_TOKEN}}' \

Response

The operation object.

Upload file content

Upload file as operation request's content. Only PNG, JPG, MP3 or MP4 is allowed.

Request

[POST] /api/v2/products/api/operations/upload

Example

curl -i -X POST 'https://product-api.redflagai.co/api/v2/products/api/operations/upload' \
-H 'Content-Type: multipart/form-data' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer {{JWT_TOKEN}}' \
-F 'file=@"{{FILE_LOCATION}}"'

Response

The file content ID. To be used when creating operation.

{
    "id": 1
}

Last updated

Was this helpful?