{
  "openapi": "3.1.0",
  "info": {
    "title": "Expo Calendar API",
    "version": "1.0.0",
    "description": "Trade show editions from Expo Calendar's successful local imports of The Trade Show Calendar. Worldwide covers the imported directory listings."
  },
  "paths": {
    "/api/events": {
      "get": {
        "summary": "List trade show editions",
        "operationId": "listEvents",
        "description": "All supplied filters apply together. Date windows are inclusive and match any overlap with an event's known local dates.",
        "parameters": [
          {
            "name": "scope",
            "in": "query",
            "description": "Las Vegas only, or all events from the imported source listings.",
            "schema": {
              "type": "string",
              "enum": [
                "las-vegas",
                "worldwide"
              ],
              "default": "las-vegas"
            }
          },
          {
            "name": "q",
            "in": "query",
          "description": "Case-insensitive search of event name, venue, location and industries. Every search term must match.",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "date_from",
            "in": "query",
            "description": "First local calendar day to include.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "description": "Last local calendar day to include.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "city",
            "in": "query",
          "description": "Exact city filter, ignoring case.",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "region",
            "in": "query",
          "description": "Exact state, province or equivalent filter, ignoring case and recognizing Nevada and NV.",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "country",
            "in": "query",
          "description": "Exact country filter, ignoring case and recognizing common names for the United States.",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "industry",
            "in": "query",
          "description": "Exact source industry label, ignoring case.",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "One-based page number. Pages past the last result return an empty list.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000000,
              "default": 1
            }
          },
          {
            "name": "page_size",
            "in": "query",
            "description": "Maximum number of events per page.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 30
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of matching events and local source coverage.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventList"
                }
              }
            }
          },
          "400": {
            "description": "A supplied filter or pagination argument is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueryError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Event": {
        "title": "Expo Calendar event",
        "description": "One trade show edition as verified in the source catalog.",
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "start_date",
          "end_date",
          "date_status",
          "date_raw",
          "city",
          "region",
          "country",
          "venue",
          "industries",
          "website_url",
          "sources",
          "first_seen_at",
          "last_verified_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^evt_[0-9a-f]{32}$"
          },
          "name": {
            "type": "string",
            "minLength": 1
          },
          "start_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "First local calendar day."
          },
          "end_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "Last local calendar day, inclusive."
          },
          "date_status": {
            "enum": [
              "scheduled",
              "tentative",
              "unknown"
            ]
          },
          "date_raw": {
            "type": [
              "string",
              "null"
            ],
            "description": "Original date text from the source."
          },
          "city": {
            "type": [
              "string",
              "null"
            ],
            "minLength": 1
          },
          "region": {
            "type": [
              "string",
              "null"
            ],
            "minLength": 1,
            "description": "State, province or equivalent as available."
          },
          "country": {
            "type": [
              "string",
              "null"
            ],
            "minLength": 1
          },
          "venue": {
            "type": [
              "string",
              "null"
            ],
            "minLength": 1
          },
          "industries": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true
          },
          "website_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "pattern": "^https?://",
            "description": "Official event or organizer website when identified."
          },
          "sources": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "provider",
                "scope",
                "list_url",
                "record_url",
                "source_id"
              ],
              "properties": {
                "provider": {
                  "type": "string",
                  "minLength": 1
                },
                "scope": {
                  "enum": [
                    "nevada",
                    "worldwide"
                  ]
                },
                "list_url": {
                  "type": "string",
                  "format": "uri",
                  "pattern": "^https?://"
                },
                "record_url": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "uri",
                  "pattern": "^https?://"
                },
                "source_id": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "minLength": 1,
                  "description": "Verified source identifier for this edition, when available."
                }
              }
            }
          },
          "first_seen_at": {
            "type": "string",
            "format": "date-time"
          },
          "last_verified_at": {
            "type": "string",
            "format": "date-time"
          },
          "attendees": {
            "type": "integer",
            "minimum": 0,
            "description": "Source-reported audience size when present."
          },
          "exhibitors": {
            "type": "integer",
            "minimum": 0,
            "description": "Source-reported exhibitor count when present."
          }
        },
        "if": {
          "properties": {
            "date_status": {
              "const": "scheduled"
            }
          }
        },
        "then": {
          "properties": {
            "start_date": {
              "type": "string"
            }
          }
        }
      },
      "EventList": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "scope",
          "events",
          "page",
          "page_size",
          "total",
          "total_pages",
          "updated_at",
          "source",
          "coverage"
        ],
        "properties": {
          "scope": {
            "type": "string",
            "enum": [
              "las-vegas",
              "worldwide"
            ]
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Event"
            }
          },
          "page": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000000
          },
          "page_size": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          },
          "total": {
            "type": "integer",
            "minimum": 0,
            "description": "Number of events matching the filters across all pages."
          },
          "total_pages": {
            "type": "integer",
            "minimum": 0
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Time of the latest successful source import, when available."
          },
          "source": {
            "$ref": "#/components/schemas/Source"
          },
          "coverage": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Coverage"
            }
          }
        }
      },
      "Source": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "url"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1
          },
          "url": {
            "type": "string",
            "format": "uri",
            "pattern": "^https?://"
          }
        }
      },
      "Coverage": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "scope",
          "url",
          "last_attempt_at",
          "last_success_at",
          "last_attempt_status",
          "failure_count",
          "pages",
          "records"
        ],
        "properties": {
          "scope": {
            "type": "string",
            "enum": [
              "nevada",
              "worldwide"
            ]
          },
          "url": {
            "type": "string",
            "format": "uri",
            "pattern": "^https?://"
          },
          "last_attempt_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "last_success_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "last_attempt_status": {
            "enum": [
              "success",
              "failed",
              null
            ]
          },
          "failure_count": {
            "type": "integer",
            "minimum": 0
          },
          "pages": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "Pages scanned in the most recent successful import for this scope."
          },
          "records": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "Rows observed in the most recent successful import for this scope."
          }
        }
      },
      "QueryError": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "error",
          "message"
        ],
        "properties": {
          "error": {
            "const": "invalid_query"
          },
          "message": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    }
  }
}
