Python
This Python example shows how to use the Vaxtor Cloud ALPR API to request a plate analysis that includes Make, Model, and Color (MMC).
Code sample
python
import requests
TOKEN_URL = "https://auth.vaxtor.cloud/connect/token"
API_URL = "https://vaxtor.cloud/analysis/api/plate"
CLIENT_ID = "PUT_YOU_CLIENT_ID_HERE"
CLIENT_SECRET = "PUT_YOU_CLIENT_SECRET_HERE"
SCOPE = "api"
# Get Token
token_response = requests.post(
TOKEN_URL,
data={
"grant_type": "client_credentials",
"client_id": CLIENT_ID,
"client_secret": CLIENT_SECRET,
"scope": SCOPE,
}
)
access_token = token_response.json().get("access_token")
if not access_token:
print("Error getting token")
exit(1)
# Analyse Image (raw binary upload)
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/octet-stream"
}
with open("image.jpg", "rb") as image_file:
response = requests.post(API_URL, headers=headers, data=image_file)
# Show Result
print(response.json())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
Sends the image as a raw binary body (application/octet-stream) to the ALPR endpoint https://vaxtor.cloud/analysis/api/plate with the Authorization: Bearer <token> header.