{
  "swagger": "2.0",
  "info": {
    "version": "1.0.0",
    "title": "Black History API",
    "description": "Welcome to the black history api! To get started go to click the Sign Up link in the navigation bar and get an api key."
  },
  "host": "rest.blackhistoryapi.io",
  "basePath": "/v2",
  "schemes": ["https", "http"],
  "securityDefinitions": {
    "ApiKeyAuth": {
      "type": "apiKey",
      "name": "x-api-key",
      "in": "header"
    }
  },
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "paths": {
    "/hc": {
      "get": {
        "tags": ["general"],
        "summary": "Health Check",
        "description": "Check the health of the API.",
        "responses": {
          "200": {
            "description": "API is healthy."
          }
        }
      }
    },
    "/metadata/all": {
      "get": {
        "tags": ["metadata"],
        "summary": "Get All Metadata",
        "description": "Retrieve all metadata from the system. Optionally filter by type using query parameters.",
        "parameters": [
          {
            "name": "tag",
            "in": "query",
            "description": "Filter to retrieve only tag metadata.",
            "required": false,
            "type": "string"
          },
          {
            "name": "people",
            "in": "query",
            "description": "Filter to retrieve only people metadata.",
            "required": false,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Metadata retrieved successfully."
          },
          "404": {
            "description": "No metadata found for the given criteria."
          }
        }
      }
    },
    "/metadata/search": {
      "get": {
        "tags": ["metadata"],
        "summary": "Search Metadata by Type",
        "description": "Search metadata by type and value (e.g., people or tags).",
        "parameters": [
          {
            "name": "people",
            "in": "query",
            "description": "Search for people metadata by name (case-insensitive regex match).",
            "required": false,
            "type": "string"
          },
          {
            "name": "tag",
            "in": "query",
            "description": "Search for tag metadata by exact tag value.",
            "required": false,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Metadata retrieved successfully."
          },
          "404": {
            "description": "No metadata found for the given criteria."
          }
        }
      }
    },
    "/fact": {
      "post": {
        "tags": ["facts"],
        "summary": "Create a New Fact",
        "description": "Submit a new fact to the system.",
        "consumes": ["application/json"],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "description": "Fact object to be created.",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "facts": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "date_of_event": { "type": "string", "format": "date" },
                      "text": { "type": "string" },
                      "source_references": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "source_type": { "type": "string" },
                            "source_url": { "type": "string" },
                            "accessed_on": {
                              "type": "string",
                              "format": "date"
                            }
                          }
                        }
                      },
                      "related_people": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "_id": { "type": "string" },
                            "type": { "type": "string" },
                            "value": { "type": "string" },
                            "created_date": {
                              "type": "string",
                              "format": "date"
                            },
                            "updated_date": {
                              "type": "string",
                              "format": "date"
                            }
                          }
                        }
                      },
                      "location": { "type": "string" },
                      "tags": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "_id": { "type": "string" },
                            "type": { "type": "string" },
                            "value": { "type": "string" },
                            "created_date": {
                              "type": "string",
                              "format": "date"
                            },
                            "updated_date": {
                              "type": "string",
                              "format": "date"
                            }
                          }
                        }
                      },
                      "created_date": { "type": "string", "format": "date" },
                      "updated_date": { "type": "string", "format": "date" },
                      "length": { "type": "integer" },
                      "status": { "type": "string" }
                    }
                  }
                }
              }
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Fact created successfully."
          }
        }
      }
    },
    "/fact/search": {
      "get": {
        "tags": ["facts"],
        "summary": "Search Facts",
        "description": "Search approved facts based on tags and/or people. Returns up to 20 results.",
        "parameters": [
          {
            "name": "tags",
            "in": "query",
            "description": "Filter facts by tags (case-insensitive regex match).",
            "required": false,
            "type": "string"
          },
          {
            "name": "people",
            "in": "query",
            "description": "Filter facts by people (case-insensitive regex match).",
            "required": false,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Facts retrieved successfully."
          },
          "404": {
            "description": "No facts found for the given criteria."
          }
        }
      }
    },
    "/fact/random": {
      "get": {
        "tags": ["facts"],
        "summary": "Get a Random Fact",
        "description": "Retrieve a random approved fact from the system.",
        "responses": {
          "200": {
            "description": "Random fact retrieved successfully."
          },
          "404": {
            "description": "No facts found."
          }
        }
      }
    }
  }
}
