{"openapi": "3.0.3", "info": {"title": "Birgen Seller API", "version": "2", "description": "API для серверной продажи товаров. API-ключ создаётся отдельно в Telegram-боте. Суммы передаются строками.\n\nКаждый закрытый запрос подписывается X-Api-Key, X-Timestamp, X-Nonce и X-Signature. Подпись: HMAC-SHA256(secret, timestamp + '.' + nonce + '.' + METHOD + '.' + path_with_query + '.' + raw_body).\n\nСоздайте ключ в разделе «Мой API» бота. Храните секрет на сервере. Для каждой попытки используйте новый nonce; для повтора заказа сохраняйте прежние Idempotency-Key и тело запроса.\n\nСначала получите каталог и расчёт, затем передайте quote_token при создании заказа. Если цена выросла, получите новый расчёт; если снизилась, применяется новая цена. available=false означает, что товар недоступен для покупки. При тайм-ауте проверьте заказ по external_order_id.\n\nPROCESSING — ожидайте; DELIVERED — данные товара в delivery_text; REFUNDED — средства возвращены; SUPPORT_REQUIRED — обратитесь в поддержку. Денежные значения — строки. Суммы в RUB рассчитываются магазином по его курсу."}, "servers": [{"url": "https://grinberg.cc"}], "paths": {"/api/v1/health": {"get": {"summary": "Health", "responses": {"200": {"description": "OK"}}}}, "/api/v1/products": {"get": {"summary": "Товары", "parameters": [{"name": "X-Api-Key", "in": "header", "required": true, "schema": {"type": "string"}}, {"name": "X-Timestamp", "in": "header", "required": true, "schema": {"type": "string"}, "description": "Unix seconds"}, {"name": "X-Nonce", "in": "header", "required": true, "schema": {"type": "string", "pattern": "^[A-Za-z0-9_-]{16,128}$"}}, {"name": "X-Signature", "in": "header", "required": true, "schema": {"type": "string", "pattern": "^[0-9a-f]{64}$"}}, {"name": "currency", "in": "query", "required": false, "schema": {"type": "string", "enum": ["USDT", "RUB"]}}], "responses": {"200": {"description": "Catalogue"}}}}, "/api/v1/balances": {"get": {"summary": "Balances", "parameters": [{"name": "X-Api-Key", "in": "header", "required": true, "schema": {"type": "string"}}, {"name": "X-Timestamp", "in": "header", "required": true, "schema": {"type": "string"}, "description": "Unix seconds"}, {"name": "X-Nonce", "in": "header", "required": true, "schema": {"type": "string", "pattern": "^[A-Za-z0-9_-]{16,128}$"}}, {"name": "X-Signature", "in": "header", "required": true, "schema": {"type": "string", "pattern": "^[0-9a-f]{64}$"}}], "responses": {"200": {"description": "Account balances"}}}}, "/api/v1/quote": {"get": {"summary": "Расчёт без списания", "description": "Каждый закрытый запрос подписывается X-Api-Key, X-Timestamp, X-Nonce и X-Signature. Подпись: HMAC-SHA256(secret, timestamp + '.' + nonce + '.' + METHOD + '.' + path_with_query + '.' + raw_body).", "parameters": [{"name": "X-Api-Key", "in": "header", "required": true, "schema": {"type": "string"}}, {"name": "X-Timestamp", "in": "header", "required": true, "schema": {"type": "string"}, "description": "Unix seconds"}, {"name": "X-Nonce", "in": "header", "required": true, "schema": {"type": "string", "pattern": "^[A-Za-z0-9_-]{16,128}$"}}, {"name": "X-Signature", "in": "header", "required": true, "schema": {"type": "string", "pattern": "^[0-9a-f]{64}$"}}, {"name": "product_id", "in": "query", "required": true, "schema": {"type": "integer"}}, {"name": "quantity", "in": "query", "required": false, "schema": {"type": "integer", "minimum": 1, "maximum": 1000, "default": 1}}, {"name": "currency", "in": "query", "required": false, "schema": {"type": "string", "enum": ["USDT", "RUB"]}}], "responses": {"200": {"description": "Расчёт", "content": {"application/json": {"example": {"ok": true, "quote": {"product_id": 123, "quantity": 2, "currency": "USDT", "unit_price": "3.09", "total": "6.18", "available": true, "max_quantity": 5, "stock": 7, "quote_token": "example-token"}}}}}}}}, "/api/v1/orders": {"post": {"summary": "Заказ создан", "parameters": [{"name": "X-Api-Key", "in": "header", "required": true, "schema": {"type": "string"}}, {"name": "X-Timestamp", "in": "header", "required": true, "schema": {"type": "string"}, "description": "Unix seconds"}, {"name": "X-Nonce", "in": "header", "required": true, "schema": {"type": "string", "pattern": "^[A-Za-z0-9_-]{16,128}$"}}, {"name": "X-Signature", "in": "header", "required": true, "schema": {"type": "string", "pattern": "^[0-9a-f]{64}$"}}, {"name": "Idempotency-Key", "in": "header", "required": true, "schema": {"type": "string", "minLength": 16, "maxLength": 128}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "required": ["external_order_id", "product_id", "quantity", "currency", "quote_token"], "properties": {"external_order_id": {"type": "string", "example": "funpay-10069"}, "product_id": {"type": "integer", "example": 123}, "quantity": {"type": "integer", "example": 2}, "currency": {"type": "string", "example": "USDT"}, "quote_token": {"type": "string"}}}}}}, "responses": {"201": {"description": "Заказ", "content": {"application/json": {"schema": {"type": "object", "required": ["ok", "order"], "properties": {"ok": {"type": "boolean", "example": true}, "order": {"type": "object", "required": ["id", "external_order_id", "status", "amount", "currency", "product", "created_at"], "properties": {"id": {"type": "integer", "example": 10069}, "external_order_id": {"type": "string", "example": "funpay-10069"}, "status": {"type": "string", "enum": ["PROCESSING", "DELIVERED", "REFUNDED", "SUPPORT_REQUIRED"]}, "amount": {"type": "string", "example": "6.18"}, "currency": {"type": "string", "enum": ["USDT", "RUB"]}, "product": {"type": "object", "properties": {"title": {"type": "string"}, "quantity": {"type": "integer"}}}, "created_at": {"type": "string", "format": "date-time"}, "delivered_at": {"type": "string", "nullable": true, "format": "date-time"}, "delivery_text": {"type": "string", "description": "Данные товара; присутствуют только при DELIVERED"}}}, "idempotent_replay": {"type": "boolean"}}}}}}, "200": {"description": "Заказ", "content": {"application/json": {"schema": {"type": "object", "required": ["ok", "order"], "properties": {"ok": {"type": "boolean", "example": true}, "order": {"type": "object", "required": ["id", "external_order_id", "status", "amount", "currency", "product", "created_at"], "properties": {"id": {"type": "integer", "example": 10069}, "external_order_id": {"type": "string", "example": "funpay-10069"}, "status": {"type": "string", "enum": ["PROCESSING", "DELIVERED", "REFUNDED", "SUPPORT_REQUIRED"]}, "amount": {"type": "string", "example": "6.18"}, "currency": {"type": "string", "enum": ["USDT", "RUB"]}, "product": {"type": "object", "properties": {"title": {"type": "string"}, "quantity": {"type": "integer"}}}, "created_at": {"type": "string", "format": "date-time"}, "delivered_at": {"type": "string", "nullable": true, "format": "date-time"}, "delivery_text": {"type": "string", "description": "Данные товара; присутствуют только при DELIVERED"}}}, "idempotent_replay": {"type": "boolean"}}}}}}, "409": {"description": "Получите новый расчёт или проверьте существующий заказ"}}}}, "/api/v1/orders/{order_id}": {"get": {"summary": "Order", "parameters": [{"name": "X-Api-Key", "in": "header", "required": true, "schema": {"type": "string"}}, {"name": "X-Timestamp", "in": "header", "required": true, "schema": {"type": "string"}, "description": "Unix seconds"}, {"name": "X-Nonce", "in": "header", "required": true, "schema": {"type": "string", "pattern": "^[A-Za-z0-9_-]{16,128}$"}}, {"name": "X-Signature", "in": "header", "required": true, "schema": {"type": "string", "pattern": "^[0-9a-f]{64}$"}}, {"name": "order_id", "in": "path", "required": true, "schema": {"type": "integer"}}], "responses": {"200": {"description": "Заказ", "content": {"application/json": {"schema": {"type": "object", "required": ["ok", "order"], "properties": {"ok": {"type": "boolean", "example": true}, "order": {"type": "object", "required": ["id", "external_order_id", "status", "amount", "currency", "product", "created_at"], "properties": {"id": {"type": "integer", "example": 10069}, "external_order_id": {"type": "string", "example": "funpay-10069"}, "status": {"type": "string", "enum": ["PROCESSING", "DELIVERED", "REFUNDED", "SUPPORT_REQUIRED"]}, "amount": {"type": "string", "example": "6.18"}, "currency": {"type": "string", "enum": ["USDT", "RUB"]}, "product": {"type": "object", "properties": {"title": {"type": "string"}, "quantity": {"type": "integer"}}}, "created_at": {"type": "string", "format": "date-time"}, "delivered_at": {"type": "string", "nullable": true, "format": "date-time"}, "delivery_text": {"type": "string", "description": "Данные товара; присутствуют только при DELIVERED"}}}, "idempotent_replay": {"type": "boolean"}}}}}}}}}, "/api/v1/orders/by-external": {"get": {"summary": "Recover an order", "parameters": [{"name": "X-Api-Key", "in": "header", "required": true, "schema": {"type": "string"}}, {"name": "X-Timestamp", "in": "header", "required": true, "schema": {"type": "string"}, "description": "Unix seconds"}, {"name": "X-Nonce", "in": "header", "required": true, "schema": {"type": "string", "pattern": "^[A-Za-z0-9_-]{16,128}$"}}, {"name": "X-Signature", "in": "header", "required": true, "schema": {"type": "string", "pattern": "^[0-9a-f]{64}$"}}, {"name": "external_order_id", "in": "query", "required": true, "schema": {"type": "string"}}], "responses": {"200": {"description": "Заказ", "content": {"application/json": {"schema": {"type": "object", "required": ["ok", "order"], "properties": {"ok": {"type": "boolean", "example": true}, "order": {"type": "object", "required": ["id", "external_order_id", "status", "amount", "currency", "product", "created_at"], "properties": {"id": {"type": "integer", "example": 10069}, "external_order_id": {"type": "string", "example": "funpay-10069"}, "status": {"type": "string", "enum": ["PROCESSING", "DELIVERED", "REFUNDED", "SUPPORT_REQUIRED"]}, "amount": {"type": "string", "example": "6.18"}, "currency": {"type": "string", "enum": ["USDT", "RUB"]}, "product": {"type": "object", "properties": {"title": {"type": "string"}, "quantity": {"type": "integer"}}}, "created_at": {"type": "string", "format": "date-time"}, "delivered_at": {"type": "string", "nullable": true, "format": "date-time"}, "delivery_text": {"type": "string", "description": "Данные товара; присутствуют только при DELIVERED"}}}, "idempotent_replay": {"type": "boolean"}}}}}}}}}}}