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/uploadThe 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
Simple sentiment label. One of positive, neutral, or negative.
analyses[].data.prob integer
Probability of value occurrence. In range (0.0, 1.0).
analyses[].data.value string
Spam label. One of spam or ham.
analyses[].data.prob integer
Probability of value occurrence. In range (0.0, 1.0).
analyses[].data.value string
Personlity Myers-Brigg label. Classified by focus: extraversion(E) or introversion(I), information input: sensing(S) or intuition(N), decision making: thinking(T) or feeling(F) and lifestyle: judging(J) or perceiving(P). One of ESTJ, ENTJ, ESFJ, ENFJ, ISTJ, ISFJ, INTJ, INFJ, ESTP, ESFP, ENTP, ENFP, ISTP, ISFP, INTP, or INFP.
analyses[].data.prob1 integer
Probability of preferring extraversion or introversion depending on value. In range (0.0, 1.0).
analyses[].data.prob2 integer
Probability of preferring sensing or intuition depending on value. In range (0.0, 1.0).
analyses[].data.prob3 integer
Probability of preferring thinking or feeling depending on value. In range (0.0, 1.0).
analyses[].data.prob4 integer
Probability of preferring judging or perceiving depending on value. In range (0.0, 1.0).
analyses[].data.group boolean
whether if value result is based on contents grouped in query.contents_groups
analyses[].data[].value string
Topic label. Word or phrase derived from content.
analyses[].data[].topic_type string
Type of value. One of entity or noun-chunk.
analyses[].data[].sub_type integer
Classification of topic_type, if any.
- If topic_type is entity, one of PERSON, NORP, FAC, ORG, GPE, LOC, PRODUCT, EVENT, WORK_OF_ART, LAW, or LANGUAGE.
- If topic_type is noun-chunk, one of POS, ADJ, ADV, ADP, VERB, NOUN, PROPN, INTJ, SCONJ, AUX, CONJ, CCONJ, INTJ.
analyses[].data.value string
Intention label. Classified by affect: affective or denotative, time: present/past or future and description: descriptive or prescriptive. One of assertion, valuation, palinode, contrition, forecast, wish, proposal, inducement, or none.
Intention Label Classification
- assertion (denotative, present/past, descriptive)
- valuation (affective, present/past, descriptive)
- palinode (denotative, present/past, prescriptive)
- contrition (affective, present/past, prescriptive)
- forecast (denotative, future, descriptive)
- wish (affective, future, descriptive)
- proposal (denotative, future, prescriptive)
- inducement (affective, future, prescriptive)
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).
analyses[].data[].value string
Detected object label.
analyses[].data[].prob integer
Probability of value occurrence. In range (0.0, 1.0).
analyses[].data[].value string
Detected activity label.
analyses[].data[].prob integer
Probability of value occurrence. In range (0.0, 1.0).
analyses[].data[].value string
Detected logo label.
analyses[].data[].prob integer
Probability of value occurrence. In range (0.0, 1.0).
analyses[].data[].description optional string
Text description of image.
analyses[].data[].duration optional string
Video length
analyses[].data[].descriptions optional array of hashes
Text descriptions of video moments.
analyses[].data[].descriptions[].timestamp string
Specific video moment
analyses[].data[].descriptions[].description string
Video description at this moment
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/operationsPayload
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.
{
"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."
]
}{
"type": "file",
"analyses": [
"face-id",
"sentiment-real",
"topic"
],
"contents": [
1, 2, 3
]
}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/:idExample
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/uploadExample
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
}Once file is used in an operation, it cannot be reused.
Last updated
Was this helpful?