Skip to content
API console (try a request with your own key)Get early access

Quickstart

From an API key to every value on a drawing in a few minutes. You need:

  • An API key. A workspace’s owner or an admin makes one in the SpecCapture dashboard, under API keys (how).
  • A drawing: a PDF, TIFF, PNG, JPEG, BMP or WebP. To try it with ours first, download bracket.pdf (below).
  • One of: curl (with jq for the longer scripts), .NET 10, Python 3.9 or later with requests, or Node.js 20 or later. Every sample below comes in all four; pick a tab and the docs remember it.

Every sample below sends a file named bracket.pdf from the folder it runs in. To use ours, download it there:

Terminal window
curl -O https://speccapture.com/samples/bracket.pdf

In PowerShell: Invoke-WebRequest https://speccapture.com/samples/bracket.pdf -OutFile bracket.pdf.

It is a one-sheet drawing of a made-up mounting bracket, generated for the purpose: every value on it is invented, and its legend is Distribution Statement A, approved for public release. It is the drawing on the sample page, which shows what SpecCapture read from it and the file’s SHA-256, so you can compare your results with that reading. Reading it costs 4 credits, as any sheet does. To send your own drawing instead, put its name where the samples say bracket.pdf.

2. Put the key where the samples look for it

Section titled “2. Put the key where the samples look for it”

Every sample reads the key from the environment variable SPECCAPTURE_API_KEY, so it never appears in code:

Terminal window
export SPECCAPTURE_API_KEY="sc_live_..."

In PowerShell: $env:SPECCAPTURE_API_KEY = "sc_live_...".

check_key.sh
#!/usr/bin/env bash
set -euo pipefail
API=https://api.speccapture.com
AUTH="Authorization: Bearer $SPECCAPTURE_API_KEY"
account=$(curl -sS --fail-with-body "$API/v1/account" \
-H "$AUTH") || { echo "$account" >&2; exit 1; }
jq -r '"Workspace \(.workspaceName): \(.credits.available) credits, enough for \(.credits.sheetsAvailable) sheets"' <<<"$account"

Save as check_key.sh, set SPECCAPTURE_API_KEY, and run: bash check_key.sh. Needs curl; scripts also use bash and jq.

An answer of 401 means the key was not accepted; its code says why (Errors).

4. Submit a drawing, wait for it, and read it

Section titled “4. Submit a drawing, wait for it, and read it”
quickstart.sh
#!/usr/bin/env bash
set -euo pipefail
API=https://api.speccapture.com
AUTH="Authorization: Bearer $SPECCAPTURE_API_KEY"
DRAWING=bracket.pdf # the drawing to send: a PDF, TIFF, PNG, JPEG, BMP or WebP
job=$(curl -sS --fail-with-body "$API/v1/extractions" \
-H "$AUTH" \
-H "Idempotency-Key: $(openssl rand -hex 16)" \
-F "file=@$DRAWING") || { echo "$job" >&2; exit 1; }
jq -r '"Job \(.jobId): \(.sheetCount) sheets, \(.credits.reserved) credits reserved"' <<<"$job"
while true; do
job=$(curl -sS --fail-with-body "$API/v1/extractions/$(jq -r '.jobId' <<<"$job")" \
-H "$AUTH") || { echo "$job" >&2; exit 1; }
jq -r '" \(.status): \(.progress.sheetsCompleted) of \(.sheetCount) sheets read"' <<<"$job"
if [[ "$(jq -r '.status' <<<"$job")" =~ ^(completed|failed)$ ]]; then break; fi
sleep 5
done
while IFS= read -r summary; do
if [[ "$(jq -r '.status' <<<"$summary")" == "completed" ]]; then
sheet=$(curl -sS --fail-with-body "$API/v1/extractions/$(jq -r '.jobId' <<<"$job")/sheets/$(jq -r '.sheetNumber' <<<"$summary")" \
-H "$AUTH") || { echo "$sheet" >&2; exit 1; }
jq -r '"Sheet \(.sheetNumber) (\(.reviewState))"' <<<"$sheet"
jq -r '.fields[] as $field | " \($field.path) = \($field.value // "(not printed)") [\($field.reviewState), \($field.confidence)]"' <<<"$sheet"
fi
done < <(jq -c '.sheets[]' <<<"$job")

Save as quickstart.sh, set SPECCAPTURE_API_KEY, and run: bash quickstart.sh. Needs curl; scripts also use bash and jq.

The program sends the drawing with an Idempotency-Key, so a retry can never be charged twice; asks for the job every 5 seconds until it has finished; then prints every value of every sheet that was read, with its review state and confidence. A value printed as needsReview waits for a person in your workspace: it is delivered as read, but nobody has confirmed it yet. One printed as (not printed) is not on the drawing; when SpecCapture is sure of that it is autoAccepted, with nothing to check (Values a drawing does not print).