{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/pexafy/json-schema/pexafy-photo-envelope-schema.json",
  "title": "PhotoEnvelope",
  "x-generated": "2026-11-19",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/pexafy-photos-api-openapi.yml#/components/schemas/PhotoEnvelope",
  "type": "object",
  "required": [
    "success",
    "data"
  ],
  "properties": {
    "success": {
      "type": "boolean"
    },
    "data": {
      "$ref": "#/$defs/Photo"
    },
    "meta": {
      "$ref": "#/$defs/Meta"
    }
  },
  "$defs": {
    "Attribution": {
      "type": "object",
      "description": "Credit line, ready to drop into a page. Most upstream licences require it even when they do not require a link.",
      "properties": {
        "html": {
          "type": "string"
        },
        "plain": {
          "type": "string"
        }
      }
    },
    "ColorName": {
      "type": "string",
      "enum": [
        "black",
        "white",
        "grey",
        "red",
        "orange",
        "yellow",
        "green",
        "teal",
        "blue",
        "purple",
        "pink",
        "brown"
      ],
      "x-extensible-enum": true,
      "description": "Extensible."
    },
    "LicenseType": {
      "type": "string",
      "enum": [
        "cc0",
        "unsplash",
        "pexels",
        "pixabay",
        "cc-by",
        "cc-by-sa"
      ],
      "x-extensible-enum": true,
      "description": "Extensible."
    },
    "Meta": {
      "type": "object",
      "properties": {
        "request_id": {
          "type": "string"
        },
        "took_ms": {
          "type": "number",
          "description": "Server side time, excluding transfer."
        }
      }
    },
    "Orientation": {
      "type": "string",
      "enum": [
        "landscape",
        "portrait",
        "square"
      ],
      "x-extensible-enum": true,
      "description": "Extensible: new orientations may be added."
    },
    "Photo": {
      "type": "object",
      "required": [
        "photo_id",
        "urls",
        "source",
        "license_type"
      ],
      "properties": {
        "photo_id": {
          "type": "string",
          "format": "uuid",
          "description": "UUIDv7. Sortable by creation time, which is why it is not an integer."
        },
        "image_url": {
          "type": "string",
          "format": "uri"
        },
        "urls": {
          "$ref": "#/$defs/PhotoUrls"
        },
        "width": {
          "type": "integer",
          "minimum": 1
        },
        "height": {
          "type": "integer",
          "minimum": 1
        },
        "blur_hash": {
          "type": [
            "string",
            "null"
          ],
          "description": "Placeholder while loading."
        },
        "orientation": {
          "$ref": "#/$defs/Orientation"
        },
        "color_name": {
          "$ref": "#/$defs/ColorName"
        },
        "color_hex": {
          "type": "string"
        },
        "photographer_username": {
          "type": "string"
        },
        "photographer_full_name": {
          "type": [
            "string",
            "null"
          ]
        },
        "photographer_url": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        },
        "source": {
          "$ref": "#/$defs/Source"
        },
        "license_type": {
          "$ref": "#/$defs/LicenseType"
        },
        "source_image_url": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        },
        "source_description": {
          "type": [
            "string",
            "null"
          ]
        },
        "description": {
          "type": [
            "string",
            "null"
          ]
        },
        "alt_description": {
          "type": [
            "string",
            "null"
          ],
          "description": "Short text for an alt attribute. Null for a large part of the catalogue; fall back to description, then to source_description, then to nothing rather than to the filename."
        },
        "uploaded_on": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        },
        "relevance_score": {
          "type": [
            "number",
            "null"
          ],
          "minimum": 0,
          "maximum": 1,
          "description": "Only present on search results. Comparable within one response and not across responses: the scores are normalised per query."
        },
        "attribution": {
          "$ref": "#/$defs/Attribution"
        }
      }
    },
    "PhotoUrls": {
      "type": "object",
      "required": [
        "thumb",
        "small",
        "regular",
        "large",
        "full"
      ],
      "description": "The same image at five widths. Pick the smallest one that fits; the CDN charges you nothing for it but the upstream library counts a view either way.",
      "properties": {
        "thumb": {
          "type": "string",
          "format": "uri"
        },
        "small": {
          "type": "string",
          "format": "uri"
        },
        "regular": {
          "type": "string",
          "format": "uri"
        },
        "large": {
          "type": "string",
          "format": "uri"
        },
        "full": {
          "type": "string",
          "format": "uri"
        }
      }
    },
    "Source": {
      "type": "string",
      "enum": [
        "pexels",
        "unsplash",
        "pixabay",
        "wikimedia"
      ],
      "x-extensible-enum": true,
      "description": "Upstream library. Extensible: this list grows as libraries are indexed, so parse it as an open string."
    }
  }
}