{
  "openapi": "3.1.0",
  "info": {
    "title": "PageCritic API",
    "version": "1.0.0",
    "description": "Audit public landing pages for conversion problems and check whether AI crawlers can read them. No API key needed for the free result. Limits: 5 audits and 15 readiness checks per hour per client. The full report costs $19 USD one-time per page, unlocked by a human at the report_url. Also available as a remote MCP server (Streamable HTTP) at https://pagecritic.app/mcp.",
    "contact": {
      "email": "hello@pagecritic.app",
      "url": "https://pagecritic.app"
    },
    "termsOfService": "https://pagecritic.app/terms"
  },
  "servers": [
    {
      "url": "https://pagecritic.app"
    }
  ],
  "paths": {
    "/api/v1/audit": {
      "post": {
        "operationId": "auditLandingPage",
        "summary": "Audit a landing page (free result)",
        "description": "Loads the page in a real browser (desktop and mobile) and returns a conversion score 0-100, 7 sub-scores, the top 3 issues with fixes, what works and an AI-readiness score. Waits up to 85 seconds; if status is \"running\", poll GET /api/v1/audit/{id}. Free. The full report is $19 at report_url. With an API key that has credits, one credit is spent and full_report holds the whole report (10 full reports cost $49 via POST /api/v1/credits).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "example": "https://example.com"
                  },
                  "wait": {
                    "type": "boolean",
                    "default": true,
                    "description": "false returns at once with status running"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Audit result (done, running or error)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Audit"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        },
        "security": [
          {},
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 100
            },
            "description": "Retries with the same key return the same audit without spending another credit."
          }
        ]
      }
    },
    "/api/v1/audit/{id}": {
      "get": {
        "operationId": "getAudit",
        "summary": "Get an audit result by id",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{24}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Audit result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Audit"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/api/v1/readiness": {
      "get": {
        "operationId": "checkAiReadiness",
        "summary": "Check whether AI crawlers and agents can read a page (free)",
        "description": "Fetches the page as a browser and as GPTBot, OAI-SearchBot, ChatGPT-User, ClaudeBot, Claude-User and PerplexityBot; checks robots.txt rules, text without JavaScript, JSON-LD, sitemap, Markdown and llms.txt. Returns a 0-100 score and prioritized fixes.",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uri"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Readiness result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    },
                    "score": {
                      "type": "integer"
                    },
                    "findings": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "impact": {
                            "type": "string",
                            "enum": [
                              "high",
                              "medium",
                              "low"
                            ]
                          },
                          "title": {
                            "type": "string"
                          },
                          "fix": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "bots": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/api/v1/keys": {
      "post": {
        "operationId": "createApiKey",
        "summary": "Create a free API key (shown once)",
        "responses": {
          "200": {
            "description": "Key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "key_id": {
                      "type": "string"
                    },
                    "credits": {
                      "type": "integer"
                    },
                    "used_credits": {
                      "type": "integer"
                    },
                    "daily_credit_cap": {
                      "type": "integer"
                    },
                    "api_key": {
                      "type": "string",
                      "description": "Only on creation"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/api/v1/keys/me": {
      "get": {
        "operationId": "getApiKey",
        "summary": "Credits left on this key",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "key_id": {
                      "type": "string"
                    },
                    "credits": {
                      "type": "integer"
                    },
                    "used_credits": {
                      "type": "integer"
                    },
                    "daily_credit_cap": {
                      "type": "integer"
                    },
                    "api_key": {
                      "type": "string",
                      "description": "Only on creation"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/api/v1/credits": {
      "post": {
        "operationId": "buyCredits",
        "summary": "Stripe Checkout link: 10 full reports for $49 USD",
        "description": "Returns checkout_url. A person opens it and pays; the credits land on the key right after payment.",
        "security": [
          {
            "apiKey": []
          }
        ],
        "x-price": {
          "amount": 49,
          "currency": "USD",
          "credits": 10
        },
        "responses": {
          "200": {
            "description": "Checkout",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "checkout_url": {
                      "type": "string"
                    },
                    "credits": {
                      "type": "integer"
                    },
                    "price_usd": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "Error": {
        "description": "Error",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "schemas": {
      "Issue": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "impact": {
            "type": "string"
          },
          "fix": {
            "type": "string"
          }
        }
      },
      "Audit": {
        "type": "object",
        "properties": {
          "audit_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "done",
              "running",
              "error"
            ]
          },
          "url": {
            "type": "string"
          },
          "report_url": {
            "type": "string",
            "description": "Human-readable report; the $19 full report is unlocked here"
          },
          "score": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "verdict": {
            "type": "string"
          },
          "subscores": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            }
          },
          "top_issues": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Issue"
            }
          },
          "what_works": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "ai_readiness": {
            "type": [
              "object",
              "null"
            ]
          },
          "ai_summary": {
            "type": [
              "string",
              "null"
            ]
          },
          "full_report": {
            "type": "object",
            "properties": {
              "unlocked": {
                "type": "boolean"
              },
              "locked_issues": {
                "type": "integer"
              },
              "price_usd": {
                "type": "number",
                "example": 19
              }
            }
          },
          "error": {
            "type": "string"
          }
        }
      }
    },
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Optional. Free from POST /api/v1/keys. With credits, audits return the full report."
      }
    }
  }
}