Retrieving Your Results
Introduction
This guide explains how to retrieve and interpret the JSON model results generated by the Indico Intake platform. These files allow users to integrate Indico's document processing results into their downstream systems, offering a structured summary of each processed submission.
How to Retrieve JSON Model Results
Retrieving Results Using the API
Results can be accessed through a submission's "Results File" attribute, or you can use the Indico API to retrieve them programmatically. Please read our article on Retrieving Submissions to learn more.
Results with SNS
If SNS (Simple Notification Service) is enabled and Review is disabled, Indico will send notifications with results files upon submission completion. In this case, you do not need to query the platform to retrieve the raw JSON results.
Example:
After retrieving the result file, it is saved as a .json file:
from json import dump
from indico import IndicoClient, IndicoConfig
from indico.queries import RetrieveStorageObject, SubmissionResult
# Submission id to use
sub_id=1234
# Create client
HOST='mycluster.indico.io'
TOKEN='./indico-api-token.txt'
config = IndicoConfig(host=HOST, api_token_path=TOKEN)
client = IndicoClient(config=config)
# Create Submssion Result job
job = client.call(SubmissionResult(sub_id, wait=True))
# Retrieve result file
result = client.call(RetrieveStorageObject(job.result))
# Write output
with open(f"result_{sub_id}.json") as f:
dump(result, f)
using System;
using System.IO;
using System.Threading.Tasks;
using IndicoV2;
using Newtonsoft.Json.Linq;
namespace Examples
{
public class RetrieveSubmission
{
private static string GetToken() =>
File.ReadAllText(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
"indico_api_token.txt"));
public static async Task Main()
{
var client = new IndicoClient(GetToken(), new Uri("https://mycluster.indico.io"));
int submissionId = 1;
var jobResult = await client.GetSubmissionResultAwaiter().WaitReady(submissionId);
Console.WriteLine(jobResult);
}
}
}
package com.indico;
import com.indico.query.GetSubmission;
import com.indico.query.Job;
import com.indico.storage.Blob;
import com.indico.storage.RetrieveBlob;
import com.indico.type.JobStatus;
import java.io.File;
import java.io.IOException;
import java.util.*;
import org.apache.commons.io.FileUtils;
import com.indico.entity.Submission;
import org.json.JSONObject;
public class main {
public IndicoClient client;
private static String token_path = "./indico_api_token.txt";
private static String host = "mycluster.indico.io"
private static Integer submission_id = 1;
public static void main(String args[]) throws Exception {
IndicoConfig config = new IndicoConfig.Builder().host(host)
.protocol("https")
.tokenPath(token_path)
.build();
client = new IndicoKtorClient(config);
Job job = client.submissionResult().submission(submission_id).execute();
/**
* each call to .status() executes a query.
*/
while (job.status() == JobStatus.PENDING) {
Thread.sleep(1000);
System.out.println("Job Status: " + job.status());
}
JSONObject obj = job.result();
String url = obj.getString("url");
RetrieveBlob retrieveBlob = client.retrieveBlob();
Blob blob = retrieveBlob.url(url).execute();
/**
* It is important to close blob storage objects to release the
* connections that may remain from reading the blob.
*/
blob.close();
System.out.println(blob.asString());
System.exit(0);
}
}
Successfully Retrieved
Once you can access the results file, check out our Interpreting Your Results article.
Accessing ETL and OCR Output
In your results file, the value of "etl_output" will contain an Indico storage object (e.g., a file named indico-file:///storage/submission/####/9/9_etl_output.json
). For more details on downloading storage objects, see Downloading Storage Objects.
Example:
from indico.client import IndicoClient
from indico.queries import RetrieveStorageObject
client = IndicoClient()
# From another operation such as GetSubmission
result_url = "indico-file:///storage/submission/1/2/submission_3_result.json"
# Retrieve storage object
result = client.call(RetrieveStorageObject(result_url))
using IndicoV2;
// With provided token and host
var client = new IndicoClient(token, new Uri(host));
var storageClient = client.Storage();
// From another operation such as GetSubmission
var resultUrl = "indico-file:///storage/submission/1/2/submission_3_result.json";
// Retrieve storage object
var result = await storageClient.GetAsync(new Uri(resultUrl), default);
import com.indico.IndicoClient;
import com.indico.IndicoKtorClient;
import com.indico.storage.RetrieveBlob;
import com.indico.storage.Blob;
// Create client with config provided
IndicoClient client = new IndicoKtorClient(config);
RetrieveBlob retrieveBlob = client.retrieveBlob();
// From another operation such as GetSubmission
String resultUrl = "indico-file:///storage/submission/1/2/submission_3_result.json";
// Retrieve storage object
Blob blob = retrieveBlob.url(resultUrl).execute();
Updated about 2 months ago