752 lines
376 KiB
HTML
752 lines
376 KiB
HTML
<!DOCTYPE html>
|
|||
|
|
<html lang="en">
|
||
|
|
<head>
|
||
|
|
<meta charset="UTF-8">
|
||
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
|
|
<meta name="apidocs-schema" content="1">
|
||
|
|
<title>FastAPI Generative AI Backend API Reference</title>
|
||
|
|
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||
|
|
<link href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,[email protected],500;12..96,700;12..96,800&family=Instrument+Sans:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
|
||
|
|
<script>try{var t=localStorage.getItem('apidocs-theme')||'light';document.documentElement.setAttribute('data-theme',t)}catch(e){}</script>
|
||
|
|
<style>
|
||
|
|
:root{--h:172;--paper:#F3EDE0;--card:#FBF8F1;--soft:#ECE5D6;--ink:#232831;--ink2:#575B63;--ink3:#6E6B62;--line:#DAD1BC;--code:#20242E;--codeink:#EEE9DB;--acc:hsl(var(--h) 55% 32%);--tint:hsl(var(--h) 45% 86%);--rail:276px;--rqbg:#FADDD5;--rqfg:#8F1B10;--rqbd:#E6A394;--opbg:#DCEADF;--opfg:#1B5A3C;--opbd:#A6CBB5;
|
||
|
|
--display:'Bricolage Grotesque','Segoe UI Variable Display','Helvetica Neue',system-ui,sans-serif;--sans:'Instrument Sans','Segoe UI',system-ui,sans-serif;--mono:'JetBrains Mono',ui-monospace,'SF Mono',Consolas,monospace;color-scheme:light}
|
||
|
|
[data-theme=dark]{--paper:#171510;--card:#201D16;--soft:#1B1913;--ink:#F2ECDD;--ink2:#BEB7A6;--ink3:#8F897A;--line:#36322A;--code:#0F0E0B;--tint:hsl(var(--h) 30% 22%);--acc:hsl(var(--h) 60% 70%);--rqbg:#4A1E18;--rqfg:#FFB4A6;--rqbd:#7A3329;--opbg:#1B3A2B;--opfg:#9FDDBB;--opbd:#2F5C45;color-scheme:dark}
|
||
|
|
*{box-sizing:border-box;margin:0;padding:0}html{scroll-behavior:smooth;scroll-padding-top:84px}
|
||
|
|
body{background:var(--paper);color:var(--ink);font:16px/1.65 var(--sans);-webkit-font-smoothing:antialiased}
|
||
|
|
button{font:inherit;color:inherit;background:none;border:0;cursor:pointer}code{font-family:var(--mono)}
|
||
|
|
:focus-visible{outline:2px solid var(--acc);outline-offset:2px;border-radius:6px}
|
||
|
|
.rail{position:fixed;inset:0 auto 0 0;width:var(--rail);padding:28px 18px;display:flex;flex-direction:column;gap:6px;border-right:1px solid var(--line);background:var(--paper);overflow:auto;z-index:20}
|
||
|
|
.brand{display:flex;gap:12px;align-items:center;padding:0 10px 22px;text-decoration:none;color:inherit}
|
||
|
|
.brand svg{width:34px;height:34px;flex:none}.brand b{font:700 15px/1.2 var(--display);letter-spacing:-.01em}.brand span{display:block;font-size:12.5px;color:var(--ink3);font-weight:400}
|
||
|
|
.fam{display:flex;align-items:center;gap:12px;padding:10px 12px;border-radius:12px;text-decoration:none;color:var(--ink2);font-weight:500;font-size:15px;position:relative;transition:background .2s,color .2s}
|
||
|
|
.fam:hover{background:var(--soft);color:var(--ink)}.fam i{width:10px;height:10px;border-radius:3px;background:hsl(var(--h) 55% 46%);flex:none}.fam em{margin-left:auto;font:400 12.5px var(--mono);color:var(--ink3);font-style:normal}
|
||
|
|
.fam.on{background:var(--card);color:var(--ink);box-shadow:0 0 0 1px var(--line)}
|
||
|
|
.railfoot{margin-top:auto;padding:18px 10px 0;font-size:12.5px;color:var(--ink3);line-height:1.5}
|
||
|
|
.shell{margin-left:var(--rail)}
|
||
|
|
.top{position:sticky;top:0;z-index:15;display:flex;gap:10px;align-items:center;padding:14px 48px;background:color-mix(in srgb,var(--paper) 86%,transparent);backdrop-filter:blur(14px);border-bottom:1px solid var(--line)}
|
||
|
|
.find{flex:1;max-width:520px;display:flex;align-items:center;gap:10px;padding:10px 14px;border:1px solid var(--line);border-radius:12px;background:var(--card);color:var(--ink3);text-align:left;font-size:14.5px;transition:border-color .2s}
|
||
|
|
.find:hover{border-color:var(--ink3)}.find kbd{margin-left:auto;font:400 12px var(--mono);border:1px solid var(--line);border-radius:6px;padding:1px 7px;color:var(--ink3)}
|
||
|
|
.btn{padding:9px 14px;border-radius:11px;border:1px solid var(--line);background:var(--card);font-size:14px;font-weight:500;transition:border-color .2s,transform .1s}.btn:hover{border-color:var(--ink3)}.btn:active{transform:scale(.97)}
|
||
|
|
.sp{flex:1}
|
||
|
|
main{padding:0 48px 140px;max-width:1180px}
|
||
|
|
.hero{padding:88px 0 72px}
|
||
|
|
.hero h1{font:800 clamp(40px,6.2vw,84px)/.98 var(--display);letter-spacing:-.035em;max-width:13ch;text-wrap:balance}
|
||
|
|
.hero p.lead{font-size:19px;color:var(--ink2);max-width:56ch;margin-top:26px;line-height:1.6}
|
||
|
|
.reel{margin-top:48px;display:block;width:100%;max-width:760px;text-align:left;background:var(--code);color:var(--codeink);border-radius:18px;padding:22px 26px;box-shadow:0 30px 60px -30px rgba(60,45,20,.5)}
|
||
|
|
.reel code{display:block;font-size:clamp(13px,1.9vw,19px);min-height:1.7em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||
|
|
.reel .cur{display:inline-block;width:.55em;height:1.1em;background:hsl(var(--h) 90% 70%);vertical-align:-.18em;margin-left:2px;animation:bl 1s steps(2) infinite}
|
||
|
|
.reel small{display:block;margin-top:10px;font:400 13px var(--mono);color:hsl(var(--h) 60% 78%);opacity:.9;min-height:1.4em}
|
||
|
|
.mv{font-weight:600;color:hsl(var(--h) 90% 76%)}
|
||
|
|
@keyframes bl{50%{opacity:0}}
|
||
|
|
.facts{display:flex;flex-wrap:wrap;gap:14px 56px;margin-top:56px}.facts div{font-size:14px;color:var(--ink3)}.facts b{display:block;font:700 34px/1.1 var(--display);color:var(--ink);letter-spacing:-.02em}
|
||
|
|
.note{margin-top:40px;font-size:14.5px;color:var(--ink2);max-width:62ch;padding-left:16px;border-left:3px solid var(--line)}
|
||
|
|
.fsec{padding-top:56px;--a:hsl(var(--h) 55% 40%)}
|
||
|
|
.fhead{border-top:3px solid var(--a);padding-top:26px;margin-bottom:28px}
|
||
|
|
.fhead h2{font:800 clamp(30px,4vw,48px)/1.05 var(--display);letter-spacing:-.03em}
|
||
|
|
.fhead .tag{margin-top:10px;font-size:14px;color:var(--ink3);display:flex;gap:18px;flex-wrap:wrap}.fhead .tag code{font-size:13px}
|
||
|
|
.fhead p{margin-top:16px;color:var(--ink2);max-width:70ch;font-size:17px}
|
||
|
|
.ep{background:var(--card);border:1px solid var(--line);border-radius:16px;margin-bottom:12px;position:relative;transition:border-color .25s,box-shadow .25s;scroll-margin-top:90px}
|
||
|
|
.ep:hover{border-color:var(--ink3)}.ep.open{border-color:var(--a);box-shadow:0 18px 50px -28px rgba(70,50,20,.35)}
|
||
|
|
.eh{display:grid;grid-template-columns:auto 1fr auto;gap:18px;align-items:start;width:100%;text-align:left;padding:20px 24px}
|
||
|
|
.m{font:500 12px/1 var(--mono);padding:7px 10px;border-radius:8px;letter-spacing:.02em;margin-top:3px}
|
||
|
|
.m-POST{background:var(--ink);color:var(--paper)}.m-GET,.m-PUT,.m-PATCH,.m-DELETE{border:1.5px solid var(--ink);color:var(--ink)}
|
||
|
|
.et{font:700 20px/1.25 var(--display);letter-spacing:-.015em}
|
||
|
|
.ep-path{display:block;font-size:13.5px;color:var(--ink2);margin-top:5px;word-break:break-all}
|
||
|
|
.es{display:block;color:var(--ink2);font-size:15px;margin-top:8px;max-width:72ch}
|
||
|
|
.ek{display:flex;flex-direction:column;align-items:flex-end;gap:8px;font:400 12.5px var(--mono);color:var(--ink3);white-space:nowrap}
|
||
|
|
.chev{width:30px;height:30px;border-radius:50%;border:1px solid var(--line);display:grid;place-items:center;transition:transform .35s cubic-bezier(.3,1.4,.5,1),background .2s}
|
||
|
|
.open .chev{transform:rotate(180deg);background:var(--tint)}
|
||
|
|
.eb{display:grid;grid-template-rows:0fr;transition:grid-template-rows .4s cubic-bezier(.3,.9,.3,1)}.open .eb{grid-template-rows:1fr}
|
||
|
|
.ei{overflow:hidden;min-height:0}.ew{padding:4px 24px 28px;border-top:1px dashed var(--line);margin:0 24px;padding-left:0;padding-right:0}
|
||
|
|
.ew h4{font:700 15px var(--display);margin:30px 0 12px;display:flex;gap:12px;align-items:center}.ew h4 span{font:400 13px var(--sans);color:var(--ink3)}
|
||
|
|
.desc{margin-top:24px;max-width:72ch;color:var(--ink2)}
|
||
|
|
.subs{list-style:none;display:grid;gap:6px}.subs li{display:flex;gap:12px;flex-wrap:wrap;align-items:baseline;font-size:14.5px;color:var(--ink2)}.subs code{font-size:13px;color:var(--ink)}
|
||
|
|
.pt{width:100%;border-collapse:collapse;font-size:14.5px}
|
||
|
|
.pt th{text-align:left;font:500 13px var(--sans);color:var(--ink3);padding:0 14px 10px 0;border-bottom:1px solid var(--line)}
|
||
|
|
.pt td{padding:16px 14px 16px 0;border-bottom:1px solid var(--line);vertical-align:top;color:var(--ink2)}.pt tr:last-child td{border-bottom:0}
|
||
|
|
.pn{font-size:14px;color:var(--ink);font-weight:500}.al{display:block;font-size:12.5px;color:var(--ink3);margin-top:3px}
|
||
|
|
.ty{display:block;font:400 13px var(--mono);color:var(--ink)}.lc{display:block;font-size:12.5px;color:var(--ink3);margin-top:3px}
|
||
|
|
.rq,.op{display:inline-flex;align-items:center;gap:7px;padding:6px 13px;border-radius:99px;font:600 12.5px/1 var(--sans);letter-spacing:.01em;border:1px solid}
|
||
|
|
.rq{background:var(--rqbg);color:var(--rqfg);border-color:var(--rqbd)}.rq::before,.op::before{content:'';width:7px;height:7px;border-radius:50%;background:currentColor}
|
||
|
|
.op{background:var(--opbg);color:var(--opfg);border-color:var(--opbd);font-weight:500}.op::before{background:none;border:1.5px solid currentColor}
|
||
|
|
.pt tr.req td:first-child{box-shadow:inset 3px 0 0 var(--rqbd)}.pt td:first-child,.pt th:first-child{padding-left:14px}
|
||
|
|
.df{font:400 13px var(--mono);color:var(--ink)}
|
||
|
|
.pr-tools{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-bottom:14px}
|
||
|
|
.pr-tools input{flex:1;min-width:180px;padding:9px 13px;border:1px solid var(--line);border-radius:10px;background:var(--soft);font:inherit;font-size:14px;color:var(--ink)}
|
||
|
|
.pr-tools .btn{padding:7px 12px;font-size:13px}
|
||
|
|
.chips{display:flex;flex-wrap:wrap;gap:7px;max-height:210px;overflow:auto;padding:2px}
|
||
|
|
.chip{font:400 13px var(--mono);padding:5px 10px;border-radius:8px;background:var(--soft);border:1px solid var(--line);color:var(--ink2);transition:background .15s,border-color .15s}
|
||
|
|
.chip:hover{border-color:var(--a)}.chip.sel{background:var(--tint);border-color:var(--a);color:var(--ink)}
|
||
|
|
.resp{display:flex;align-items:center;gap:12px;font-size:14.5px;color:var(--ink2)}.resp code{font-size:13px;padding:4px 10px;border-radius:8px;background:var(--soft);border:1px solid var(--line);color:var(--ink)}
|
||
|
|
.code{background:var(--code);border-radius:14px;overflow:hidden}
|
||
|
|
.ctab{display:flex;align-items:center;gap:4px;padding:8px 10px 0 14px;border-bottom:1px solid rgba(255,255,255,.12)}
|
||
|
|
.ctab button{padding:9px 14px;font-size:13.5px;color:#8F97C4;border-bottom:2px solid transparent;margin-bottom:-1px}.ctab button.on{color:#fff;border-color:hsl(var(--h) 90% 72%)}
|
||
|
|
.ctab .cp{margin-left:auto;margin-bottom:6px;border:1px solid rgba(255,255,255,.2);border-radius:8px;padding:5px 11px;font-size:12.5px;color:#C9CFF5}.ctab .cp:hover{background:rgba(255,255,255,.08)}
|
||
|
|
.code pre{padding:20px 22px;overflow:auto;font:400 13.5px/1.75 var(--mono);color:var(--codeink);tab-size:2}
|
||
|
|
.hint{font-size:13px;color:var(--ink3);margin-top:10px}
|
||
|
|
.pal{position:fixed;inset:0;z-index:100;background:rgba(40,32,18,.45);backdrop-filter:blur(6px);display:grid;justify-items:center;align-content:start;padding-top:12vh}
|
||
|
|
.pal[hidden]{display:none}
|
||
|
|
.pbox{width:min(680px,92vw);background:var(--card);border:1px solid var(--line);border-radius:20px;box-shadow:0 40px 90px -20px #000a;overflow:hidden;animation:pin .22s cubic-bezier(.3,1.3,.5,1)}
|
||
|
|
@keyframes pin{from{transform:translateY(-10px) scale(.98);opacity:0}}
|
||
|
|
.pbox input{width:100%;padding:22px 26px;border:0;border-bottom:1px solid var(--line);background:none;font:500 18px var(--sans);color:var(--ink);outline:0}
|
||
|
|
.pl{max-height:52vh;overflow:auto;padding:8px}
|
||
|
|
.pi{display:flex;gap:14px;align-items:center;width:100%;text-align:left;padding:12px 16px;border-radius:12px}
|
||
|
|
.pi.on{background:var(--tint)}.pi b{font-weight:600;font-size:15px}.pi code{display:block;font-size:12.5px;color:var(--ink3);margin-top:2px}.pi .m{margin:0;font-size:11px;padding:5px 8px}
|
||
|
|
.pe{padding:30px;text-align:center;color:var(--ink3)}
|
||
|
|
.toast{position:fixed;left:50%;bottom:28px;translate:-50% 0;background:var(--ink);color:var(--paper);padding:11px 20px;border-radius:12px;font-weight:500;font-size:14.5px;z-index:200;animation:pin .25s}
|
||
|
|
.toast[hidden]{display:none}
|
||
|
|
@media(max-width:1000px){.rail{position:static;width:auto;flex-direction:row;overflow-x:auto;padding:12px 16px;border:0;border-bottom:1px solid var(--line);gap:4px}.brand,.railfoot{display:none}.fam{white-space:nowrap}.shell{margin:0}.top{padding:12px 16px;top:0}main{padding:0 18px 100px}.hero{padding:48px 0}.eh{grid-template-columns:1fr auto;padding:18px}.eh .m{grid-column:1/-1;justify-self:start;margin:0}.ek span{display:none}.ew{margin:0 18px}
|
||
|
|
.pt thead{display:none}.pt tr,.pt td{display:block}.pt td{padding:4px 0;border:0}.pt tr{padding:14px 0;border-bottom:1px solid var(--line)}}
|
||
|
|
@media(prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important;scroll-behavior:auto!important}}
|
||
|
|
|
||
|
|
/* ─── URL Bar & Endpoint Tabs (Clean integration) ─── */
|
||
|
|
.ep-full-url-bar {
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
gap: 12px;
|
||
|
|
background: var(--soft);
|
||
|
|
border: 1px solid var(--line);
|
||
|
|
border-radius: 12px;
|
||
|
|
padding: 10px 14px;
|
||
|
|
margin: 16px 0;
|
||
|
|
flex-wrap: wrap;
|
||
|
|
}
|
||
|
|
.ep-full-url-bar code {
|
||
|
|
font-family: var(--mono);
|
||
|
|
font-size: 13.5px;
|
||
|
|
color: var(--acc);
|
||
|
|
word-break: break-all;
|
||
|
|
flex: 1;
|
||
|
|
min-width: 0;
|
||
|
|
}
|
||
|
|
.ep-tabs-wrapper {
|
||
|
|
margin: 16px 0 14px;
|
||
|
|
padding-bottom: 12px;
|
||
|
|
border-bottom: 1px solid var(--line);
|
||
|
|
}
|
||
|
|
.ep-tabs-label {
|
||
|
|
font-size: 11.5px;
|
||
|
|
font-weight: 700;
|
||
|
|
letter-spacing: 0.05em;
|
||
|
|
text-transform: uppercase;
|
||
|
|
color: var(--ink3);
|
||
|
|
margin-bottom: 8px;
|
||
|
|
display: block;
|
||
|
|
}
|
||
|
|
.ep-tabs {
|
||
|
|
display: flex;
|
||
|
|
gap: 8px;
|
||
|
|
flex-wrap: wrap;
|
||
|
|
}
|
||
|
|
.ep-tab {
|
||
|
|
padding: 7px 12px;
|
||
|
|
border-radius: 10px;
|
||
|
|
background: var(--soft);
|
||
|
|
border: 1px solid var(--line);
|
||
|
|
font-size: 13px;
|
||
|
|
font-weight: 500;
|
||
|
|
color: var(--ink2);
|
||
|
|
cursor: pointer;
|
||
|
|
display: inline-flex;
|
||
|
|
align-items: center;
|
||
|
|
gap: 8px;
|
||
|
|
transition: all 0.15s;
|
||
|
|
}
|
||
|
|
.ep-tab:hover {
|
||
|
|
border-color: var(--acc);
|
||
|
|
color: var(--ink);
|
||
|
|
}
|
||
|
|
.ep-tab.active {
|
||
|
|
background: var(--card);
|
||
|
|
border-color: var(--acc);
|
||
|
|
color: var(--acc);
|
||
|
|
font-weight: 600;
|
||
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.06);
|
||
|
|
}
|
||
|
|
.ep-tab .m { padding: 3px 6px; font-size: 10.5px; margin: 0; }
|
||
|
|
|
||
|
|
.chip.copied {
|
||
|
|
background: var(--opbg) !important;
|
||
|
|
color: var(--opfg) !important;
|
||
|
|
border-color: var(--opbd) !important;
|
||
|
|
}
|
||
|
|
|
||
|
|
/* ─── Header Session Pill & Admin Button ─── */
|
||
|
|
.session-pill {
|
||
|
|
display: inline-flex;
|
||
|
|
align-items: center;
|
||
|
|
gap: 6px;
|
||
|
|
padding: 6px 12px;
|
||
|
|
border-radius: 10px;
|
||
|
|
background: var(--card);
|
||
|
|
border: 1px solid var(--line);
|
||
|
|
font-size: 13px;
|
||
|
|
font-family: var(--mono);
|
||
|
|
color: var(--ink2);
|
||
|
|
font-weight: 500;
|
||
|
|
}
|
||
|
|
.session-pill.warning {
|
||
|
|
background: var(--rqbg);
|
||
|
|
color: var(--rqfg);
|
||
|
|
border-color: var(--rqbd);
|
||
|
|
}
|
||
|
|
.btn-admin {
|
||
|
|
display: inline-flex;
|
||
|
|
align-items: center;
|
||
|
|
gap: 6px;
|
||
|
|
color: var(--acc);
|
||
|
|
border-color: var(--acc);
|
||
|
|
font-weight: 600;
|
||
|
|
}
|
||
|
|
.btn-admin:hover {
|
||
|
|
background: var(--tint);
|
||
|
|
}
|
||
|
|
.btn-khira {
|
||
|
|
display: inline-flex;
|
||
|
|
align-items: center;
|
||
|
|
gap: 6px;
|
||
|
|
color: #a855f7;
|
||
|
|
border-color: rgba(168, 85, 247, 0.45);
|
||
|
|
background: rgba(168, 85, 247, 0.08);
|
||
|
|
font-weight: 600;
|
||
|
|
text-decoration: none;
|
||
|
|
}
|
||
|
|
.btn-khira:hover {
|
||
|
|
background: rgba(168, 85, 247, 0.18);
|
||
|
|
border-color: #a855f7;
|
||
|
|
color: #c084fc;
|
||
|
|
}
|
||
|
|
|
||
|
|
</style>
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
<div id="app"></div>
|
||
|
|
<script id="api-data" type="application/json">{"meta": {"title": "FastAPI Generative AI Backend API Reference", "heading": "Edit faces, hair and photos over plain HTTP.", "baseUrl": "https://apigp0006.creinnovations.in", "intro": "Complete interactive documentation for all 68 production AI services with full direct URLs, categorized multi-route endpoints, and verified preset codes.", "authNote": "All inference endpoints authenticate using secretKey form-data parameter (default: 'abcdef')."}, "sections": [{"id": "sec-flux-fill", "key": "flux-fill", "icon": "\ud83c\udfa8", "title": "FLUX.1-Fill Inpainting", "tag": "Flow Matching Inpainting", "lead": "FLUX.1-Fill-dev 12B flow-matching inpainting models specialized in precision portrait manipulation, multi-preset wardrobe restyling, hair color/style changing, and double exposure with automatic Sapiens segmentation.", "port": "8003 (Backend: 8013)", "hue": 268, "eps": [{"id": "api-stable-diffusion-hair-color-changer-and-hair-style-changer", "api_key": "Stable_Diffusion_Hair_Color_Changer_And_Hair_Style_Changer", "api_ip_link": "https://apigp0006.creinnovations.in/apis/flxf/flux_fill/hair_color_changer/", "title": "Stable_Diffusion_Hair_Color_Changer_And_Hair_Style_Changer", "method": "MULTI", "path": "/flux_fill/hair_color_changer/image/", "full_url": "https://apigp0006.creinnovations.in/apis/flxf/flux_fill/hair_color_changer/hair_color_changer/", "port": "8000", "resp": "image/png", "summary": "Inpaints hair with natural dyes, fantasy colors, and dual-tone highlights.", "desc": "Uses FLUX.1-Fill-dev inpainting to re-color hair while preserving original texture, strand geometry, and lighting. If mask_image is omitted, Sapiens hair segmentation automatically extracts the hair mask.", "params": [{"n": "image0", "al": "image", "ty": "file (binary)", "lc": "multipart/form-data", "rq": true, "df": "None", "ds": "Input portrait photograph (JPEG/PNG/WEBP). Recommended max resolution 720-1024px."}, {"n": "colorId", "al": "effectId", "ty": "string", "lc": "multipart/form-data", "rq": true, "df": "None", "ds": "Hair color preset encoding ID. Must match one of the 36 verified presets."}, {"n": "secretKey", "al": "", "ty": "string", "lc": "multipart/form-data", "rq": true, "df": "abcdef", "ds": "\ud83d\udd11 Authentication: Authentication key. Must be 'abcdef'."}, {"n": "mask_image", "al": "", "ty": "file (binary)", "lc": "multipart/form-data", "rq": false, "df": "None (auto-extracted)", "ds": "Optional alpha mask for hair region. If omitted, Sapiens automatically extracts the hair region."}], "chips": ["C1", "C10", "C11", "C12", "C13", "C14", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9", "G1", "G10", "G11", "G2", "G3", "G4", "G5", "G6", "G7", "G8", "G9", "HL1", "HL10", "HL11", "HL2", "HL3", "HL4", "HL5", "HL6", "HL7", "HL8", "HL9"], "subs": [], "curl": "", "endpoints": [{"id": "ff-hair-color-changer", "method": "POST", "subpath": "hair_color_changer/", "full_url": "https://apigp0006.creinnovations.in/apis/flxf/flux_fill/hair_color_changer/hair_color_changer/", "path": "/flux_fill/hair_color_changer/image/", "title": "FLUX.1-Fill Hair Color Changer (36 Presets)", "summary": "Inpaints hair with natural dyes, fantasy colors, and dual-tone highlights.", "desc": "Uses FLUX.1-Fill-dev inpainting to re-color hair while preserving original texture, strand geometry, and lighting. If mask_image is omitted, Sapiens hair segmentation automatically extracts the hair mask.", "params": [{"n": "image0", "al": "image", "ty": "file (binary)", "lc": "multipart/form-data", "rq": true, "df": "None", "ds": "Input portrait photograph (JPEG/PNG/WEBP). Recommended max resolution 720-1024px."}, {"n": "colorId", "al": "effectId", "ty": "string", "lc": "multipart/form-data", "rq": true, "df": "None", "ds": "Hair color preset encoding ID. Must match one of the 36 verified presets."}, {"n": "secretKey", "al": "", "ty": "string", "lc": "multipart/form-data", "rq": true, "df": "abcdef", "ds": "\ud83d\udd11 Authentication: Authentication key. Must be 'abcdef'."}, {"n": "mask_image", "al": "", "ty": "file (binary)",
|
||
|
|
<script>
|
||
|
|
(()=>{
|
||
|
|
const $=(s,r=document)=>r.querySelector(s),$$=(s,r=document)=>[...r.querySelectorAll(s)];
|
||
|
|
const esc=s=>String(s??'').replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
|
||
|
|
let D=JSON.parse($('#api-data').textContent);
|
||
|
|
const open=new Set(),picked={},activeSubEp={};
|
||
|
|
let toastT;
|
||
|
|
|
||
|
|
const base=e=>{
|
||
|
|
if (e.full_url) {
|
||
|
|
try {
|
||
|
|
const u = new URL(e.full_url);
|
||
|
|
return u.origin;
|
||
|
|
} catch(err){}
|
||
|
|
}
|
||
|
|
const b=(D.meta.baseUrl||'https://apigp0006.creinnovations.in').replace(/\/$/,''),p=(String(e.port).match(/^\d+/)||[''])[0];
|
||
|
|
return p?b+':'+p:b;
|
||
|
|
};
|
||
|
|
|
||
|
|
const meaningful=v=>v&&!/^(none|null|-|—)/i.test(v.trim());
|
||
|
|
const clean=v=>v.replace(/^['"]|['"]$/g,'');
|
||
|
|
|
||
|
|
function fields(e){
|
||
|
|
let used=false;
|
||
|
|
return (e.params||[]).filter(p=>p.rq).map(p=>{
|
||
|
|
const file=/file|binary/i.test(p.ty);
|
||
|
|
let v;
|
||
|
|
if(file) v=(p.n||'file')+'.jpg';
|
||
|
|
else if(meaningful(p.df)&&!/auto/i.test(p.df)) v=clean(p.df);
|
||
|
|
else if(!used&&e.chips&&e.chips.length&&/id$/i.test(p.n)){ v=e.chips[0]; used=true; }
|
||
|
|
else v='<'+p.n+'>';
|
||
|
|
return {n:p.n, file, v, q:/query/i.test(p.lc)};
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
function snippets(e, targetUrl){
|
||
|
|
const url=targetUrl || e.full_url || (base(e)+e.path);
|
||
|
|
const f=fields(e);
|
||
|
|
const isImg=/image|video|audio/.test(e.resp);
|
||
|
|
const q=f.filter(x=>x.q), b=f.filter(x=>!x.q);
|
||
|
|
const qs=q.length?'?'+q.map(x=>x.n+'='+encodeURIComponent(x.v)).join('&'):'';
|
||
|
|
const omitted=(e.params||[]).length-f.length;
|
||
|
|
|
||
|
|
let curl=e.curl?e.curl.replace(/\{\{base\}\}/g,(D.meta.baseUrl||'https://apigp0006.creinnovations.in').replace(/\/$/,'')):
|
||
|
|
`curl -X ${e.method==='MULTI'?'POST':e.method} "${url}${qs}"`+b.map(x=>` \\
|
||
|
|
-F "${x.n}=${x.file?'@':''}${x.v}"`).join('')+(isImg?` \\
|
||
|
|
-o result.${/jpeg/.test(e.resp)?'jpg':'png'}`:'');
|
||
|
|
|
||
|
|
const files=b.filter(x=>x.file), data=b.filter(x=>!x.file);
|
||
|
|
const py=`import requests
|
||
|
|
|
||
|
|
res = requests.${(e.method==='MULTI'?'post':e.method).toLowerCase()}(
|
||
|
|
"${url}${qs}"`+(b.length?`,
|
||
|
|
files={${files.map(x=>`"${x.n}": open("${x.v}", "rb")`).join(', ')}},
|
||
|
|
data={${data.map(x=>`"${x.n}": "${x.v}"`).join(', ')}}`:'')+`,
|
||
|
|
)
|
||
|
|
res.raise_for_status()
|
||
|
|
`+(isImg?`open("result.${/jpeg/.test(e.resp)?'jpg':'png'}", "wb").write(res.content)`:`print(res.json())`);
|
||
|
|
|
||
|
|
const js=(b.length?`const form = new FormData();\n`+files.map(x=>`form.append("${x.n}", fileInput.files[0]); // ${x.v}`).join('\n')+(files.length?'\n':'')+data.map(x=>`form.append("${x.n}", "${x.v}");`).join('\n')+'\n\n':'')+`const res = await fetch("${url}${qs}", {\n method: "${e.method==='MULTI'?'POST':e.method}",`+(b.length?'\n body: form,':'')+`\n});\n`+(isImg?`const image = URL.createObjectURL(await res.blob());`:`const result = await res.json();`);
|
||
|
|
|
||
|
|
return {curl, py, js, omitted};
|
||
|
|
}
|
||
|
|
|
||
|
|
const ICON='<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>';
|
||
|
|
const COPY_ICON='<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>';
|
||
|
|
|
||
|
|
function detail(api, s){
|
||
|
|
const curIdx = activeSubEp[api.id] || 0;
|
||
|
|
const subEps = (api.endpoints && api.endpoints.length) ? api.endpoints : [api];
|
||
|
|
const e = subEps[curIdx] || api;
|
||
|
|
const cleanParams = (e.params || []).filter(p=>p.n && p.n.trim());
|
||
|
|
const targetUrl = e.full_url || api.full_url || (base(e) + e.path);
|
||
|
|
const sn = snippets(e, targetUrl);
|
||
|
|
|
||
|
|
// Universal Endpoint Tabs: Shown for every API (single and multiple)
|
||
|
|
const tabsHtml = `
|
||
|
|
<div class="ep-tabs-wrapper">
|
||
|
|
<span class="ep-tabs-label">Endpoints within this API (${subEps.length}):</span>
|
||
|
|
<div class="ep-tabs" role="tablist">
|
||
|
|
${subEps.map((sub, i) => `
|
||
|
|
<button class="ep-tab ${i === curIdx ? 'active' : ''}" data-act="subtab" data-api="${esc(api.id)}" data-idx="${i}">
|
||
|
|
<span class="m m-${esc(sub.method)}">${esc(sub.method)}</span>
|
||
|
|
<code>${esc(sub.subpath || sub.path)}</code>
|
||
|
|
<span>${esc(sub.title)}</span>
|
||
|
|
</button>
|
||
|
|
`).join('')}
|
||
|
|
</div>
|
||
|
|
</div>`;
|
||
|
|
|
||
|
|
// Direct Full URL Bar
|
||
|
|
const urlBarHtml = `
|
||
|
|
<div class="ep-full-url-bar">
|
||
|
|
<span class="m m-${esc(e.method)}">${esc(e.method)}</span>
|
||
|
|
<code>${esc(targetUrl)}</code>
|
||
|
|
<button class="btn sm" data-act="copyurl" data-url="${esc(targetUrl)}" title="Copy Complete URL">
|
||
|
|
${COPY_ICON} Copy Full URL
|
||
|
|
</button>
|
||
|
|
</div>`;
|
||
|
|
|
||
|
|
return tabsHtml + urlBarHtml + `<p class="desc">${esc(e.desc || e.summary || api.desc || api.summary)}</p>` +
|
||
|
|
(e.subs && e.subs.length ? `<h4>Also served at <span>${e.subs.length} more routes share this schema</span></h4><ul class="subs">${e.subs.map(x=>`<li><span class="m m-${esc(x.m)}">${esc(x.m)}</span><code>${esc(x.p)}</code><span>${esc(x.d)}</span></li>`).join('')}</ul>` : '') +
|
||
|
|
`<h4>Parameters <span>${cleanParams.length} total, ${cleanParams.filter(p=>p.rq).length} required</span></h4>` +
|
||
|
|
(cleanParams.length ? `<table class="pt"><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Default</th><th>What it does</th></tr></thead><tbody>` +
|
||
|
|
cleanParams.map(p=>`<tr class="${p.rq?'req':''}"><td><code class="pn">${esc(p.n)}</code>${p.al?`<span class="al">also accepts <code>${esc(p.al)}</code></span>`:''}</td><td><code class="ty">${esc(p.ty)}</code><span class="lc">${esc(p.lc)}</span></td><td>${p.rq?'<span class="rq">Required</span>':'<span class="op">Optional</span>'}</td><td><code class="df">${meaningful(p.df)?esc(clean(p.df)):'—'}</code></td><td>${esc(p.ds)}</td></tr>`).join('') +
|
||
|
|
`</tbody></table>` : '<p class="hint">This endpoint takes no parameters.</p>') +
|
||
|
|
(e.chips && e.chips.length ? `<h4>Verified presets <span>${e.chips.length} accepted values</span></h4><div class="pr-tools"><input type="search" placeholder="Filter ${e.chips.length} presets" data-act="chipfilter" aria-label="Filter presets"><button class="btn" data-act="copyall" data-ep="${esc(api.id)}">Copy all</button><button class="btn" data-act="copyjson" data-ep="${esc(api.id)}">Copy as JSON</button><button class="btn" data-act="copysel" data-ep="${esc(api.id)}">Copy selected <span data-n>0</span></button><button class="btn" data-act="clearsel" data-ep="${esc(api.id)}">Clear</button></div><div class="chips">${e.chips.map(c=>`<button class="chip" data-act="chip" data-v="${esc(c)}" title="Click to copy: ${esc(c)}">${esc(c)}</button>`).join('')}</div>` : '') +
|
||
|
|
`<h4>Response</h4><div class="resp"><code>${esc(e.resp||'—')}</code><span>${/json/.test(e.resp)?'Parsed JSON body':'Binary image body, write it straight to a file'}</span></div>` +
|
||
|
|
`<h4>Try it</h4><div class="code" data-code><div class="ctab"><button class="on" data-act="tab" data-t="curl">cURL</button><button data-act="tab" data-t="py">Python</button><button data-act="tab" data-t="js">JavaScript</button><button class="cp" data-act="copycode">Copy</button></div><pre data-t="curl">${esc(sn.curl)}</pre><pre data-t="py" hidden>${esc(sn.py)}</pre><pre data-t="js" hidden>${esc(sn.js)}</pre></div>` +
|
||
|
|
(sn.omitted?`<p class="hint">${sn.omitted} optional parameter${sn.omitted>1?'s are':' is'} left out of these examples.</p>`:'');
|
||
|
|
}
|
||
|
|
|
||
|
|
function epHTML(e, s){
|
||
|
|
const subEps = (e.endpoints && e.endpoints.length) ? e.endpoints : [e];
|
||
|
|
const displayPath = e.full_url || (base(e) + e.path);
|
||
|
|
|
||
|
|
// Exact 3-column .eh grid structure from original: col1: method, col2: info, col3: stats & chevron
|
||
|
|
return `<article class="ep" id="${esc(e.id)}" data-sec="${esc(s.id)}">
|
||
|
|
<button class="eh" data-act="toggle" aria-expanded="false">
|
||
|
|
<span class="m m-${esc(e.method)}">${esc(e.method)}</span>
|
||
|
|
<span style="min-width:0;">
|
||
|
|
<span class="et">${esc(e.api_key || e.title)}</span>
|
||
|
|
<code class="ep-path">${esc(displayPath)}</code>
|
||
|
|
<span class="es">${esc(e.summary)}</span>
|
||
|
|
</span>
|
||
|
|
<span class="ek">
|
||
|
|
<span style="background:var(--soft);padding:3px 8px;border-radius:6px;">${subEps.length} endpoint${subEps.length===1?'':'s'}</span>
|
||
|
|
${e.chips && e.chips.length ? `<span>${e.chips.length} presets</span>` : ''}
|
||
|
|
<span class="chev">${ICON}</span>
|
||
|
|
</span>
|
||
|
|
</button>
|
||
|
|
<div class="eb"><div class="ei"><div class="ew"></div></div></div>
|
||
|
|
</article>`;
|
||
|
|
}
|
||
|
|
|
||
|
|
const find=id=>{
|
||
|
|
for(const s of D.sections){
|
||
|
|
const e=s.eps.find(x=>x.id===id);
|
||
|
|
if(e) return {e, s};
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
function render(){
|
||
|
|
const all = D.sections.flatMap(s=>s.eps);
|
||
|
|
const pre = all.reduce((n,e)=>n+(e.chips?e.chips.length:0), 0);
|
||
|
|
const ports = new Set(all.map(e=>String(e.port).match(/^\d+/)?.[0]).filter(Boolean));
|
||
|
|
const m = D.meta;
|
||
|
|
|
||
|
|
document.title = m.title;
|
||
|
|
$('#app').innerHTML = `
|
||
|
|
<nav class="rail" aria-label="Endpoint families">
|
||
|
|
<a class="brand" href="#top">
|
||
|
|
<svg viewBox="0 0 34 34">
|
||
|
|
<rect width="34" height="34" rx="10" fill="var(--ink)"/>
|
||
|
|
<circle cx="17" cy="17" r="8" fill="none" stroke="var(--paper)" stroke-width="2.4"/>
|
||
|
|
<path d="M17 9v8l6 4" stroke="hsl(172 70% 70%)" stroke-width="2.4" fill="none" stroke-linecap="round"/>
|
||
|
|
</svg>
|
||
|
|
<div>
|
||
|
|
<b>${esc(m.title.replace(/ API Reference$/,''))}</b>
|
||
|
|
<span>API reference</span>
|
||
|
|
</div>
|
||
|
|
</a>
|
||
|
|
${D.sections.map(s=>`
|
||
|
|
<a class="fam" href="#${esc(s.id)}" data-s="${esc(s.id)}" style="--h:${+s.hue||250}">
|
||
|
|
<i></i>${esc(s.title)}<em>${s.eps.length}</em>
|
||
|
|
</a>
|
||
|
|
`).join('')}
|
||
|
|
<div class="railfoot">
|
||
|
|
<div style="margin-bottom:8px;">Press <b>/</b> to search APIs.</div>
|
||
|
|
<div>Auth: <code>secretKey='abcdef'</code></div>
|
||
|
|
</div>
|
||
|
|
</nav>
|
||
|
|
<div class="shell">
|
||
|
|
<header class="top">
|
||
|
|
<button class="find" data-act="pal">
|
||
|
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2">
|
||
|
|
<circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/>
|
||
|
|
</svg>
|
||
|
|
Search by API Key, endpoint path or presets
|
||
|
|
<kbd>/</kbd>
|
||
|
|
</button>
|
||
|
|
<span class="sp"></span>
|
||
|
|
<div class="session-pill" id="sessionPill" title="Security session expires in 10 minutes">
|
||
|
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
||
|
|
<circle cx="12" cy="12" r="10"/>
|
||
|
|
<polyline points="12 6 12 12 16 14"/>
|
||
|
|
</svg>
|
||
|
|
<span id="timerCountdown">10:00</span>
|
||
|
|
</div>
|
||
|
|
<a href="/docs/logout" class="btn sm" style="text-decoration:none;" title="Log out of documentation">Log out</a>
|
||
|
|
<button class="btn" data-act="all">Expand all</button>
|
||
|
|
<button class="btn" data-act="theme" aria-label="Switch theme">Theme</button>
|
||
|
|
<a href="/khira/" target="_blank" class="btn btn-khira" title="Khira - Cross-Team Dev Ticketing Hub">
|
||
|
|
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
||
|
|
<path d="M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"/>
|
||
|
|
<path d="M13 5v2"/>
|
||
|
|
<path d="M13 17v2"/>
|
||
|
|
<path d="M13 11v2"/>
|
||
|
|
</svg>
|
||
|
|
Khira Tickets
|
||
|
|
</a>
|
||
|
|
<a href="/docs/editor" target="_blank" class="btn btn-admin" title="Documentation Admin Panel & Editor">
|
||
|
|
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
|
||
|
|
<path d="M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"/>
|
||
|
|
<path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1Z"/>
|
||
|
|
</svg>
|
||
|
|
Admin
|
||
|
|
</a>
|
||
|
|
</header>
|
||
|
|
<main id="top">
|
||
|
|
<section class="hero">
|
||
|
|
<h1>${esc(m.heading || m.title)}</h1>
|
||
|
|
<p class="lead">${esc(m.intro)}</p>
|
||
|
|
<div class="facts">
|
||
|
|
<div><b>${all.length}</b>APIs</div>
|
||
|
|
<div><b>${D.sections.length}</b>families</div>
|
||
|
|
<div><b>${ports.size}</b>ports in use</div>
|
||
|
|
<div><b>${pre.toLocaleString()}</b>verified presets</div>
|
||
|
|
</div>
|
||
|
|
${m.authNote ? `<p class="note">${esc(m.authNote)}</p>` : ''}
|
||
|
|
</section>
|
||
|
|
${D.sections.map(s=>`
|
||
|
|
<section class="fsec" id="${esc(s.id)}" style="--h:${+s.hue||250}">
|
||
|
|
<div class="fhead">
|
||
|
|
<h2>${esc(s.title)}</h2>
|
||
|
|
<div class="tag">
|
||
|
|
${s.tag ? `<span>${esc(s.tag)}</span>` : ''}
|
||
|
|
${s.port ? `<span>Port <code>${esc(s.port)}</code></span>` : ''}
|
||
|
|
<span>${s.eps.length} API${s.eps.length===1?'':'s'}</span>
|
||
|
|
</div>
|
||
|
|
${s.lead ? `<p>${esc(s.lead)}</p>` : ''}
|
||
|
|
</div>
|
||
|
|
${s.eps.map(e=>epHTML(e, s)).join('')}
|
||
|
|
</section>
|
||
|
|
`).join('')}
|
||
|
|
</main>
|
||
|
|
</div>
|
||
|
|
<div class="pal" hidden data-act="palbg">
|
||
|
|
<div class="pbox" role="dialog" aria-label="Search APIs">
|
||
|
|
<input id="pq" placeholder="Search ${all.length} APIs (name, path, preset)" autocomplete="off">
|
||
|
|
<div class="pl" id="pl"></div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div class="toast" id="toast" hidden></div>
|
||
|
|
`;
|
||
|
|
|
||
|
|
// Reopen cards that were previously open
|
||
|
|
open.forEach(id => {
|
||
|
|
const a = document.getElementById(id);
|
||
|
|
if (a) setOpen(a, true);
|
||
|
|
});
|
||
|
|
updateSessionDisplay();
|
||
|
|
}
|
||
|
|
|
||
|
|
function setOpen(a, on){
|
||
|
|
const f = find(a.id);
|
||
|
|
if (!f) return;
|
||
|
|
a.classList.toggle('open', on);
|
||
|
|
$('.eh', a)?.setAttribute('aria-expanded', on);
|
||
|
|
a.style.setProperty('--h', f.s.hue);
|
||
|
|
a.style.setProperty('--a', `hsl(${+f.s.hue||250} 55% 40%)`);
|
||
|
|
const w = $('.ew', a);
|
||
|
|
if (on && w && !w.innerHTML) {
|
||
|
|
w.innerHTML = detail(f.e, f.s);
|
||
|
|
}
|
||
|
|
on ? open.add(a.id) : open.delete(a.id);
|
||
|
|
}
|
||
|
|
|
||
|
|
function toast(t){
|
||
|
|
const n = $('#toast');
|
||
|
|
if (!n) return;
|
||
|
|
n.textContent = t;
|
||
|
|
n.hidden = false;
|
||
|
|
clearTimeout(toastT);
|
||
|
|
toastT = setTimeout(() => n.hidden = true, 2000);
|
||
|
|
}
|
||
|
|
|
||
|
|
async function copy(t, msg){
|
||
|
|
try {
|
||
|
|
await navigator.clipboard.writeText(t);
|
||
|
|
} catch(err){
|
||
|
|
const x = document.createElement('textarea');
|
||
|
|
x.value = t;
|
||
|
|
document.body.append(x);
|
||
|
|
x.select();
|
||
|
|
document.execCommand('copy');
|
||
|
|
x.remove();
|
||
|
|
}
|
||
|
|
toast(msg || 'Copied');
|
||
|
|
}
|
||
|
|
|
||
|
|
function goto(id){
|
||
|
|
const a = document.getElementById(id);
|
||
|
|
if (!a) return;
|
||
|
|
setOpen(a, true);
|
||
|
|
history.replaceState(null, '', '#' + id);
|
||
|
|
setTimeout(() => a.scrollIntoView({behavior: 'smooth', block: 'start'}), 60);
|
||
|
|
}
|
||
|
|
|
||
|
|
let ro;
|
||
|
|
function spy(){
|
||
|
|
ro && ro.disconnect();
|
||
|
|
ro = new IntersectionObserver(es => es.forEach(en => {
|
||
|
|
if (en.isIntersecting) {
|
||
|
|
$$('.fam').forEach(f => f.classList.toggle('on', f.dataset.s === en.target.id));
|
||
|
|
}
|
||
|
|
}), {rootMargin: '-20% 0px -70% 0px'});
|
||
|
|
$$('.fsec').forEach(s => ro.observe(s));
|
||
|
|
}
|
||
|
|
|
||
|
|
function palList(q){
|
||
|
|
const t = q.toLowerCase().split(/\s+/).filter(Boolean);
|
||
|
|
const out = [];
|
||
|
|
for (const s of D.sections) {
|
||
|
|
for (const e of s.eps) {
|
||
|
|
const subPaths = (e.endpoints || []).map(x => x.subpath || x.path).join(' ');
|
||
|
|
const hay = [e.api_key, e.title, e.path, e.full_url, e.summary, e.desc, s.title, subPaths, ...(e.chips || [])].join(' ').toLowerCase();
|
||
|
|
if (t.every(w => hay.includes(w))) {
|
||
|
|
out.push(e);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return out.slice(0, 40);
|
||
|
|
}
|
||
|
|
|
||
|
|
let pi = 0, pr = [];
|
||
|
|
function palDraw(){
|
||
|
|
const l = $('#pl');
|
||
|
|
pr = palList($('#pq').value);
|
||
|
|
pi = Math.min(pi, Math.max(pr.length - 1, 0));
|
||
|
|
l.innerHTML = pr.length ? pr.map((x, i) => `
|
||
|
|
<button class="pi ${i === pi ? 'on' : ''}" data-act="pick" data-id="${esc(x.id)}">
|
||
|
|
<span class="m m-${esc(x.method)}">${esc(x.method)}</span>
|
||
|
|
<span><b>${esc(x.api_key || x.title)}</b><code>${esc(x.full_url || x.path)}</code></span>
|
||
|
|
</button>
|
||
|
|
`).join('') : '<p class="pe">No matching APIs found.</p>';
|
||
|
|
$('.pi.on')?.scrollIntoView({block: 'nearest'});
|
||
|
|
}
|
||
|
|
|
||
|
|
function palOpen(on){
|
||
|
|
const p = $('.pal');
|
||
|
|
p.hidden = !on;
|
||
|
|
if (on) {
|
||
|
|
$('#pq').value = '';
|
||
|
|
pi = 0;
|
||
|
|
palDraw();
|
||
|
|
$('#pq').focus();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/* Event delegation */
|
||
|
|
document.addEventListener('click', ev => {
|
||
|
|
const t = ev.target.closest('[data-act]');
|
||
|
|
if (!t) return;
|
||
|
|
const a = t.dataset.act, ep = t.closest('.ep');
|
||
|
|
|
||
|
|
if (a === 'palbg') {
|
||
|
|
if (ev.target === t) palOpen(false);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (a === 'toggle' && ep) {
|
||
|
|
setOpen(ep, !ep.classList.contains('open'));
|
||
|
|
} else if (a === 'subtab') {
|
||
|
|
const apiId = t.dataset.api;
|
||
|
|
const idx = +t.dataset.idx;
|
||
|
|
activeSubEp[apiId] = idx;
|
||
|
|
const art = document.getElementById(apiId);
|
||
|
|
const f = find(apiId);
|
||
|
|
if (art && f) {
|
||
|
|
const w = $('.ew', art);
|
||
|
|
if (w) w.innerHTML = detail(f.e, f.s);
|
||
|
|
}
|
||
|
|
} else if (a === 'copyurl') {
|
||
|
|
const url = t.dataset.url;
|
||
|
|
copy(url, 'Copied full URL');
|
||
|
|
} else if (a === 'chip') {
|
||
|
|
// Clicking preset chip copies that preset directly
|
||
|
|
const val = t.dataset.v || t.textContent;
|
||
|
|
copy(val, 'Copied preset: ' + val);
|
||
|
|
t.classList.add('copied');
|
||
|
|
setTimeout(() => t.classList.remove('copied'), 1200);
|
||
|
|
} else if (a === 'copyall') {
|
||
|
|
const apiId = t.dataset.ep;
|
||
|
|
const f = find(apiId);
|
||
|
|
if (f && f.e.chips) copy(f.e.chips.join(', '), 'Copied all presets');
|
||
|
|
} else if (a === 'copyjson') {
|
||
|
|
const apiId = t.dataset.ep;
|
||
|
|
const f = find(apiId);
|
||
|
|
if (f && f.e.chips) copy(JSON.stringify(f.e.chips), 'Copied presets as JSON');
|
||
|
|
} else if (a === 'copysel') {
|
||
|
|
const v = $$('.chip.sel', ep).map(c => c.dataset.v || c.textContent);
|
||
|
|
v.length ? copy(v.join(', '), `Copied ${v.length} presets`) : toast('Click presets to select first');
|
||
|
|
} else if (a === 'clearsel') {
|
||
|
|
$$('.chip.sel', ep).forEach(c => c.classList.remove('sel'));
|
||
|
|
$('[data-n]', ep).textContent = '0';
|
||
|
|
} else if (a === 'pal') {
|
||
|
|
palOpen(true);
|
||
|
|
} else if (a === 'pick') {
|
||
|
|
palOpen(false);
|
||
|
|
goto(t.dataset.id);
|
||
|
|
} else if (a === 'theme') {
|
||
|
|
const n = document.documentElement.dataset.theme === 'dark' ? 'light' : 'dark';
|
||
|
|
document.documentElement.dataset.theme = n;
|
||
|
|
try { localStorage.setItem('apidocs-theme', n); } catch(e){}
|
||
|
|
} else if (a === 'all') {
|
||
|
|
const on = t.textContent === 'Expand all';
|
||
|
|
$$('.ep').forEach(x => setOpen(x, on));
|
||
|
|
t.textContent = on ? 'Collapse all' : 'Expand all';
|
||
|
|
} else if (a === 'tab') {
|
||
|
|
const box = t.closest('[data-code]');
|
||
|
|
$$('.ctab button[data-t]', box).forEach(b => b.classList.toggle('on', b === t));
|
||
|
|
$$('pre', box).forEach(p => p.hidden = p.dataset.t !== t.dataset.t);
|
||
|
|
} else if (a === 'copycode') {
|
||
|
|
copy($$('pre', t.closest('[data-code]')).find(p => !p.hidden).textContent, 'Copied snippet');
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
document.addEventListener('input', ev => {
|
||
|
|
const t = ev.target;
|
||
|
|
if (t.id === 'pq') {
|
||
|
|
pi = 0;
|
||
|
|
palDraw();
|
||
|
|
} else if (t.dataset.act === 'chipfilter') {
|
||
|
|
const q = t.value.toLowerCase();
|
||
|
|
$$('.chip', t.closest('.ew')).forEach(c => {
|
||
|
|
const v = (c.dataset.v || c.textContent).toLowerCase();
|
||
|
|
c.hidden = !!q && !v.includes(q);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
document.addEventListener('keydown', ev => {
|
||
|
|
const p = $('.pal'), typing = /INPUT|TEXTAREA/.test(document.activeElement.tagName);
|
||
|
|
if (((ev.ctrlKey || ev.metaKey) && ev.key === 'k') || (ev.key === '/' && !typing)) {
|
||
|
|
ev.preventDefault();
|
||
|
|
palOpen(true);
|
||
|
|
} else if (p && !p.hidden) {
|
||
|
|
if (ev.key === 'Escape') palOpen(false);
|
||
|
|
else if (ev.key === 'ArrowDown') { ev.preventDefault(); pi = Math.min(pi + 1, pr.length - 1); palDraw(); }
|
||
|
|
else if (ev.key === 'ArrowUp') { ev.preventDefault(); pi = Math.max(pi - 1, 0); palDraw(); }
|
||
|
|
else if (ev.key === 'Enter' && pr[pi]) { palOpen(false); goto(pr[pi].id); }
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
/* ---------- 10-Minute Session Auto-Logout ---------- */
|
||
|
|
let sessionRemaining = 600;
|
||
|
|
async function checkSession(){
|
||
|
|
try {
|
||
|
|
const res = await fetch('/docs/session');
|
||
|
|
if (!res.ok) {
|
||
|
|
window.location.href = '/docs/logout';
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
const data = await res.json();
|
||
|
|
if (data.authenticated && typeof data.remaining_seconds === 'number') {
|
||
|
|
sessionRemaining = data.remaining_seconds;
|
||
|
|
updateSessionDisplay();
|
||
|
|
} else {
|
||
|
|
window.location.href = '/docs/logout';
|
||
|
|
}
|
||
|
|
} catch(err){}
|
||
|
|
}
|
||
|
|
|
||
|
|
function updateSessionDisplay(){
|
||
|
|
const el = document.getElementById('timerCountdown');
|
||
|
|
const pill = document.getElementById('sessionPill');
|
||
|
|
if (!el) return;
|
||
|
|
const m = Math.floor(sessionRemaining / 60);
|
||
|
|
const s = sessionRemaining % 60;
|
||
|
|
el.textContent = `${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}`;
|
||
|
|
if (pill) {
|
||
|
|
pill.classList.toggle('warning', sessionRemaining <= 60);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
setInterval(() => {
|
||
|
|
sessionRemaining--;
|
||
|
|
if (sessionRemaining <= 0) {
|
||
|
|
toast('Session expired after 10 minutes. Logging out...');
|
||
|
|
setTimeout(() => {
|
||
|
|
window.location.href = '/docs/logout';
|
||
|
|
}, 600);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
updateSessionDisplay();
|
||
|
|
}, 1000);
|
||
|
|
|
||
|
|
setInterval(checkSession, 25000);
|
||
|
|
checkSession();
|
||
|
|
|
||
|
|
/* PostMessage Editor Communication */
|
||
|
|
function exportHtml(data){
|
||
|
|
const c = document.documentElement.cloneNode(true);
|
||
|
|
c.removeAttribute('data-theme');
|
||
|
|
c.removeAttribute('style');
|
||
|
|
$('#app', c).innerHTML = '';
|
||
|
|
$('#api-data', c).textContent = JSON.stringify(data).replace(/</g, '\\u003c');
|
||
|
|
$('title', c).textContent = data.meta.title;
|
||
|
|
return '<!DOCTYPE html>\n' + c.outerHTML;
|
||
|
|
}
|
||
|
|
|
||
|
|
addEventListener('message', ev => {
|
||
|
|
const m = ev.data;
|
||
|
|
if (!m || m.apidocs !== 1) return;
|
||
|
|
const re = o => ev.source && ev.source.postMessage({ apidocs: 1, ...o }, '*');
|
||
|
|
if (m.type === 'hello') {
|
||
|
|
re({ type: 'data', schema: 1, data: D, file: decodeURIComponent(location.pathname.split('/').pop()) });
|
||
|
|
} else if (m.type === 'render') {
|
||
|
|
D = m.data;
|
||
|
|
render();
|
||
|
|
} else if (m.type === 'focus') {
|
||
|
|
goto(m.id);
|
||
|
|
} else if (m.type === 'export') {
|
||
|
|
re({ type: 'html', html: exportHtml(m.data || D) });
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
render();
|
||
|
|
spy();
|
||
|
|
if (location.hash.length > 1) {
|
||
|
|
setTimeout(() => goto(decodeURIComponent(location.hash.slice(1))), 200);
|
||
|
|
}
|
||
|
|
})();
|
||
|
|
</script>
|
||
|
|
</body>
|
||
|
|
</html>
|