{"openapi":"3.1.0","info":{"title":"base64hub API","version":"1.0.0","summary":"Encode, decode and validate Base64 over HTTP.","description":"A free, stateless Base64 API. Encode text or raw bytes (standard or URL-safe alphabet, optional padding and line wrapping), decode Base64 leniently (whitespace, data URIs, either alphabet, missing padding) and validate it. No authentication. Request bodies are limited to 1 MB, and each IP may send 20 requests per 10 seconds. Nothing is logged or stored.","contact":{"name":"base64hub","url":"https://base64hub.com/contact/","email":"g@base64hub.com"},"license":{"name":"MIT","identifier":"MIT"}},"externalDocs":{"description":"API documentation","url":"https://base64hub.com/docs/api/"},"servers":[{"url":"https://api.base64hub.com/v1"}],"tags":[{"name":"base64"},{"name":"meta"}],"paths":{"/encode":{"post":{"tags":["base64"],"operationId":"encode","summary":"Encode text or bytes to Base64","description":"Send JSON with UTF-8 text in `input`, or raw bytes as `application/octet-stream` with options in the query string.","parameters":[{"name":"variant","in":"query","description":"Only with an application/octet-stream body.","schema":{"$ref":"#/components/schemas/Variant"}},{"name":"padding","in":"query","description":"Only with an application/octet-stream body.","schema":{"type":"string","enum":["true","false"],"default":"true"}},{"name":"wrap","in":"query","description":"Only with an application/octet-stream body.","schema":{"type":"integer","minimum":0,"maximum":1000,"default":0}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EncodeRequest"},"example":{"input":"Hello, hub!","variant":"standard","padding":true,"wrap":0}},"application/octet-stream":{"schema":{"type":"string","contentMediaType":"application/octet-stream"}}}},"responses":{"200":{"description":"Encoded output.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EncodeResponse"},"example":{"output":"SGVsbG8sIGh1YiE=","variant":"standard","padding":true,"bytes_in":11,"bytes_out":16}}}},"400":{"$ref":"#/components/responses/InvalidBody"},"413":{"$ref":"#/components/responses/TooLarge"},"415":{"$ref":"#/components/responses/UnsupportedMediaType"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/decode":{"post":{"tags":["base64"],"operationId":"decode","summary":"Decode Base64","description":"Lenient: surrounding whitespace, line breaks, a `data:...;base64,` prefix, missing padding and either alphabet are accepted. Returns UTF-8 text, or hex when the bytes are not UTF-8. With `Accept: application/octet-stream` the raw bytes are returned instead.","requestBody":{"$ref":"#/components/requestBodies/Base64Input"},"responses":{"200":{"description":"Decoded output.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DecodeResponse"},"examples":{"text":{"value":{"output":"Hello, hub!","utf8":true,"bytes_out":11}},"binary":{"value":{"output":null,"utf8":false,"hex":"fbffbf","bytes_out":3}}}},"application/octet-stream":{"schema":{"type":"string","contentMediaType":"application/octet-stream"}}}},"400":{"description":"`invalid_base64` when the input is not Base64, `invalid_body` when the body is malformed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"invalid_base64","message":"invalid character '!' at position 4"}}}}},"413":{"$ref":"#/components/responses/TooLarge"},"415":{"$ref":"#/components/responses/UnsupportedMediaType"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/validate":{"post":{"tags":["base64"],"operationId":"validate","summary":"Check whether input is valid Base64","description":"Valid exactly when decode succeeds. Invalid input still returns status 200.","requestBody":{"$ref":"#/components/requestBodies/Base64Input"},"responses":{"200":{"description":"Validation result.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidateResponse"},"examples":{"valid":{"value":{"valid":true,"variant":"either","padded":true,"bytes":11}},"invalid":{"value":{"valid":false,"error":{"code":"invalid_base64","message":"invalid character '!' at position 4"}}}}}}},"400":{"$ref":"#/components/responses/InvalidBody"},"413":{"$ref":"#/components/responses/TooLarge"},"415":{"$ref":"#/components/responses/UnsupportedMediaType"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/health":{"get":{"tags":["meta"],"operationId":"health","summary":"Health check","responses":{"200":{"description":"The service is up.","content":{"application/json":{"schema":{"type":"object","required":["status","version"],"properties":{"status":{"const":"ok"},"version":{"type":"string"}}},"example":{"status":"ok","version":"1.0.0"}}}}}}},"/openapi.json":{"get":{"tags":["meta"],"operationId":"openapi","summary":"This OpenAPI description","responses":{"200":{"description":"OpenAPI 3.1 document.","content":{"application/json":{"schema":{"type":"object"}}}}}}}},"components":{"schemas":{"Variant":{"type":"string","enum":["standard","url"],"default":"standard"},"EncodeRequest":{"type":"object","required":["input"],"additionalProperties":false,"properties":{"input":{"type":"string","description":"Text to encode; its UTF-8 bytes are encoded."},"variant":{"$ref":"#/components/schemas/Variant"},"padding":{"type":"boolean","default":true,"description":"Keep trailing \"=\" padding."},"wrap":{"type":"integer","minimum":0,"maximum":1000,"default":0,"description":"Insert a line break after every N output characters (76 for MIME); 0 disables."}}},"EncodeResponse":{"type":"object","required":["output","variant","padding","bytes_in","bytes_out"],"properties":{"output":{"type":"string"},"variant":{"$ref":"#/components/schemas/Variant"},"padding":{"type":"boolean"},"bytes_in":{"type":"integer","minimum":0},"bytes_out":{"type":"integer","minimum":0}}},"DecodeRequest":{"type":"object","required":["input"],"additionalProperties":false,"properties":{"input":{"type":"string","description":"Base64 text, standard or URL-safe."}}},"DecodeResponse":{"type":"object","required":["output","utf8","bytes_out"],"properties":{"output":{"type":["string","null"],"description":"Decoded UTF-8 text, or null when the bytes are not UTF-8."},"utf8":{"type":"boolean"},"hex":{"type":"string","description":"Present only when utf8 is false."},"bytes_out":{"type":"integer","minimum":0}}},"ValidateResponse":{"oneOf":[{"type":"object","required":["valid","variant","padded","bytes"],"properties":{"valid":{"const":true},"variant":{"type":"string","enum":["standard","url","mixed","either"]},"padded":{"type":"boolean"},"bytes":{"type":"integer","minimum":0}}},{"type":"object","required":["valid","error"],"properties":{"valid":{"const":false},"error":{"$ref":"#/components/schemas/ErrorDetail"}}}]},"ErrorDetail":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","enum":["invalid_body","invalid_base64","not_found","method_not_allowed","too_large","unsupported_media_type","rate_limited"]},"message":{"type":"string"}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"$ref":"#/components/schemas/ErrorDetail"}}}},"requestBodies":{"Base64Input":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DecodeRequest"},"example":{"input":"SGVsbG8sIGh1YiE="}},"text/plain":{"schema":{"type":"string"},"example":"SGVsbG8sIGh1YiE="}}}},"responses":{"InvalidBody":{"description":"Malformed body or invalid option (`invalid_body`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"TooLarge":{"description":"Request body over 1 MB (`too_large`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"UnsupportedMediaType":{"description":"Content-Type not accepted by this endpoint (`unsupported_media_type`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"RateLimited":{"description":"More than 20 requests in 10 seconds from one IP (`rate_limited`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}