Currently, the Captricity API client library provides methods to accomplish the following:
- create a Batch
- read (get) a Batch
- delete a Batch
- add Batch Files to the Batch
- submit the Batch for processing
- get results for a specific Batch
- show a list of Batches in the account
- get Job status (percent completed)
- get Job results (for Jobs that are 100% complete)
- show a list of master Templates in the account
- get a list of all the Fields defined on a Template
I have also provided a number of example programs that demonstrate how the API client library works in a controlled environment. You can find these programs in the examples folder.
This code was built against Java 1.8.0_40 and uses ant 1.9.4 for the build tool.
From the base of the directory, type
ant jar
A jar file named captricity-1.2.jar will be generated in the base directory.
Copy/move the captricity-1.2.jar file into your classpath.
and then in your java program, like is done in the example code-- TestCaptricityClient.java,
import com.captricity.api.CaptricityClient;In order to use this code, you will also need a Captricity API Token.
To instantiate a Captricity API client object, use something like this:
CaptricityClient capClient = new CaptricityClient('6cf43...88b75');where the parameter is your Captricity API token.
You can then use this client object to make method calls against the Captricity API, as is shown in the example below:
JSONObject newBatch = capClient.createBatch("name of new batch", true, false);public CaptricityClient(String token)
public CaptricityClient(String token, String url) - Create a Captricity API client object.
- You will need a Captricity API token.
- Unless you have been directed otherwise, use the simpler constructor, and the endpoint URL will be set for you.
public JSONArray showBatches() throws Exception {...}- Returns a
JSONArrayof the Batches that exist in your account. - Parameters:
- None
public JSONObject createBatch(String name) throws Exception {...}
public JSONObject createBatch(String name, ArrayList<Integer> docIds) throws Exception {...}
public JSONObject createBatch(String name, Boolean sortingEnabled, Boolean isSortingOnly) throws Exception {...}
public JSONObject createBatch(String name, Boolean sortingEnabled, Boolean isSortingOnly, ArrayList<Integer> docIds) throws Exception {...}- Creates a Batch in accordance with the given name and properties.
- Returns a
JSONObjectrepresenting the Batch that was created by the method call. - Parameters:
String name- Provide a name for the Batch you are creatingBoolean sortingEnabled- Set to true to enable sorting for this Batch. The default value istrueif not specified.Boolean isSortingOnly- Set to true if you only want to sort this Batch (as opposed to submit for data extraction). The default value isfalseif not specified.ArrayList<Integer> docIds- Add anArrayListof integers representing the Template ID's of the templates that you want to use for sorting. Your account must have sorting enabled for this to work. If sorting is enabled on your account and you do not specify a list of Template ID's, your Batch will be sorted against all active templates in your account.
public JSONObject readBatch(int batchID) throws Exception {...}- Gets the Batch specified by the batchID parameter.
- Returns a
JSONObjectrepresenting the Batch. - Parameters:
int batchID- Batch ID of the Batch you want to get
public JSONObject deleteBatch(int batchID) throws Exception {...}- Deletes the Batch specified by the batchID parameter.
- Returns a
JSONObjectrepresenting the status of the delete request. - Parameters:
int batchID- Batch ID of the Batch you want to delete
public JSONObject addFileToBatch(int batchID, String fileName) throws Exception {...}
public JSONObject addFileToBatch(int batchID, String fileName, JSONObject metadata) throws Exception {...}- Adds the file found at the given pathname to the Batch with the specified Batch ID.
- Returns a
JSONObjectrepresenting the Batch File that was just added to the specified Batch by the method call. - Parameters:
int batchID- Batch ID of the Batch to which you want to add file (obtained from the resultingJSONObjectafter you create a Batch)String fileName- Full pathname of the file on your local file systemJSONObject metadata- AJSONObjectcontaining key:value pairs of your desired metadata for this Batch File. Defaults to emptyJSONObjectif not specified.
public JSONObject submitBatch(int batchID) throws Exception {...}- Submits the Batch specified by the batchID parameter for processing.
- Returns a
JSONObjectrepresenting the Batch that was submitted for processing. - Parameters:
int batchID- Batch ID of the Batch you want to submit for processing
public String getBatchResults(int batchID) throws Exception {...}
public String getBatchResults(int batchID, Boolean verboseResults) throws Exception {...}- Gets the results for the Batch specified by the batchID parameter.
- Returns a
Stringrepresenting the CSV output of the Batch results, or indicates current status otherwise. - Parameters:
int batchID- Batch ID of the Batch for which you want to obtain results.Boolean verboseResults- Set to true to enable verbose results output. The default value isfalseif not specified.
public int getJobStatus(int jobID) throws Exception {...}- Gets the percent completed value for the Job specified by the jobID parameter.
- Returns an
intrepresenting the percent completed. - Parameters:
int jobID- Job ID of the Job in question
public String getJobResults(int jobID) throws Exception {...}- Gets the results of the Job specified by the jobID parameter.
- Returns a
Stringrepresenting the CSV output of the Job results, or indicates that the Job is not 100% complete. - Parameters:
int jobID- Job ID of the Job in question
public JSONArray showTemplates() throws Exception {...}
public JSONArray showDocuments() throws Exception {...}- Returns a
JSONArrayof the master templates that exist in your account.showDocuments()method just points toshowTemplates()and is kept to maintain backwards compatibility. - Parameters:
- None
public JSONObject readTemplate(int templateId) throws Exception {...}- Gets the Template specified by the templateId parameter.
- Returns a
JSONObjectrepresenting the Template. - Parameters:
int templateId- Template ID of the Template you want to get.
public String listTemplateFields(int templateId) throws Exception {...}
public String listTemplateFields(int templateId, Boolean includeChoices) throws Exception {...} - Gets the list of Fields associated with the Template specified by the templateId parameter.
- Returns a
Stringrepresenting the list of fields associated with the Template. Note that the fields will be ordered alphabetically by name. - Parameters:
int templateId- Template ID of the Template for which you want to get the Field list.Boolean includeChoices- Set to true to show enumeration of choices of multiple choice fields. The default value isfalseif not specified.