Get one sheet's values in its template's shape
JOB_ID=7c9e6679-7425-40de-944b-e07fc1f90ae7 # the jobId the submission answered withSHEET_NUMBER=1 # which sheet: 1 is the first page
curl -sS "https://api.speccapture.com/v1/extractions/$JOB_ID/sheets/$SHEET_NUMBER/values" \ -H "Authorization: Bearer $SPECCAPTURE_API_KEY"using System.Text.Json;
using HttpClient http = new() { BaseAddress = new Uri("https://api.speccapture.com") };http.DefaultRequestHeaders.Authorization = new("Bearer", Environment.GetEnvironmentVariable("SPECCAPTURE_API_KEY"));
string jobId = args[0]; // the jobId the submission answered withstring sheetNumber = args[1]; // which sheet: 1 is the first page
HttpResponseMessage response = await Call(HttpMethod.Get, $"/v1/extractions/{jobId}/sheets/{sheetNumber}/values");Console.WriteLine(await response.Content.ReadAsStringAsync());
// Sends a request; stops with the problem's code and detail if the API refuses it.async Task<HttpResponseMessage> Call(HttpMethod method, string path, HttpContent? body = null, string? idempotencyKey = null) { using HttpRequestMessage request = new(method, path) { Content = body }; if (idempotencyKey is not null) request.Headers.Add("Idempotency-Key", idempotencyKey); HttpResponseMessage response = await http.SendAsync(request); if (!response.IsSuccessStatusCode) { JsonElement problem = await Json(response); string? detail = (problem.TryGetProperty("detail", out JsonElement text) ? text : problem.GetProperty("title")).GetString(); Console.Error.WriteLine($"{(int)response.StatusCode} {problem.GetProperty("code")}: {detail}"); Environment.Exit(1); } return response;}
// Reads an answer as JSON.static async Task<JsonElement> Json(HttpResponseMessage response) => JsonDocument.Parse(await response.Content.ReadAsStringAsync()).RootElement;import osimport sys
import requests
API = "https://api.speccapture.com"session = requests.Session()session.headers["Authorization"] = f"Bearer {os.environ['SPECCAPTURE_API_KEY']}"
def call(method, path, **kwargs): """Send a request; stop with the problem's code and detail if the API refuses it.""" response = session.request(method, API + path, **kwargs) if not response.ok: problem = response.json() sys.exit(f"{response.status_code} {problem['code']}: {problem.get('detail', problem['title'])}") return response
job_id = sys.argv[1] # the jobId the submission answered withsheet_number = sys.argv[2] # which sheet: 1 is the first page
print(call("GET", f"/v1/extractions/{job_id}/sheets/{sheet_number}/values").text)const API = "https://api.speccapture.com";const headers = { Authorization: `Bearer ${process.env.SPECCAPTURE_API_KEY}` };
const [jobId, sheetNumber] = process.argv.slice(2); // the jobId the submission answered with; which sheet: 1 is the first page
console.log(await call("GET", `/v1/extractions/${jobId}/sheets/${sheetNumber}/values`).then((response) => response.text()));
// Sends a request; stops with the problem's code and detail if the API refuses it.async function call(method, path, init = {}) { const response = await fetch(API + path, { ...init, method, headers: { ...headers, ...init.headers } }); if (!response.ok) { const problem = await response.json(); console.error(`${response.status} ${problem.code}: ${problem.detail ?? problem.title}`); process.exit(1); } return response;}One sheet as GET /v1/extractions/{jobId}/values gives it, with the job’s id and template: data holds the sheet’s values under the template’s keys, waitingForReview names the values left out because they wait for a person (when the template does not carry the review state), and evidence mirrors data with the extras the template carries. keys=paths or keys=names chooses the keys, as on GET /v1/extractions/{jobId}/values. A sheet not read yet answers with its status and no data.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The job’s id: the jobId POST /v1/extractions answered with, or one GET /v1/extractions lists.
Which sheet of the job: 1 for the file’s first page, up to the job’s sheetCount.
Query Parameters
Section titled “Query Parameters”What the values are keyed by: names, the template’s names, or paths, SpecCapture’s keys (titleBlock.partNumber, bom, qty), which a rename never changes. Changes a template-shaped answer or json file only: the complete answer carries both each value’s path and its name. The template’s own choice when left out.
Responses
Section titled “Responses”OK
One sheet in its template’s shape: GET /v1/extractions/{jobId}/sheets/{sheetNumber}?shape=template.
object
The job the sheet belongs to.
flat or nested.
names or paths.
The template and version the job keeps.
object
drawing, or the workspace template’s id.
The template’s version the job was uploaded with, and keeps for good.
What the workspace calls the template now; “Standard” for drawing.
The sheet.
object
1 for the file’s first page.
Where the sheet is: a sheet not read has no data.
Whether a read sheet’s values can be used as delivered.
autoAccepted: Every value cleared the confidence threshold and nothing asked for a person’s look - a value the drawing does not print among them, settled as not printed (notPrinted), and a company name not found (notFound).needsReview: At least one value, or the sheet as a whole, needs a person to look.reviewed: A person has accepted or corrected every value that needed it.
When the template does not carry the review state: where in data a value still waiting for a person was left out (as null), as JSON Pointers - /Part Number, /Bill of Materials/0/Quantity - so nothing unchecked is taken as final. Empty when nothing waits; left out when the review state is carried.
The engine version that read the sheet; present only when the template carries each sheet’s details and the sheet has been read.
When the sheet was read; present only when the template carries each sheet’s details and the sheet has been read.
The number each general note in data is printed with, in the same order as the notes: 4 for 4. REMOVE ALL BURRS, read off the note’s front and never counted, so notes printed 1, 2, 4 are numbered 1, 2, 4. null for a note printed with no number, and for one left out of data while it waits for a person. Left out when the sheet has no notes array: the template leaves the notes out, or the sheet has not been read.
Examples
Sheet 1 in the template's shape: the drawn-by value waits for a person, so it is null in data and named in waitingForReview
{ "jobId": "7c9e6679-7425-40de-944b-e07fc1f90ae7", "shape": "flat", "keys": "names", "template": { "templateId": "c2b8f3a1-7e5d-4c9a-8f6b-1a2d3e4f5a6b", "version": 3, "name": "ERP import" }, "sheet": { "sheetNumber": 1, "status": "completed", "reviewState": "needsReview", "data": { "Part No.": "SC-10432", "Rev": "C", "Description": "BRACKET, MOUNTING", "Material": "AL 6061-T6 PER ASTM B209", "Finish": "ANODIZE PER MIL-A-8625 TYPE II, CLASS 1, BLACK", "Drawn by": null, "Parts list": [ { "Item": "1", "Quantity": "1", "Part Number": "SC-10433", "Description": "BRACKET BODY" }, { "Item": "2", "Quantity": "4", "Part Number": "MS24693-C272", "Description": "SCREW, MACHINE, FLAT HEAD" } ], "General notes": [ "1. ALL DIMENSIONS ARE IN INCHES.", "2. BREAK ALL SHARP EDGES .005-.015." ] }, "waitingForReview": [ "/Drawn by" ], "evidence": { "Part No.": { "confidence": 0.98, "quote": "PART NO SC-10432" }, "Rev": { "confidence": 0.99, "quote": "REV C" }, "Description": { "confidence": 0.96, "quote": "BRACKET, MOUNTING" }, "Material": { "confidence": 0.94, "quote": "MATERIAL: AL 6061-T6 PER ASTM B209" }, "Finish": { "confidence": null, "quote": "FINISH: ANODIZE PER MIL-A-8625 TYPE II CL 1" }, "Drawn by": { "confidence": 0.81, "quote": "DRAWN J. MORALES" }, "Parts list": [ { "Item": { "confidence": 0.99, "quote": null }, "Quantity": { "confidence": 0.99, "quote": null }, "Part Number": { "confidence": 0.97, "quote": null }, "Description": { "confidence": 0.97, "quote": null } }, { "Item": { "confidence": 0.99, "quote": null }, "Quantity": { "confidence": 0.98, "quote": null }, "Part Number": { "confidence": 0.95, "quote": null }, "Description": { "confidence": 0.96, "quote": null } } ], "General notes": [ { "confidence": null, "quote": null }, { "confidence": null, "quote": null } ] }, "noteNumbers": [ 1, 2 ] }}Bad Request: a problem with a stable code. See Errors for every code and what to do about it.
Every error: a problem with a stable code. https://speccapture.com/docs/api/errors lists every code.
object
A link to the code’s entry in the docs.
What went wrong, in a few words for a person: the same for every problem with this code.
The HTTP status of the answer.
What went wrong with this request and what to do about it, in a sentence or two for a person. Present on nearly every problem.
The path of the request that was refused.
What went wrong, as a stable code to branch on: a published code never changes meaning.
This request’s trace: quote it when asking for help.
Examples
The request is not valid.
{ "type": "https://speccapture.com/docs/api/errors#invalid_request", "title": "The request is not valid.", "status": 400, "detail": "keys must be names or paths; leave it out for the template's own.", "instance": "/v1/extractions/7c9e6679-7425-40de-944b-e07fc1f90ae7/sheets/1/values", "code": "invalid_request", "traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"}Not Found: a problem with a stable code. See Errors for every code and what to do about it.
Every error: a problem with a stable code. https://speccapture.com/docs/api/errors lists every code.
object
A link to the code’s entry in the docs.
What went wrong, in a few words for a person: the same for every problem with this code.
The HTTP status of the answer.
What went wrong with this request and what to do about it, in a sentence or two for a person. Present on nearly every problem.
The path of the request that was refused.
What went wrong, as a stable code to branch on: a published code never changes meaning.
This request’s trace: quote it when asking for help.
Examples
Not found.
{ "type": "https://speccapture.com/docs/api/errors#not_found", "title": "Not found.", "status": 404, "detail": "There is no extraction with this id, or this sheet, in your workspace.", "instance": "/v1/extractions/7c9e6679-7425-40de-944b-e07fc1f90ae7/sheets/3/values", "code": "not_found", "traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"}