{
  "openapi": "3.1.0",
  "info": {
    "title": "BotPages API",
    "version": "1.0.0",
    "description": "A free directory of software. Submit a product with one POST, verify its badge, read the index. No authentication.",
    "contact": {
      "email": "hello@botpages.net"
    },
    "license": {
      "name": "CC BY 4.0",
      "url": "https://creativecommons.org/licenses/by/4.0/"
    }
  },
  "servers": [
    {
      "url": "https://botpages.net"
    }
  ],
  "paths": {
    "/api/submit": {
      "post": {
        "operationId": "submitListing",
        "summary": "Add a product to the directory",
        "description": "Fetches the target page, builds the card from its Open Graph tags and publishes it immediately.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url",
                  "email"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "category": {
                    "type": "string",
                    "description": "Optional slug from /api/categories."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Listing created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "id": {
                      "type": "integer"
                    },
                    "listing_url": {
                      "type": "string"
                    },
                    "manage_url": {
                      "type": "string"
                    },
                    "badge_html": {
                      "type": "string"
                    },
                    "dofollow": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "This root domain already has a listing"
          },
          "422": {
            "description": "The page could not be read or has no title"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/api/verify-badge": {
      "post": {
        "operationId": "verifyBadge",
        "summary": "Re-check a listed page for a link back",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Check result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "has_badge": {
                      "type": "boolean"
                    },
                    "dofollow": {
                      "type": "boolean"
                    },
                    "listing_id": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No active listing for that URL"
          }
        }
      }
    },
    "/api/listings": {
      "get": {
        "operationId": "listListings",
        "summary": "Active listings, newest first",
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of listings",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total": {
                      "type": "integer"
                    },
                    "listings": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "title": {
                            "type": "string"
                          },
                          "url": {
                            "type": "string"
                          },
                          "host": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "category": {
                            "type": "string"
                          },
                          "dofollow": {
                            "type": "boolean"
                          },
                          "created_at": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/listing/{id}": {
      "get": {
        "operationId": "getListing",
        "summary": "One listing",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The listing"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/api/categories": {
      "get": {
        "operationId": "listCategories",
        "summary": "Categories with counts",
        "responses": {
          "200": {
            "description": "Category list"
          }
        }
      }
    },
    "/api/stats": {
      "get": {
        "operationId": "getStats",
        "summary": "Directory totals",
        "responses": {
          "200": {
            "description": "Counts"
          }
        }
      }
    },
    "/api/search": {
      "get": {
        "operationId": "searchListings",
        "summary": "Search listings",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matches"
          }
        }
      }
    }
  }
}