Bash
This bash example shows how to use the Vaxtor Cloud ALPR API to request a plate analysis that includes Make, Model, and Color (MMC).
Code sample
bash
#!/bin/bash
TOKEN_URL="https://auth.vaxtor.cloud/connect/token"
API_URL="https://vaxtor.cloud/analysis/api/plate"
CLIENT_ID="${VAXTOR_CLIENT_ID}"
CLIENT_SECRET="${VAXTOR_CLIENT_SECRET}"
SCOPE="api"
IMAGE_FILE="image.jpg"
# Optional region override: export OCR_REGION="europe"
OCR_REGION_HEADER=""
[ -n "$OCR_REGION" ] && OCR_REGION_HEADER="-H Vaxtor-Ocr-Region: $OCR_REGION"
# Get Token
ACCESS_TOKEN=$(curl -s -X POST "$TOKEN_URL" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "client_id=$CLIENT_ID" \
-d "client_secret=$CLIENT_SECRET" \
-d "scope=$SCOPE" | jq -r '.access_token')
[ -z "$ACCESS_TOKEN" ] && echo "Error getting token" && exit 1
# Analyze Image (send raw binary)
RESPONSE=$(curl -s -X POST "$API_URL" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/octet-stream" \
$OCR_REGION_HEADER \
--data-binary @"$IMAGE_FILE")
# Show Result
echo "$RESPONSE"Code Overview
- Authentication
The script retrieves a bearer token via OAuth2 Client Credentials at https://auth.vaxtor.cloud/connect/token.
Export your client-id and client-secret before running the script:
bash
export VAXTOR_CLIENT_ID="your-client-id"
export VAXTOR_CLIENT_SECRET="your-client-secret"- API Request
Uses curl to POST the image file to https://vaxtor.cloud/analysis/api/plate with the Authorization: Bearer <token> header.