API Reference

The Avvid API is organized around REST. It has predictiable resource-oriented URLs, returns JSON-encoded responses and uses standard HTTP response codes, authentication and verbs.

NO ACCOUNT?

Click here to set up your account.

JUST GETTING STARTED?

Check out the Dev Guide to learn how to set up and train some models.

BASE URL

http://www.develop.avvid.ai

Authentication

The API uses token authentication to authenticate incoming requests. A successful login call will return a token that will be used to authenticate any subsequent API calls

Authentication Request
Method: POST
URL: /api/custom_login

{

 "username": "your_username", # Your account username

 "password": "your_password" # Your account password

}

Response
200 OK

{

 "token": "AAA-AAA-AAA", # A String token. Used for all future API calls

 "user_id": "1234",

 "projects": [ "project1", "project2", "project3"] # A list of all the projects in your account

}

Detection

This call will run object detection on an image passed to the server. The image must be a base64 image String, no other formats are supported currently. A successful call will return a list of all the detections found in the image.

Detection API Call

URL: http://detector-prod.zbbmpamh3g.ca-central-1.elasticbeanstalk.com/api/detect

Method: POST

NOTE: This call does not use the base URL

{

 "name": "project_name", # The name of the project you are running detection on

 "user_id": "1234",

 "classes": ["a"], # Classes to detect. This is optional. By default all classes in the project will be detected

 "token": "AAA-AAA-AAA", # Auth token

 "image": "base64ImageString", # Image to run detection in in base 64 string,

 "showOutputImage": true, # Optional boolean value. If true, the API will return a labeled image of all the detections found in the image. Defaults to true

 "min_confidence": 0.3 # Minimum confidence of detections returned. Optional value, defaults to 0.3

}

200 OK

{

"detections": [{ # List of detections

  "class": "class_name" # The class that the detection belongs to

  "x": 0, # X coodinate of detection box

  "y": 0, # Y coodinate of detection box

  "width": 0, # width of detection box

  "height": 0, # height of detection box

  "confidence": 0.99, # Decimal of the confidence of the detection

},],

"output_image": "base64AnnotatedImageString,# The annotated image in base64 string

"min_confidence": 0.3, # Minimun detection confidence

"threshold": 0.3,

"image_height": 400, # Image height

"image_width": 600 # Image width

}

Classification

This call will run classification on an image passed to the server. The image must be a base64 image String, not other formats are supported currently. A successful call will return a list of possible classifications.

Classification Request

URL:http://detector-prod.zbbmpamh3g.ca-central-1.elasticbeanstalk.com/api/classify

Method: POST

NOTE: This call does not use the base URL

{

 "name": "project_name", # The name of the project you are running classification on

 "user_id": "1234",

 "token": "AAA-AAA-AAA" # Auth token

 "image": "base64ImageString" # Image to run detection in in base 64 string

 "showOutputImage": true # Optional boolean value. If true, the API will return a labeled image of all the detections found in the image. Defaults to true

 "min_confidence": 0.3 # Minimum confidence of detections returned. Optional value, defaults to 0.3

}

Response
200 OK

{

 "class_name_1": 0.6, # Name of the class as key, confidence of classification as value

 "class_name_2": 0.2 # Results can return multiple classes

}

OCR

This call will take an image and run optical character recognition on the image. This does not require a project to be run, it is separate functionality from your own models. Requires a base64 image string to be passes, not other formats are currently supported

Method: POST

URL: /api/ocr

"headers": {

 "Authorization":  "Token AAA-AAA-AAAA" # Replace this with your auth token

}


"body":{

 "name": "filename", # Name of the file to run OCR on. Must be .png or .jpg

 "byte_data": "base64ImageString" # Image as a base64 image string

}

200 OK

{

"DocumentMetadata": {

 'Pages': 123

},

"Blocks": [

 {

  "BlockType": 'KEY_VALUE_SET' | 'PAGE' | 'LINE' | 'WORD' | 'TABLE' | 'CELL' | 'SELECTION_ELEMENT'

  "Confidence": ...,

  "Text": 'String',

  "RowIndex": 123,

  "ColumnIndex": 123,

  "RowSpan": 123,

  "ColumnSpan": 123,

  "Geometry": {

   "BoundingBox": {

   "Width": ...,

   "Height": ...,

   "Left": ...,

   "Top": ...,

  },:

  "Polygon": [

   {

    "X": ...,

    "Y": ...,

   },

  ],

  "Id": 'String',

  "Relationships": [

   {

    "Type": 'VALUE' | 'CHILD',

    "Ids": ['String',]

   },

 ],

"DetectDocumentTextModelVersion": 'String'

}

Errors

AVVID uses conventional HTTP response codes to indicate the success or failure of an API request.

HTTP Status Codes
200 - OK
Everything went as planned
401 - Unauthorized
The given api token is invalid.
404 - Not Found
The requested resource does not exist
500 - Internal Errors
Our servers expierenced an error. (This is Rare)

Other API Method

Projects

Returns a list of all the projects in your account.

Request

Method: GET

URL: /api/projects

"headers": {

 Authorization: "Token AAA-AAA-AAA"

}

Response
200 OK

{

 "projects": ["project_1", "project_2"] # A list of existing projects in your account

}

Classes

Returns a list of classes in a project. Replace <project_name> with the name of your project

Request

Method: GET

URL: /api/<project_name>/classes

"headers": {

 Authorization: "Token AAA-AAA-AAA"

}

Response
200 OK

{

 "classes": ["class_1", "class_2"] # A list of existing classes in your project

}

Adding Images

Allows you to add an image to a project's dataset from the API. You can then log into the web app to label the image and train with it.

Request

Method: POST

URL: /detector/add_image

"headers": {

 Authorization: "Token AAA-AAA-AAA"

},

{

 "filename": "filename" ,# String name of the file

 "project": "project_name", #The name of the project your are adding the image to

 "width": 100, # Width of the image

 "height": 100, # Height of the image

 "byte_data": base64ImageString, # Image as base64 String

}

Response
200 OK

{

 "file_id": "aaaa-aaa-aaa", # Id of the file

 "file_url": "https://aca/asa/filename", # s3 URL of the file

}