{
    "openapi": "3.1.0",
    "info": {
        "title": "AvatarMelayu API",
        "version": "1.0.0",
        "summary": "Free Malay & Malaysian face placeholder avatars by URL. No sign-up, no API key.",
        "description": "Paste https://avatarmelayu.com/i/150?img=3 into an <img> tag. Images are CC0 for placeholder use.",
        "license": {
            "name": "CC0-1.0",
            "url": "https://creativecommons.org/publicdomain/zero/1.0/"
        },
        "termsOfService": "https://avatarmelayu.com/terms"
    },
    "servers": [
        {
            "url": "https://avatarmelayu.com"
        }
    ],
    "paths": {
        "/i/{size}": {
            "get": {
                "operationId": "getAvatarImage",
                "summary": "Get an avatar image (random, by id, or stable per identifier).",
                "parameters": [
                    {
                        "name": "size",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "minimum": 16,
                            "maximum": 1000,
                            "default": 150
                        },
                        "description": "Square size in pixels (rounded up to a cache bucket)."
                    },
                    {
                        "name": "img",
                        "in": "query",
                        "schema": {
                            "type": "integer"
                        },
                        "description": "Public avatar number."
                    },
                    {
                        "name": "u",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "description": "Any identifier; the same value always returns the same avatar."
                    },
                    {
                        "name": "g",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "lelaki",
                                "perempuan",
                                "gabungan"
                            ]
                        }
                    },
                    {
                        "name": "cat",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "bertudung",
                                "bersongkok",
                                "profesional",
                                "pelajar",
                                "kanak-kanak",
                                "warga-emas",
                                "baju-melayu"
                            ]
                        }
                    },
                    {
                        "name": "fmt",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "jpg",
                                "webp",
                                "png"
                            ]
                        },
                        "description": "Omit to get WebP when the Accept header allows it, otherwise JPG."
                    },
                    {
                        "name": "shape",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "circle"
                            ]
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The avatar image.",
                        "content": {
                            "image/jpeg": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            },
                            "image/webp": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            },
                            "image/png": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            },
                            "image/svg+xml": {
                                "schema": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Rate limit exceeded."
                    }
                }
            }
        },
        "/i/initials/{name}": {
            "get": {
                "operationId": "getInitialsAvatar",
                "summary": "Get an SVG initials avatar for a name.",
                "parameters": [
                    {
                        "name": "name",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "size",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "default": 150
                        }
                    },
                    {
                        "name": "bg",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "pattern": "^[0-9a-fA-F]{3,6}$"
                        }
                    },
                    {
                        "name": "color",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "pattern": "^[0-9a-fA-F]{3,6}$"
                        }
                    },
                    {
                        "name": "shape",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "circle"
                            ]
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "SVG image.",
                        "content": {
                            "image/svg+xml": {
                                "schema": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/avatars": {
            "get": {
                "operationId": "listAvatars",
                "summary": "List published avatars.",
                "parameters": [
                    {
                        "name": "g",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "lelaki",
                                "perempuan",
                                "gabungan"
                            ]
                        }
                    },
                    {
                        "name": "cat",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "bertudung",
                                "bersongkok",
                                "profesional",
                                "pelajar",
                                "kanak-kanak",
                                "warga-emas",
                                "baju-melayu"
                            ]
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 30
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "A page of avatars.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Avatar"
                                            }
                                        },
                                        "meta": {
                                            "type": "object"
                                        },
                                        "links": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/avatars/{id}": {
            "get": {
                "operationId": "getAvatar",
                "summary": "Get one published avatar by its public number.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The avatar.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Avatar"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Not found or not published."
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "Avatar": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer",
                        "example": 3
                    },
                    "name": {
                        "type": "string"
                    },
                    "gender": {
                        "type": "string",
                        "enum": [
                            "lelaki",
                            "perempuan",
                            "gabungan"
                        ]
                    },
                    "age_group": {
                        "type": "string"
                    },
                    "category": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "tags": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "url": {
                        "type": "string",
                        "format": "uri"
                    },
                    "urls": {
                        "type": "object",
                        "additionalProperties": {
                            "type": "string",
                            "format": "uri"
                        }
                    },
                    "license": {
                        "type": "string",
                        "example": "CC0-1.0"
                    },
                    "ai_generated": {
                        "type": "boolean",
                        "example": true
                    },
                    "ai_tool": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "example": "Midjourney v7"
                    }
                }
            }
        }
    }
}