{
    "openapi": "3.0.3",
    "info": {
        "title": "RoxSim API",
        "version": "1.0.0",
        "description": "Virtual raqamlar va SMS qabul qilish API'si.\n\n**Muhim:** barcha javoblar HTTP `200` bilan qaytadi — xatolikni javobdagi `error` maydoni borligidan aniqlang.\n\nAPI kalitini olish uchun botga `/api` yuboring: [@roxsimbot](https://t.me/roxsimbot)",
        "contact": {
            "name": "Telegram",
            "url": "https://t.me/roxsimbot"
        }
    },
    "servers": [
        {
            "url": "https://sim.roxiy.uz",
            "description": "Asosiy server"
        }
    ],
    "components": {
        "parameters": {
            "ApiKey": {
                "name": "key",
                "in": "query",
                "required": true,
                "description": "Shaxsiy API kalitingiz (botdan olinadi)",
                "schema": {
                    "type": "string",
                    "example": "YOUR_API_KEY"
                }
            }
        },
        "schemas": {
            "Error": {
                "type": "object",
                "properties": {
                    "error": {
                        "type": "string",
                        "example": "API kaliti noto'g'ri!"
                    }
                }
            },
            "Balance": {
                "type": "object",
                "properties": {
                    "success": {
                        "type": "boolean",
                        "example": true
                    },
                    "result": {
                        "type": "object",
                        "properties": {
                            "balance": {
                                "type": "number",
                                "format": "float",
                                "example": 125000
                            },
                            "currency": {
                                "type": "string",
                                "example": "UZS"
                            }
                        }
                    }
                }
            },
            "Country": {
                "type": "object",
                "properties": {
                    "country_code": {
                        "type": "string",
                        "example": "uz",
                        "description": "ISO alpha-2, kichik harflarda"
                    },
                    "country_name": {
                        "type": "string",
                        "example": "🇺🇿 O'zbekiston"
                    },
                    "qty": {
                        "type": "integer",
                        "example": 1240,
                        "description": "Zaxiradagi raqamlar soni"
                    },
                    "price_uzs": {
                        "type": "integer",
                        "example": 5000,
                        "description": "Narx (so'm), chegirmangiz hisobga olingan"
                    }
                }
            },
            "Countries": {
                "type": "object",
                "properties": {
                    "countries": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Country"
                        }
                    }
                }
            },
            "Number": {
                "type": "object",
                "properties": {
                    "phone": {
                        "type": "string",
                        "example": "998901234567",
                        "description": "Xalqaro formatda, + belgisisiz"
                    },
                    "price": {
                        "type": "number",
                        "format": "float",
                        "example": 5000
                    }
                }
            },
            "Sms": {
                "type": "object",
                "properties": {
                    "status": {
                        "type": "string",
                        "example": "ok"
                    },
                    "sms": {
                        "type": "string",
                        "example": "12345",
                        "description": "SMS kod"
                    },
                    "password": {
                        "type": "string",
                        "example": "",
                        "description": "2FA parol (bo'lsa)"
                    }
                }
            }
        }
    },
    "tags": [
        {
            "name": "Hisob",
            "description": "Balans va hisob ma'lumotlari"
        },
        {
            "name": "Katalog",
            "description": "Mavjud davlatlar, zaxira va narxlar"
        },
        {
            "name": "Raqamlar",
            "description": "Raqam sotib olish va SMS kodni olish"
        }
    ],
    "paths": {
        "/api/balance": {
            "get": {
                "tags": [
                    "Hisob"
                ],
                "summary": "Balansni olish",
                "description": "Hisobingizdagi mablag'ni qaytaradi.",
                "operationId": "getBalance",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/ApiKey"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Balans",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Balance"
                                },
                                "examples": {
                                    "ok": {
                                        "summary": "Muvaffaqiyat",
                                        "value": {
                                            "success": true,
                                            "result": {
                                                "balance": 125000,
                                                "currency": "UZS"
                                            }
                                        }
                                    },
                                    "error": {
                                        "summary": "Kalit noto'g'ri",
                                        "value": {
                                            "success": false,
                                            "error": "API kaliti noto'g'ri!"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/countries": {
            "get": {
                "tags": [
                    "Katalog"
                ],
                "summary": "Davlatlar va narxlar",
                "description": "Sotuvdagi barcha davlatlar, zaxiradagi raqamlar soni va narxi.\n\nNarx **sizning chegirmangiz** hisobga olingan holda, 100 so'mgacha yaxlitlangan.",
                "operationId": "countries",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/ApiKey"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Davlatlar ro'yxati",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Countries"
                                },
                                "examples": {
                                    "ok": {
                                        "summary": "Namuna",
                                        "value": {
                                            "countries": [
                                                {
                                                    "country_code": "uz",
                                                    "country_name": "🇺🇿 O'zbekiston",
                                                    "qty": 1240,
                                                    "price_uzs": 5000
                                                },
                                                {
                                                    "country_code": "bd",
                                                    "country_name": "🇧🇩 Bangladesh",
                                                    "qty": 2869,
                                                    "price_uzs": 5000
                                                }
                                            ]
                                        }
                                    },
                                    "error": {
                                        "summary": "Xatolik",
                                        "value": {
                                            "error": "API kaliti noto'g'ri!"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/number": {
            "get": {
                "tags": [
                    "Raqamlar"
                ],
                "summary": "Raqam sotib olish",
                "description": "Tanlangan davlatdan bitta raqam beradi.\n\n⚠️ **Balansdan pul yechiladi.** Bir daqiqada faqat bitta raqam olish mumkin.\n\nKeyingi qadam — `getsms` bilan SMS kodni olish.",
                "operationId": "getnum",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/ApiKey"
                    },
                    {
                        "name": "code",
                        "in": "query",
                        "required": true,
                        "description": "Davlat kodi — `countries` dan olinadi (masalan `uz`)",
                        "schema": {
                            "type": "string",
                            "example": "uz"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Raqam yoki xatolik",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Number"
                                },
                                "examples": {
                                    "ok": {
                                        "summary": "Raqam olindi",
                                        "value": {
                                            "phone": "998901234567",
                                            "price": 5000
                                        }
                                    },
                                    "no_money": {
                                        "summary": "Mablag' yetmadi",
                                        "value": {
                                            "error": "Balansda yetarli mablag' mavjud emas!"
                                        }
                                    },
                                    "no_country": {
                                        "summary": "Davlat topilmadi",
                                        "value": {
                                            "error": "Ushbu davlat uchun ma'lumot topilmadi!"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/sms": {
            "get": {
                "tags": [
                    "Raqamlar"
                ],
                "summary": "SMS kodni olish",
                "description": "Sotib olingan raqamga kelgan SMS kodni qaytaradi.\n\nKod darrov kelmasligi mumkin — javobda `error` bo'lsa, bir necha soniyadan keyin qayta so'rang.",
                "operationId": "getsms",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/ApiKey"
                    },
                    {
                        "name": "number",
                        "in": "query",
                        "required": true,
                        "description": "`getnum` qaytargan raqam",
                        "schema": {
                            "type": "string",
                            "example": "998901234567"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Kod yoki kutish xabari",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Sms"
                                },
                                "examples": {
                                    "ok": {
                                        "summary": "Kod keldi",
                                        "value": {
                                            "status": "ok",
                                            "sms": "12345",
                                            "password": ""
                                        }
                                    },
                                    "wait": {
                                        "summary": "Hali kelmadi",
                                        "value": {
                                            "error": "SMS hali kelmadi yoki raqam topilmadi",
                                            "api_msg": "ok"
                                        }
                                    },
                                    "not_yours": {
                                        "summary": "Begona raqam",
                                        "value": {
                                            "error": "Bu raqam sizga tegishli emas!"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}