{
  "openapi": "3.1.0",
  "info": {
    "title": "ProgramWatch API",
    "version": "1.0.0",
    "description": "Free public JSON API for Solana mainnet programs. No auth.\n\nVersioning: /api/* is stable v1. Breaking changes will be announced at https://programwatch.dev/developers#versioning with Deprecation and Sunset headers for at least 90 days.\n\nErrors: application/problem+json (RFC 9457).\n\nDocs: https://programwatch.dev/developers · https://programwatch.dev/llms.txt",
    "contact": {
      "name": "ProgramWatch",
      "url": "https://programwatch.dev/developers",
      "email": "gm@metasal.xyz"
    }
  },
  "servers": [{ "url": "https://programwatch.dev" }],
  "paths": {
    "/api": {
      "get": {
        "operationId": "getApiIndex",
        "summary": "API discovery index",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ApiIndex" }
              }
            }
          }
        }
      }
    },
    "/api/stats": {
      "get": {
        "operationId": "getStats",
        "summary": "Aggregate counts",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/StatsResponse" }
              }
            }
          },
          "500": { "$ref": "#/components/responses/Problem" }
        }
      }
    },
    "/api/program/{address}": {
      "get": {
        "operationId": "getProgram",
        "summary": "Single program",
        "parameters": [
          {
            "name": "address",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ProgramResponse" }
              }
            }
          },
          "400": { "$ref": "#/components/responses/Problem" },
          "404": { "$ref": "#/components/responses/Problem" },
          "500": { "$ref": "#/components/responses/Problem" }
        }
      }
    },
    "/api/database": {
      "get": {
        "operationId": "listPrograms",
        "summary": "Paginated program list",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/DatabaseResponse" }
              }
            }
          },
          "500": { "$ref": "#/components/responses/Problem" }
        }
      }
    },
    "/api/top-programs": {
      "get": {
        "operationId": "getTopPrograms",
        "summary": "Top 100 by 24h invocations",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/TopProgramsResponse" }
              }
            }
          },
          "500": { "$ref": "#/components/responses/Problem" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "required": ["type", "title", "status", "detail", "code", "success", "error"],
        "properties": {
          "type": { "type": "string" },
          "title": { "type": "string" },
          "status": { "type": "integer" },
          "detail": { "type": "string" },
          "code": { "type": "string" },
          "instance": { "type": "string" },
          "resolution": { "type": "string" },
          "success": { "type": "boolean", "enum": [false] },
          "error": { "type": "string" }
        }
      },
      "ApiIndex": { "type": "object", "additionalProperties": true },
      "StatsResponse": {
        "type": "object",
        "properties": {
          "success": { "type": "boolean" },
          "stats": { "type": "object", "additionalProperties": true }
        }
      },
      "ProgramResponse": {
        "type": "object",
        "properties": {
          "success": { "type": "boolean" },
          "data": { "type": "object", "additionalProperties": true }
        }
      },
      "DatabaseResponse": {
        "type": "object",
        "properties": {
          "success": { "type": "boolean" },
          "data": { "type": "array", "items": { "type": "object" } },
          "pagination": { "type": "object" }
        }
      },
      "TopProgramsResponse": {
        "type": "object",
        "properties": {
          "success": { "type": "boolean" },
          "programs": { "type": "array", "items": { "type": "object" } },
          "count": { "type": "integer" }
        }
      }
    },
    "responses": {
      "Problem": {
        "description": "Error",
        "content": {
          "application/problem+json": {
            "schema": { "$ref": "#/components/schemas/Problem" }
          }
        }
      }
    }
  }
}
