Skip to main content

Image API Endpoints

All endpoints are under the /api prefix and require a valid API key.


GET /api/image

Retrieve a CertiLock sealing image by serial number.

Query Parameters

ParameterTypeRequiredDescription
serial_numberstringYesThe CertiLock serial number
api_keystringYesYour API key for authentication

Success Response — 200 OK

{
"image": "<base64-encoded JPEG string>",
"date_of_sealing": "2024-03-15 09:32:11"
}

Error Responses

CodeBodyCause
400{"error": "Serial number is required"}serial_number param missing
401{"error": "401 Unauthorized. Access Not Allowed"}Invalid or missing API key
404{"error": "Serial number not found"}Serial number not in serial_numbers table
404{"error": "Serial Number Image File not found"}File missing from S3
404{"error": "Could not Retrieve the image. Please retry again"}S3 read failed

Example Request

curl "https://dash.scottsdalemint.com/api/image?serial_number=SN123456&api_key=YOUR_API_KEY"

GET /api/image-random

Returns a randomly selected CertiLock image. Useful for demos and testing.

Query Parameters

ParameterTypeRequiredDescription
api_keystringYesYour API key for authentication

Success Response — 200 OK

Returns the raw JPEG binary (not base64). The Content-Type header is image/jpeg.

HTTP/1.1 200 OK
Content-Type: image/jpeg

<binary JPEG data>

Error Responses

Same error codes as GET /api/image, plus:

CodeBodyCause
404{"error": "Serial number not found"}Random ID out of range

Example Request

curl -o random-certilock.jpg \
"https://dash.scottsdalemint.com/api/image-random?api_key=YOUR_API_KEY"

Notes

  • The random endpoint picks a random id between 1 and 240,157 from the serial_numbers table. This value is hardcoded in the controller — update it as the table grows.
  • Images are served directly from S3; the middleware acts as an authenticated proxy.
  • The GET /api/image endpoint returns the image base64-encoded in JSON to allow easy embedding. The random endpoint returns a raw binary response for direct browser/download use.