Files
BitGet_API/Bitget_Server/wwwroot/index.html

410 lines
13 KiB
HTML

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Bitget Server — API Console</title>
<style>
:root {
--bg: #0e1116;
--panel: #161b22;
--border: #30363d;
--text: #c9d1d9;
--muted: #8b949e;
--accent: #2f81f7;
--accent-2: #58a6ff;
--green: #238636;
--red: #da3633;
--mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
body {
margin: 0;
font-family: -apple-system, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
background: var(--bg);
color: var(--text);
}
header {
padding: 18px 28px;
border-bottom: 1px solid var(--border);
display: flex;
align-items: center;
gap: 14px;
}
header h1 {
margin: 0;
font-size: 18px;
font-weight: 600;
letter-spacing: 0.3px;
}
header .badge {
padding: 3px 8px;
border: 1px solid var(--border);
border-radius: 4px;
font-size: 11px;
color: var(--muted);
}
header a {
margin-left: auto;
color: var(--accent-2);
text-decoration: none;
font-size: 13px;
}
main {
max-width: 1280px;
margin: 0 auto;
padding: 24px 28px 48px;
display: grid;
grid-template-columns: 320px 1fr;
gap: 20px;
}
.card {
background: var(--panel);
border: 1px solid var(--border);
border-radius: 8px;
overflow: hidden;
}
.card h2 {
margin: 0;
padding: 12px 16px;
font-size: 13px;
font-weight: 600;
color: var(--muted);
border-bottom: 1px solid var(--border);
background: #0d1117;
}
.endpoints {
max-height: calc(100vh - 140px);
overflow-y: auto;
}
.endpoint {
display: grid;
grid-template-columns: 62px 1fr;
gap: 8px;
padding: 8px 16px;
border-bottom: 1px solid #1f242b;
cursor: pointer;
align-items: center;
}
.endpoint:hover { background: #1b2029; }
.endpoint.active { background: #1e2a3a; }
.method {
font-family: var(--mono);
font-size: 11px;
font-weight: 700;
padding: 2px 6px;
border-radius: 4px;
text-align: center;
}
.method.GET { color: #3fb950; border: 1px solid #1f6d30; }
.method.POST { color: #58a6ff; border: 1px solid #1f4da1; }
.method.PUT { color: #d29922; border: 1px solid #6b4b18; }
.method.DELETE { color: #f85149; border: 1px solid #82261f; }
.path {
font-family: var(--mono);
font-size: 12px;
color: var(--text);
word-break: break-all;
}
.desc {
font-size: 11px;
color: var(--muted);
margin-top: 2px;
}
.group-title {
padding: 10px 16px 4px;
font-size: 11px;
color: var(--muted);
text-transform: uppercase;
letter-spacing: 1px;
}
.runner { display: flex; flex-direction: column; }
.runner-head {
padding: 14px 16px;
border-bottom: 1px solid var(--border);
display: flex;
gap: 8px;
align-items: center;
}
.runner-head .method-box {
font-family: var(--mono);
font-weight: 700;
padding: 6px 10px;
border-radius: 4px;
border: 1px solid var(--border);
font-size: 12px;
}
.runner-head input[type=text] {
flex: 1;
background: #0d1117;
border: 1px solid var(--border);
border-radius: 6px;
padding: 8px 10px;
color: var(--text);
font-family: var(--mono);
font-size: 13px;
}
.runner-head button {
background: var(--accent);
border: none;
color: white;
padding: 8px 18px;
border-radius: 6px;
cursor: pointer;
font-weight: 600;
font-size: 13px;
}
.runner-head button:hover { background: var(--accent-2); }
.runner-body { padding: 14px 16px; }
.runner-body label {
display: block;
font-size: 12px;
color: var(--muted);
margin-bottom: 6px;
}
.runner-body textarea {
width: 100%;
min-height: 120px;
background: #0d1117;
border: 1px solid var(--border);
border-radius: 6px;
color: var(--text);
padding: 10px;
font-family: var(--mono);
font-size: 12px;
resize: vertical;
}
.runner-body pre {
background: #0d1117;
border: 1px solid var(--border);
border-radius: 6px;
padding: 12px;
font-family: var(--mono);
font-size: 12px;
max-height: 420px;
overflow: auto;
white-space: pre-wrap;
word-break: break-word;
}
.meta {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 12px;
color: var(--muted);
margin: 10px 0 6px;
}
.status-pill {
font-family: var(--mono);
padding: 2px 8px;
border-radius: 999px;
font-weight: 600;
font-size: 11px;
}
.status-pill.ok { background: #0f2a17; color: #3fb950; }
.status-pill.err { background: #2a0f10; color: #f85149; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.quick-links {
padding: 10px 16px 16px;
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.quick-links a {
font-size: 12px;
color: var(--accent-2);
text-decoration: none;
padding: 4px 10px;
border: 1px solid var(--border);
border-radius: 999px;
}
.quick-links a:hover { background: #1b2029; }
</style>
</head>
<body>
<header>
<h1>Bitget Server — API Console</h1>
<span class="badge" id="healthBadge">health: —</span>
<a href="/chart.html">[Candle Chart →]</a>
<a href="/swagger">[Swagger →]</a>
</header>
<main>
<section class="card">
<h2>Endpoints</h2>
<div class="quick-links">
<a href="/chart.html">Candle Chart</a>
<a href="/swagger">Swagger UI</a>
</div>
<div class="endpoints" id="endpointList"></div>
</section>
<section class="card runner">
<div class="runner-head">
<span class="method-box" id="runMethod">GET</span>
<input type="text" id="runUrl" value="/api/health" />
<button id="runBtn">Send</button>
</div>
<div class="runner-body">
<label>Request Body (POST/PUT 전용 — JSON)</label>
<textarea id="runBody" placeholder='{ "example": "value" }'></textarea>
<div class="meta">
<span id="runTime">—</span>
<span class="status-pill" id="runStatus">idle</span>
</div>
<label>Response</label>
<pre id="runResp">// 엔드포인트를 선택하거나 URL 을 편집 후 Send 를 누르세요.</pre>
</div>
</section>
</main>
<script>
// 전체 엔드포인트 카탈로그 (백엔드 라우트와 수동 동기화)
const ENDPOINTS = [
{ group: "Health" },
{ method: "GET", path: "/api/health", desc: "서버 버전/타임스탬프" },
{ group: "Settings" },
{ method: "GET", path: "/api/settings/candle-interval", desc: "현재 캔들 인터벌" },
{ method: "PUT", path: "/api/settings/candle-interval", desc: "캔들 인터벌 변경", body: '{ "interval": "M1" }' },
{ method: "GET", path: "/api/settings/candle-interval/options", desc: "지원 인터벌 목록" },
{ method: "GET", path: "/api/settings/selected-coin", desc: "선택 코인" },
{ method: "PUT", path: "/api/settings/selected-coin", desc: "선택 코인 변경", body: '{ "symbol": "BTCUSDT" }' },
{ method: "GET", path: "/api/settings/leverage", desc: "레버리지" },
{ method: "PUT", path: "/api/settings/leverage", desc: "레버리지 변경", body: '{ "leverage": 5 }' },
{ method: "GET", path: "/api/settings/order-amount", desc: "주문 수량" },
{ method: "PUT", path: "/api/settings/order-amount", desc: "주문 수량 변경", body: '{ "amount": 100 }' },
{ method: "GET", path: "/api/settings/api-key", desc: "선택 API 키" },
{ method: "PUT", path: "/api/settings/api-key", desc: "API 키 변경", body: '{ "id": 0 }' },
{ group: "Market" },
{ method: "GET", path: "/api/coins", desc: "전체 선물 마켓 정보" },
{ group: "Signals" },
{ method: "GET", path: "/api/signals", desc: "현재 신호 목록 + 카운트" },
{ method: "GET", path: "/api/signals/conditions", desc: "조건식 플래그" },
{ method: "PUT", path: "/api/signals/conditions", desc: "조건식 플래그 변경", body: '{ "구름떼상향돌파": true, "구름떼하향돌파": false, "영호조건식_상향돌파": false, "영호조건식_하향돌파": false }' },
{ method: "GET", path: "/api/signals/checked-markets", desc: "체크된 마켓/인터벌" },
{ method: "PUT", path: "/api/signals/checked-markets", desc: "체크 마켓/인터벌 일괄 변경", body: '{ "markets": ["BTCUSDT","ETHUSDT"], "intervals": ["M1","M5"] }' },
{ group: "Trading" },
{ method: "GET", path: "/api/trading/timestamp", desc: "Bitget 서버 timestamp" },
{ method: "GET", path: "/api/trading/account", desc: "선물 계정" },
{ method: "GET", path: "/api/trading/orders/pending", desc: "대기 주문" },
{ method: "GET", path: "/api/trading/orders/BTCUSDT/1234567", desc: "주문 상세" },
{ method: "POST", path: "/api/trading/orders", desc: "주문 실행", body: '{ "symbol": "BTCUSDT", "marginMode": "isolated", "size": 0.01, "price": 60000, "side": "buy", "orderType": "limit", "leverage": 5, "clientOrderId": "" }' },
{ method: "DELETE", path: "/api/trading/orders", desc: "주문 취소", body: '{ "symbol": "BTCUSDT", "orderId": "1234567" }' },
{ method: "PUT", path: "/api/trading/position-mode", desc: "포지션 모드 변경", body: '{ "mode": "one_way_mode" }' },
{ group: "WebSocket" },
{ method: "GET", path: "/api/websocket/status", desc: "WS 연결 상태" },
{ method: "POST", path: "/api/websocket/start", desc: "WS 연결 시작" },
{ method: "POST", path: "/api/websocket/stop", desc: "WS 연결 종료" },
{ group: "Diagnostics (캔들/지표 점검)" },
{ method: "GET", path: "/api/diag/symbols", desc: "캐시된 심볼 + 지원 인터벌" },
{ method: "GET", path: "/api/diag/candles?symbol=BTCUSDT&interval=M1&limit=200", desc: "캔들 스냅샷 + 인디케이터" },
{ method: "GET", path: "/api/diag/price-levels?symbol=BTCUSDT&interval=M1", desc: "전고점/전저점 상태" },
{ method: "GET", path: "/api/diag/signal-markers?symbol=BTCUSDT&interval=M1", desc: "차트 마커용 신호" }
];
const list = document.getElementById("endpointList");
for (const e of ENDPOINTS) {
if (e.group) {
const h = document.createElement("div");
h.className = "group-title";
h.textContent = e.group;
list.appendChild(h);
continue;
}
const item = document.createElement("div");
item.className = "endpoint";
item.innerHTML = `
<span class="method ${e.method}">${e.method}</span>
<div>
<div class="path">${e.path}</div>
<div class="desc">${e.desc || ""}</div>
</div>`;
item.addEventListener("click", () => selectEndpoint(e, item));
list.appendChild(item);
}
const runMethod = document.getElementById("runMethod");
const runUrl = document.getElementById("runUrl");
const runBody = document.getElementById("runBody");
const runBtn = document.getElementById("runBtn");
const runResp = document.getElementById("runResp");
const runStatus = document.getElementById("runStatus");
const runTime = document.getElementById("runTime");
function selectEndpoint(e, item) {
document.querySelectorAll(".endpoint").forEach(el => el.classList.remove("active"));
item.classList.add("active");
runMethod.textContent = e.method;
runUrl.value = e.path;
runBody.value = e.body || "";
}
async function send() {
const method = runMethod.textContent;
const url = runUrl.value.trim();
const bodyRaw = runBody.value.trim();
const init = { method, headers: { "Accept": "application/json" } };
if (bodyRaw && (method === "POST" || method === "PUT" || method === "DELETE")) {
init.headers["Content-Type"] = "application/json";
init.body = bodyRaw;
}
runStatus.textContent = "sending…";
runStatus.className = "status-pill";
runResp.textContent = "";
const start = performance.now();
try {
const res = await fetch(url, init);
const ms = (performance.now() - start).toFixed(0);
runTime.textContent = `${method} ${url} — ${ms}ms`;
runStatus.textContent = `${res.status} ${res.statusText || ""}`;
runStatus.className = "status-pill " + (res.ok ? "ok" : "err");
const text = await res.text();
try {
const json = JSON.parse(text);
runResp.textContent = JSON.stringify(json, null, 2);
} catch {
runResp.textContent = text || "(empty)";
}
} catch (err) {
runStatus.textContent = "NETWORK ERR";
runStatus.className = "status-pill err";
runResp.textContent = String(err);
}
}
runBtn.addEventListener("click", send);
runUrl.addEventListener("keydown", e => { if (e.key === "Enter") send(); });
// health 자동 ping
async function pingHealth() {
const el = document.getElementById("healthBadge");
try {
const r = await fetch("/api/health");
el.textContent = "health: " + (r.ok ? "OK" : `err ${r.status}`);
el.style.color = r.ok ? "#3fb950" : "#f85149";
} catch {
el.textContent = "health: unreachable";
el.style.color = "#f85149";
}
}
pingHealth();
setInterval(pingHealth, 15000);
</script>
</body>
</html>