{
  "openapi": "3.1.0",
  "info": {
    "title": "Ayr Art discovery API",
    "version": "0.2.0",
    "description": "Read-only fine art discovery. Melissa Ayr and the public Ayr Gallery roster; sourced independent gallery links. Not approved or endorsed by Meta.",
    "contact": {
      "name": "Ayr Art, Inc.",
      "email": "hello@ayrart.ai"
    },
    "termsOfService": "https://ayrart.ai/terms"
  },
  "servers": [
    {
      "url": "https://ayrart.ai",
      "description": "Production Ayr Art discovery service."
    },
    {
      "url": "/",
      "description": "Origin serving this specification. Private review sites require hosting access."
    }
  ],
  "security": [],
  "paths": {
    "/api/artworks": {
      "get": {
        "operationId": "searchArtworks",
        "summary": "Browse or keyword-search available originals",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 150
            },
            "description": "Case-insensitive keyword overlap in published text"
          },
          {
            "name": "artist",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "melissa-ayr"
            },
            "description": "Artist slug or all; use /api/artists to check the roster"
          },
          {
            "name": "maxPrice",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "minimum": 0,
              "maximum": 1000000000
            },
            "description": "USD ceiling; unpriced works excluded"
          },
          {
            "name": "medium",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 80
            },
            "description": "Substring in the published medium"
          },
          {
            "name": "id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 100
            },
            "description": "Artwork UUID or slug"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 24
            },
            "description": "Page size"
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000,
              "default": 0
            },
            "description": "Page offset"
          }
        ],
        "responses": {
          "200": {
            "description": "Discovery results with source provenance",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "source",
                    "fetchedAt",
                    "total",
                    "returned",
                    "offset",
                    "limit",
                    "works"
                  ],
                  "properties": {
                    "source": {
                      "type": "string",
                      "format": "uri"
                    },
                    "fetchedAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "query": {
                      "type": "string"
                    },
                    "artist": {
                      "type": "string"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "returned": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "matchMethod": {
                      "type": "string"
                    },
                    "scope": {
                      "type": "string"
                    },
                    "works": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Artwork"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid query parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Source unavailable; no stale or partial inventory returned",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/artists": {
      "get": {
        "operationId": "listArtists",
        "summary": "Read the live public Ayr Gallery artist roster",
        "responses": {
          "200": {
            "description": "Discovery results with source provenance",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "source",
                    "fetchedAt",
                    "artists"
                  ],
                  "properties": {
                    "source": {
                      "type": "string",
                      "format": "uri"
                    },
                    "fetchedAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "scope": {
                      "type": "string"
                    },
                    "artists": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Artist"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid query parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Source unavailable; no stale or partial inventory returned",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/galleries": {
      "get": {
        "operationId": "discoverGalleries",
        "summary": "Find sourced gallery links; no external inventory",
        "parameters": [
          {
            "name": "city",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "San Francisco",
                "Los Angeles",
                "Online",
                "sf",
                "la"
              ]
            },
            "description": "Directory location"
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 150
            },
            "description": "Directory text substring"
          }
        ],
        "responses": {
          "200": {
            "description": "Discovery results with source provenance",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "checkedAt",
                    "scope",
                    "galleries"
                  ],
                  "properties": {
                    "checkedAt": {
                      "type": "string",
                      "format": "date"
                    },
                    "scope": {
                      "type": "string"
                    },
                    "galleries": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Gallery"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Artwork": {
        "type": "object",
        "required": [
          "id",
          "title",
          "artist",
          "status",
          "publicUrl"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "artist": {
            "type": "string"
          },
          "artistSlug": {
            "type": "string"
          },
          "collection": {
            "type": "string"
          },
          "medium": {
            "type": "string"
          },
          "dimensions": {
            "type": "string"
          },
          "year": {
            "type": "string"
          },
          "price": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "galleryId": {
            "type": "string"
          },
          "gallery": {
            "type": "string"
          },
          "imageUrl": {
            "type": "string",
            "description": "Cloudflare Images /web URL, or empty when unavailable"
          },
          "publicUrl": {
            "type": "string",
            "format": "uri"
          },
          "purchaseUrl": {
            "type": "string",
            "description": "Verified upstream Ayr Gallery purchase route, or empty when checkout is unavailable"
          },
          "checkoutAvailable": {
            "type": "boolean",
            "description": "Catalog reports eligibility; confirm again with the gallery before purchase"
          },
          "relevance": {
            "type": "number"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          }
        }
      },
      "Artist": {
        "type": "object",
        "required": [
          "id",
          "slug",
          "name",
          "publicUrl"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "bio": {
            "type": [
              "string",
              "null"
            ]
          },
          "websiteUrl": {
            "type": "string"
          },
          "publicUrl": {
            "type": "string",
            "format": "uri"
          },
          "imageUrl": {
            "type": "string"
          },
          "publicWorkCount": {
            "type": "integer"
          },
          "isFoundingArtist": {
            "type": "boolean"
          },
          "galleryId": {
            "type": "string"
          }
        }
      },
      "Gallery": {
        "type": "object",
        "required": [
          "id",
          "name",
          "city",
          "website",
          "sourceUrl",
          "checkedAt",
          "catalogConnected"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "address": {
            "type": "string"
          },
          "summary": {
            "type": "string"
          },
          "relationship": {
            "type": "string"
          },
          "inventoryScope": {
            "type": "string"
          },
          "artistsUrl": {
            "type": "string"
          },
          "website": {
            "type": "string",
            "format": "uri"
          },
          "sourceUrl": {
            "type": "string",
            "format": "uri"
          },
          "checkedAt": {
            "type": "string",
            "format": "date"
          },
          "catalogConnected": {
            "type": "boolean"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    }
  }
}
