{
  "openapi": "3.1.0",
  "info": {
    "title": "rankboo.st Content API",
    "version": "1.0.0",
    "description": "Read-only API for published SEO articles. Use with the `rankboost` npm package on custom websites."
  },
  "servers": [
    { "url": "https://rankboo.st" }
  ],
  "security": [{ "bearerAuth": [] }],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "rbk_...",
        "description": "API key from Dashboard → API keys."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": { "type": "string" },
              "message": { "type": "string" }
            },
            "required": ["code", "message"]
          }
        }
      },
      "ContentPost": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "description": "Public post ID (UUID)" },
          "title": { "type": "string" },
          "slug": { "type": "string", "nullable": true },
          "excerpt": { "type": "string", "nullable": true },
          "html": { "type": "string" },
          "image": {
            "type": "object",
            "nullable": true,
            "properties": {
              "url": { "type": "string" },
              "alt": { "type": "string", "nullable": true }
            }
          },
          "publishedAt": { "type": "string", "format": "date-time" },
          "seo": {
            "type": "object",
            "properties": {
              "metaTitle": { "type": "string", "nullable": true },
              "metaDescription": { "type": "string", "nullable": true },
              "keyword": { "type": "string", "nullable": true }
            }
          }
        }
      },
      "ContentSite": {
        "type": "object",
        "properties": {
          "name": { "type": "string" },
          "url": { "type": "string" },
          "languageCode": { "type": "string" }
        }
      }
    }
  },
  "paths": {
    "/api/content/v1/site": {
      "get": {
        "summary": "Get website info",
        "responses": {
          "200": {
            "description": "Site metadata",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "site": { "$ref": "#/components/schemas/ContentSite" }
                  }
                }
              }
            }
          },
          "401": { "description": "Invalid credentials", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/api/content/v1/posts": {
      "get": {
        "summary": "List published posts",
        "parameters": [
          { "name": "cursor", "in": "query", "schema": { "type": "string" } },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "maximum": 50, "default": 20 } }
        ],
        "responses": {
          "200": {
            "description": "Paginated posts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "posts": { "type": "array", "items": { "$ref": "#/components/schemas/ContentPost" } },
                    "nextCursor": { "type": "string", "nullable": true }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/content/v1/posts/{slug}": {
      "get": {
        "summary": "Get a published post by slug or public ID",
        "parameters": [
          { "name": "slug", "in": "path", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": {
            "description": "Single post",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "post": { "$ref": "#/components/schemas/ContentPost" }
                  }
                }
              }
            }
          },
          "404": { "description": "Post not found" }
        }
      }
    }
  }
}
