144 lines
4.6 KiB
JSON
144 lines
4.6 KiB
JSON
{
|
|
"openapi": "3.1.0",
|
|
"info": {
|
|
"title": "Sophie's convert API",
|
|
"version": "1.0.0",
|
|
"description": "API for use in Computercraft to download, convert and render media. Supports emojis, image rendering, and youtube audio."
|
|
},
|
|
"servers": [
|
|
{
|
|
"url": "http://127.0.0.1:7427"
|
|
}
|
|
],
|
|
"paths": {
|
|
"/youtube": {
|
|
"post": {
|
|
"summary": "Download and convert YouTube audio",
|
|
"description": "Downloads a YouTube video matching the given `title` and `artist` and converts it to either DFPWM or MDFPWM format.",
|
|
"security": [
|
|
{ "bearerAuth": [] }
|
|
],
|
|
"requestBody": {
|
|
"required": true,
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"required": ["title", "artist"],
|
|
"properties": {
|
|
"title": {
|
|
"type": "string",
|
|
"description": "Song title",
|
|
"example": "Never Gonna Give You Up"
|
|
},
|
|
"artist": {
|
|
"type": "string",
|
|
"description": "Artist name",
|
|
"example": "Rick Astley"
|
|
},
|
|
"mdfpwm": {
|
|
"type": "boolean",
|
|
"description": "If true, produces MDFPWM instead of DFPWM",
|
|
"example": true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"responses": {
|
|
"200": {
|
|
"description": "Audio file generated successfully",
|
|
"content": {
|
|
"audio/vnd.dfpwm": {
|
|
"schema": {
|
|
"type": "string",
|
|
"format": "binary"
|
|
}
|
|
},
|
|
"audio/vnd.mdfpwm": {
|
|
"schema": {
|
|
"type": "string",
|
|
"format": "binary"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"400": { "description": "Missing or invalid parameters" },
|
|
"401": { "description": "Unauthorized" },
|
|
"500": { "description": "Internal server error" }
|
|
}
|
|
}
|
|
},
|
|
"/render": {
|
|
"post": {
|
|
"summary": "Render an emoji or image to bimg format",
|
|
"description": "Renders an emoji (via JoyPixels) or arbitrary image to `.bimg` format using the `sanjuuni` tool. Optionally resizes the image before conversion. You cannot use both emojis and image URLs at the same time.",
|
|
"security": [
|
|
{ "bearerAuth": [] }
|
|
],
|
|
"requestBody": {
|
|
"required": true,
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"size": {
|
|
"type": "string",
|
|
"pattern": "^\\d{1,4}x\\d{1,4}$",
|
|
"description": "Desired image size in format `<width>x<height>` (max 1000x1000)",
|
|
"example": "64x64"
|
|
},
|
|
"extraArgs": {
|
|
"type": "string",
|
|
"description": "Extra command-line arguments to pass to sanjuuni",
|
|
"example": "-b -W 128 -H 128"
|
|
},
|
|
"emoji": {
|
|
"type": "string",
|
|
"description": "Unicode emoji to render",
|
|
"example": "🔥"
|
|
},
|
|
"imageUrl": {
|
|
"type": "string",
|
|
"format": "uri",
|
|
"description": "URL of an image to render",
|
|
"example": "https://example.com/image.png"
|
|
}
|
|
},
|
|
"oneOf": [
|
|
{ "required": ["emoji"] },
|
|
{ "required": ["imageUrl"] }
|
|
]
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"responses": {
|
|
"200": {
|
|
"description": "Rendered `.bimg` output",
|
|
"content": {
|
|
"text/plain": {
|
|
"schema": { "type": "string" }
|
|
}
|
|
}
|
|
},
|
|
"400": { "description": "Missing parameters or invalid size format" },
|
|
"401": { "description": "Unauthorized" },
|
|
"500": { "description": "Internal server error" }
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"components": {
|
|
"securitySchemes": {
|
|
"bearerAuth": {
|
|
"type": "http",
|
|
"scheme": "bearer",
|
|
"bearerFormat": "token",
|
|
"description": "Use the `Authorization` header with your API password:\n```\nAuthorization: <PASSWORD>\n```"
|
|
}
|
|
}
|
|
}
|
|
}
|