Skip to content
  1. Guides
  2. Code examples

Guides

Code examples

Each example creates an order, waits for it to finish, and saves the PDF. Pick your language on any code block and the whole page follows.

Language Needs
cURL Bash, curl and jq.
PHP PHP 8.1+ and Guzzle (composer require guzzlehttp/guzzle).
Java Java 17+ (the built-in java.net.http client) and Jackson for JSON.
Python Python 3.8+ and requests (pip install requests).
#!/usr/bin/env bash
set -euo pipefail

BASE="https://www.all789uss.com/api/v1"
VIN="WBA3A5C50CF256651"
api() { curl -sSf -H "Authorization: Bearer $VINHISTORY_KEY" -H "Accept: application/json" "$@"; }

NUMBER=$(api "$BASE/orders" -H "Content-Type: application/json" -d "{
  \"brand\": \"bmw\",
  \"vin\": \"$VIN\",
  \"customer_name\": \"Ali Hassan\",
  \"customer_email\": \"[email protected]\"
}" | jq -r '.data.number')

for _ in $(seq 60); do
  sleep 30
  ORDER=$(api "$BASE/orders/$NUMBER")
  STATUS=$(jq -r '.data.status' <<< "$ORDER")

  if [ "$STATUS" = "completed" ]; then
    # The signed link needs no token.
    curl -sSf -o "$VIN.pdf" "$(jq -r '.data.report_url' <<< "$ORDER")"
    break
  fi

  if [ "$STATUS" = "cancelled" ]; then
    echo "No records found for this vehicle."
    break
  fi
done