Get models

Get the list of trained, deployed, or all models based on the query condition.

Syntax: GET/model

Table 1. Getting models requirements
Property Data type Description
apiKey header (required) String To authenticate API call.
status query (optical) String Status provided to retrieve the models. There are two values, 0 and 1. 0 - trained models, 1 - deployed models.
version query (optical) String Version provided to retrieve the models. (one specific version cannot be provided with version range (startVersion and endVersion) at the same time)
startVersion query (optical) String Version range provided to retrieve the models.
endVersion query (optical) String Version range provided to retrieve the models.
startDate query (optical) String Created date range provided to retrieve the models. Date format: YYYY/MM/DD (example: 2019/12/15)
endDate query (optical) String Created date range provided to retrieve the models. Date format: YYYY/MM/DD (example: 2019/12/25)

Model information is returned from the latest to the oldest in the response based on the query condition. If no query provided, all the models, including trained and deployed will be returned. Trained model means that the model is only trained but never be deployed with a machine learning model (classifier) selected. Deployed model means that this model is deployed already. If you want to use one specific deployed model to do the document classification after submitting a file for processing, see the function of /model?status=1 to retrieve the deployed models first and remember the model ID that you would like to use. Look at the function of Submit a document for processing for more details.classifierId is included in the model information as "ID" in "Classifiers" object. It is used to deploy a model later.

  • Curl
    curl -X GET -u 'Functional ID:Password' 'https://requesturl/ca/rest/content/v1/model?status=1'  -H 'apiKey: ZjMzYzg1ZDYtNTk1Nwhi5782NzItYjg3Mzg2ZGQwOGNhO3h5aWJtO2RlZmF1bHQ=' 
  • Java
    import java.io.IOException;
    import okhttp3.OkHttpClient;
    import okhttp3.Request;
    import okhttp3.Response;
    import okhttp3.RequestBody;
    import java.util.Base64;
    import okhttp3.MediaType;
    public class testcode {
      public static void main(String[] args) {
        String encoding = Base64.getEncoder().encodeToString(("Functional ID:Password").getBytes());
        OkHttpClient client = new OkHttpClient();
    
    
        Request request = new Request.Builder()
          .url("https://requesturl/ca/rest/content/v1/model?status=1")
          .get()
          .addHeader("apiKey", "ZjMzYzg1ZDYtNTk1Nwhi5782NzItYjg3Mzg2ZGQwOGNhO3h5aWJtO2RlZmF1bHQ=")
          .addHeader("Authorization", "Basic " + encoding)
          .build();
    
    
        try {
          Response response = client.newCall(request).execute();
          System.out.println(response.body().string());
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    }
    /*
     * The JAR files in Referenced Libraries could be found in the Download section with the following link:
     * 1. okhttp.jar - https://github.com/square/okhttp
     * 2. okio.jar - https://github.com/square/okio
     */
  • Javascript
    var request = require("request");
    var Base64 = require('js-base64').Base64;
    
    
    var encoding = Base64.encode('Functional ID:Password');
    var options = {
      method: 'GET',
      url: 'https://requesturl/ca/rest/content/v1/model?status=1',
      headers:
      {
        'apiKey' : 'ZjMzYzg1ZDYtNTk1Nwhi5782NzItYjg3Mzg2ZGQwOGNhO3h5aWJtO2RlZmF1bHQ=',
        'authorization': "Basic " + encoding
      }
    };
    
    
    request(options, function (error, response, body) {
      console.log(body)
      if (error) throw new Error(error);
    });
  • Python
    import requests
    import base64
    
    
    encoding = base64.b64encode(b'Functional ID:Password')
    
    
    url = "https://requesturl/ca/rest/content/v1/model?status=1"
    headers = {
     "apiKey" : "ZjMzYzg1ZDYtNTk1Nwhi5782NzItYjg3Mzg2ZGQwOGNhO3h5aWJtO2RlZmF1bHQ=",
     "authorization": "Basic " +  encoding.decode("utf-8") 
    }
    response = requests.request("GET", url, headers=headers)
Example response
{
  "status": {
    "code": 0,
    "messageId": "string",
    "message": "string"
  },
  "data": [
    {
      "Status": "Trained",
      "ModelID": 1,
      "Version": 49,
      "TrainedDate": "2019-10-16T18:30:28.232Z",
      "TrainedUser": "sample@test.com",
      "PublishedID": 3,
      "PublishedDate": "2019-10-18T05:51:29.905Z",
      "PublishedUser": "sample@test.com",
      "DefaultClassifier": 30,
      "NoOfDocClass": 5,
      "Classifiers": [
        {
          "ID": 209,
          "DisplayName": "Model 2",
          "Accuracy": 87.5
        }
      ],
      "DocumentClassAndDocuments": {
        "DocumentClassID": 1,
        "DocumentClass": "Invoice",
        "NoOfDocuments": 55,
        "NoOfDocumentsUsedForTraining": 55,
        "Documents": [
          {
            "DocumentID": 11,
            "DocumentName": "Invoice1.pdf",
            "DocumentNumPages": 1,
            "DocumentStatus": 4
          }
        ]
      }
    }
  ]
}