{
  "openapi": "3.1.0",
  "info": {
    "title": "YourImageShare API",
    "version": "1.0.0",
    "description": "Free JSON/REST API for YourImageShare - upload, list, and delete image/video files. Every request needs an API key. Official client libraries: JavaScript/TypeScript (`yourimageshare` on npm), Python (`yourimageshare` on PyPI), an MCP server (`yourimageshare-mcp` on npm) for AI coding agents, and a Discord bot.",
    "termsOfService": "https://yourimageshare.com/about/terms-and-conditions",
    "contact": {
      "url": "https://yourimageshare.com/contact"
    },
    "license": {
      "name": "MIT",
      "url": "https://github.com/MediaShareORG/yourimageshare/blob/main/LICENSE"
    }
  },
  "servers": [
    { "url": "https://yourimageshare.com/api", "description": "Production" }
  ],
  "externalDocs": {
    "description": "Full human-readable API reference",
    "url": "https://yourimageshare.com/about/api"
  },
  "security": [{ "ApiKeyHeader": [] }, { "ApiKeyQuery": [] }],
  "paths": {
    "/": {
      "post": {
        "operationId": "uploadFile",
        "summary": "Upload a file",
        "description": "Upload an image or video and get back a direct file URL, a page link, and metadata. Accepts JPG, PNG, GIF, WEBP, AVIF, BMP, TIFF, HEIC, or HEIF images, or MP4, WEBM, or AVI videos, up to 200MB.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": ["uploads"],
                "properties": {
                  "uploads": {
                    "type": "string",
                    "format": "binary",
                    "description": "The file to upload."
                  },
                  "expires_in": {
                    "type": "integer",
                    "minimum": 60,
                    "maximum": 2592000,
                    "description": "Auto-delete this upload after N seconds (60 to 2,592,000 = 30 days). Omit for a permanent upload."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Upload succeeded.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/UploadResponse" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": {
            "description": "This account or IP is currently banned from uploading.",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } }
            }
          },
          "422": {
            "description": "Validation failed - no file, unsupported format, oversized dimensions, or content previously flagged.",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } }
            }
          },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      },
      "get": {
        "operationId": "listUploads",
        "summary": "List your uploads",
        "description": "List your uploads, newest first, 50 per page.",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": { "type": "integer", "minimum": 1, "default": 1 }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ListResponse" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/{id}": {
      "delete": {
        "operationId": "deleteUpload",
        "summary": "Delete an upload",
        "description": "Permanently delete one of your uploads by id.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" },
            "description": "The upload id, from the `upload` or `list` response."
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "type": { "type": "string", "const": "success" },
                    "msg": { "type": "string", "const": "Deleted." }
                  }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "404": {
            "description": "No upload with that id belongs to this account.",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Your API key or upload-only key, from the API tab at https://yourimageshare.com/my-account. The full API key can upload, list, and delete. The upload-only key can only upload (list/delete return 401 for it) - use it anywhere the value ends up visible to others, and the full key only in trusted server-side code."
      },
      "ApiKeyQuery": {
        "type": "apiKey",
        "in": "query",
        "name": "key",
        "description": "Fallback for the X-API-Key header (same key types accepted), kept for older integrations. If both are present, the header wins."
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Missing or invalid API key.",
        "content": {
          "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } }
        }
      },
      "ServerError": {
        "description": "Server error, please try again.",
        "content": {
          "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } }
        }
      }
    },
    "schemas": {
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "type": { "type": "string", "const": "error" },
          "errors": { "type": "string" }
        }
      },
      "Upload": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "description": "Unique identifier for this upload. Pass to the delete endpoint to remove it." },
          "type": { "type": "string", "enum": ["image", "video"] },
          "path": { "type": "string", "description": "Raw storage URL - the literal file." },
          "src": { "type": "string", "description": "Direct/embeddable file URL - use for <img>/<video> src attributes." },
          "direct": { "type": "string", "description": "The shareable page URL (title, description, comments, share buttons)." },
          "expires_at": { "type": ["string", "null"], "format": "date-time" }
        },
        "required": ["id", "type", "path", "src", "direct", "expires_at"]
      },
      "ListedUpload": {
        "allOf": [
          { "$ref": "#/components/schemas/Upload" },
          {
            "type": "object",
            "properties": {
              "title": { "type": ["string", "null"] },
              "created_at": { "type": "string", "format": "date-time" }
            },
            "required": ["title", "created_at"]
          }
        ]
      },
      "UploadResponse": {
        "type": "object",
        "properties": {
          "type": { "type": "string", "const": "success" },
          "msg": { "type": "string", "const": "success" },
          "data": { "$ref": "#/components/schemas/Upload" }
        }
      },
      "ListResponse": {
        "type": "object",
        "properties": {
          "type": { "type": "string", "const": "success" },
          "data": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/ListedUpload" }
          },
          "meta": {
            "type": "object",
            "properties": {
              "current_page": { "type": "integer" },
              "last_page": { "type": "integer" },
              "total": { "type": "integer" }
            }
          }
        }
      }
    }
  }
}
