{
  "openapi": "3.1.0",
  "info": {
    "title": "BinaryBirthday Binary API",
    "version": "1.0.0",
    "description": "Convert dates, text and numbers to binary and back. Free, no key. Each result includes links to personalized gifts with the code pre-filled."
  },
  "servers": [{ "url": "https://www.binarybirthday.com" }],
  "paths": {
    "/api/binary": {
      "get": {
        "operationId": "convertBinary",
        "summary": "Convert a date, text, binary or number. Send exactly one parameter.",
        "parameters": [
          { "name": "date", "in": "query", "schema": { "type": "string", "example": "1990-06-15" }, "description": "Date as YYYY-MM-DD. Returns 12-bit year, 4-bit month, 5-bit day." },
          { "name": "text", "in": "query", "schema": { "type": "string", "example": "Emma" }, "description": "Text to encode as 8-bit UTF-8 bytes. Up to 16 characters also returns gift links." },
          { "name": "binary", "in": "query", "schema": { "type": "string", "example": "01001000 01101001" }, "description": "Binary to decode to text and to a number." },
          { "name": "number", "in": "query", "schema": { "type": "string", "example": "2025" }, "description": "Whole number to convert to binary." }
        ],
        "responses": {
          "200": {
            "description": "Conversion result",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Result" } } }
          },
          "400": {
            "description": "Bad input",
            "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" } } } } }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Result": {
        "type": "object",
        "properties": {
          "type": { "type": "string", "enum": ["date", "text", "binary", "number"] },
          "input": { "type": "string" },
          "binary": { "type": "string" },
          "text": { "type": "string" },
          "number": { "type": "string" },
          "bits": { "type": "integer" },
          "printable": { "type": "boolean" },
          "note": { "type": "string" },
          "gifts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "product": { "type": "string" },
                "price_usd": { "type": "number" },
                "url": { "type": "string", "format": "uri" }
              }
            }
          },
          "more": { "type": "string", "format": "uri" }
        }
      }
    }
  }
}
