PageSourceSearch

https://www.goglobal.to/assets/ApiPlatformPage-BYzw66Wk.js

js goglobal.to collected 2026-10-01 23:45:16 UTC 18,965 bytes, 17 lines download raw bytes

1import{e as o,j as e}from"./react-vendor-COA9LC9C.js";import{a2 as I,aH as W,aL as X,aG as m,aF as T,B as n,f as M,g as ee,h as se,k as te,l as ae,i as re,j as _,a1 as ie}from"./index-DNOAzpau.js";import{C as G,d as B,e as L,b as z,a as H}from"./card-Bhwb9Q_i.js";import{I as de}from"./input-BOGnGvhO.js";import{L as ne}from"./label-DReHdLPI.js";import{B as A}from"./badge-DrtwPH22.js";import{A as ce,c as oe,f as le,g as me,d as xe,e as he,b as pe,a as fe}from"./alert-dialog-uYFfvZrQ.js";import{T as F,d as $,e as y,c as r,a as U,b as i}from"./table-CE88J3Ea.js";import{s as P}from"./apiErrorToast-Dlkm8k7S.js";import{B as ue}from"./book-open-DhhX0AjK.js";import{P as Z}from"./plus-Cr6fK8jk.js";import{S as ge}from"./shield-3Ef5BYMk.js";import{Z as ye}from"./zap-C7RC9V8k.js";import{L as C}from"./loader-circle-SaNojEXd.js";import{K as je}from"./key-DDadT8uh.js";import{T as be}from"./trash-2-E8_iP2eX.js";import{C as Ne}from"./circle-check-BGWj_h4Y.js";import{E as ve}from"./eye-DXTpS85j.js";import{g as ke,f as we}from"./format-CJZafWgJ.js";import{z as Ae}from"./zh-CN-BQX3qyDD.js";import"./ui-vendor-DZhVfNUY.js";import"./data-vendor-DLQwpBlT.js";/**
2 * @license lucide-react v0.542.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Pe=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Ce=I("eye-off",Pe);/**
7 * @license lucide-react v0.542.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const Te=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Ie=I("terminal",Te);/**
12 * @license lucide-react v0.542.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const De=[["circle",{cx:"15",cy:"12",r:"3",key:"1afu0r"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],Se=I("toggle-right",De);function q(c,d="Copied!"){navigator.clipboard.writeText(c).then(()=>T.success(d))}function Y(c,d){if(!c)return"—";try{return ke(new Date(c),d==="zh"?"yyyy-MM-dd":"MMM d, yyyy",{locale:d==="zh"?Ae:we})}catch{return String(c)}}const Ke={GET:"bg-blue-100 text-blue-700",POST:"bg-green-100 text-green-700",DELETE:"bg-red-100 text-red-700"};function ss(){const{user:c}=W(),{language:d}=X(),j=m.useUtils(),s=d==="zh",t={copied:s?"已复制":"Copied!",exampleCopied:s?"示例已复制":"Example copied!",keyRevoked:s?"API 密钥已撤销":"API key revoked",keyDeleted:s?"API 密钥已删除":"API key deleted",enterKeyName:s?"请输入 API 密钥名称":"Please enter a name for the API key",pageTitle:s?"API 平台":"API Platform",pageDesc:s?"管理你的 API 密钥,并通过 REST API 完成集成。":"Manage your API keys and integrate with the REST API.",apiDocs:s?"API 文档":"API Docs",createApiKey:s?"创建 API 密钥":"Create API Key",featureAuthTitle:s?"自托管认证":"Self-hosted Auth",featureAuthDesc:s?"你的密钥,你的控制权。无需第三方认证。":"Your keys, your control. No third-party auth required.",featureOrderTitle:s?"完整下单 API":"Full Order API",featureOrderDesc:s?"通过 REST 创建订单、发布帖子并管理投票。":"Create orders, publish posts, manage votes via REST.",featureIntegrationTitle:s?"简单集成":"Simple Integration",featureIntegrationDesc:s?"标准 Bearer Token,适用于任何 HTTP 客户端。":"Standard Bearer token — works with any HTTP client.",yourApiKeys:s?"你的 API 密钥":"Your API Keys",keySecurityDesc:s?"密钥会被安全哈希存储。原始密钥只会在创建时展示一次。":"Keys are hashed and stored securely. The raw key is only shown once at creation.",keyCount:a=>s?`${a} 个密钥`:`${a} key${a!==1?"s":""}`,noApiKeys:s?"还没有 API 密钥":"No API keys yet",noApiKeysDesc:s?"创建你的第一个密钥,开始接入 API。":"Create your first key to 
16start integrating.",name:s?"名称":"Name",key:s?"密钥":"Key",status:s?"状态":"Status",lastUsed:s?"最近使用":"Last Used",created:s?"创建时间":"Created",actions:s?"操作":"Actions",active:s?"启用中":"Active",revoked:s?"已撤销":"Revoked",revoke:s?"撤销":"Revoke",apiReference:s?"API 参考":"API Reference",apiReferenceDesc:s?"所有端点都需要携带":"All endpoints require an",headerSuffix:s?"请求头。":"header.",method:s?"方法":"Method",endpoint:s?"端点":"Endpoint",description:s?"说明":"Description",dialogTitle:s?"创建 API 密钥":"Create API Key",dialogDesc:s?"给密钥起一个便于识别的名称。原始密钥只会展示一次,请立即复制保存。":"Give your key a descriptive name. The raw key will be shown once — copy it immediately.",createSuccess:s?"API 密钥创建成功":"API key created successfully!",copyNow:s?"请现在复制这个密钥,之后将不再显示。":"Copy this key now — it will not be shown again.",keyCopied:s?"API 密钥已复制":"API key copied!",done:s?"完成":"Done",keyName:s?"密钥名称":"Key Name",keyNamePlaceholder:s?"例如:生产环境、我的应用、测试":"e.g. Production, My App, Test",scopes:s?"权限":"Scopes",cancel:s?"取消":"Cancel",createKey:s?"创建密钥":"Create Key",deleteConfirmTitle:s?"删除 API 密钥?":"Delete API Key?",deleteConfirmDesc:s?"此操作不可恢复。所有使用该密钥的集成都会立即失效。":"This action is permanent. Any integrations using this key will stop working immediately.",delete:s?"删除":"Delete",endpoints:[{method:"GET",path:"/api/v1/me",desc:s?"获取当前用户信息":"Get current user info"},{method:"GET",path:"/api/v1/balance",desc:s?"获取账户余额":"Get provider balance"},{method:"GET",path:"/api/v1/orders",desc:s?"获取订单列表":"List your orders"},{method:"GET",path:"/api/v1/orders/pricing",desc:s?"获取价格配置":"Get pricing config"},{method:"GET",path:"/api/v1/orders/:id",desc:s?"获取单个订单详情":"Get a single order"},{method:"POST",path:"/api/v1/orders",desc:s?"创建新订单":"Create a new order"},{method:"POST",path:"/api/v1/orders/:id/cancel",desc:s?"取消订单":"Cancel an order"},{method:"POST",path:"/api/v1/votes",desc:s?"创建直投订单,内置幂等计费保护":"Create a direct vote order with idempotent billing protection"},{method:"POST",path:"/api/v1/roadmap/reddit-draft",desc:s?"生成与路线图对齐的 Reddit 草稿,带幂等计费保护":"Generate a roadmap-aligned Reddit draft with idempotent billing guards"},{method:"POST",path:"/api/v1/campaigns/:publicId/tasks",desc:s?"生成 Campaign 草稿文档,带重试安全计费与缓存":"Generate campaign draft documents with retry-safe billing and caching"},{method:"POST",path:"/api/v1/campaigns/:publicId/auto-promote",desc:s?"生成 Campaign 草稿并安排自动推广,内置幂等保护":"Generate campaign drafts and schedule auto-promotion with idempotent safeguards"},{method:"POST",path:"/api/v1/posts/publish",desc:s?"发布 Reddit 帖子":"Publish a Reddit post"},{method:"POST",path:"/api/v1/comments/publish",desc:s?"发布 Reddit 评论":"Publish Reddit comments"},{method:"POST",path:"/api/v1/geo/search-posts",desc:s?"按关键词搜索 Reddit 帖子,内置平台计费保护":"Search Reddit posts for a keyword with platform billing safeguards"},{method:"POST",path:"/api/v1/geo/generate-comment",desc:s?"生成符合 Reddit 语境的评论,带规则感知计费":"Generate a Reddit-native comment with rules-aware credit billing"},{method:"POST",path:"/api/v1/geo/recommend-subreddits",desc:s?"为文章或页面推荐最匹配的 subreddit":"Recommend the best-fit subreddits for an article or page"}]},{data:x=[],isLoading:Q}=m.apiKey.list.useQuery(void 0,{enabled:!!c}),[J,h]=o.useState(!1),[p,b]=o.useState(""),[f,l]=o.useState(null),[u,D]=o.useState(null),[S,K]=o.useState(!0),[N,v]=o.useState(null),k=m.apiKey.create.useMutation({onSuccess:a=>{D(a.rawKey),b(""),l(null),j.apiKey.list.invalidate()},onError:a=>P(a,s?"创建 API 密钥失败,请稍后重试":"Failed to create API key. Please try again.")}),R=m.apiKey.revoke.useMutation({onSuccess:()=>
16{T.success(t.keyRevoked),j.apiKey.list.invalidate()},onError:a=>P(a,s?"撤销 API 密钥失败,请稍后重试":"Failed to revoke API key. Please try again.")}),E=m.apiKey.delete.useMutation({onSuccess:()=>{T.success(t.keyDeleted),j.apiKey.list.invalidate(),v(null)},onError:a=>P(a,s?"删除 API 密钥失败,请稍后重试":"Failed to delete API key. Please try again.")});function O(){if(!p.trim()){l(t.enterKeyName);return}l(null),k.mutate({name:p.trim()})}function w(){h(!1),D(null),b(""),l(null),K(!0)}return e.jsxs("div",{className:"min-h-full bg-[#faf8f6]",children:[e.jsxs("div",{className:"max-w-4xl mx-auto px-6 py-8 space-y-8",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-[#1f1a17] tracking-tight",children:t.pageTitle}),e.jsx("p",{className:"mt-1 text-sm text-[#8d7d71]",children:t.pageDesc})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("a",{href:"/docs/api",children:e.jsxs(n,{variant:"outline",className:"gap-2 border-[#ebe6df] text-[#5a4a3f] hover:text-[#1f1a17] hover:bg-[#f5ede6]",children:[e.jsx(ue,{className:"h-4 w-4"}),t.apiDocs]})}),e.jsxs(n,{onClick:()=>h(!0),className:"gap-2 bg-[#ea580c] hover:bg-[#c2410c] text-white shadow-sm",children:[e.jsx(Z,{className:"h-4 w-4"}),t.createApiKey]})]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-4",children:[{icon:ge,title:t.featureAuthTitle,desc:t.featureAuthDesc},{icon:ye,title:t.featureOrderTitle,desc:t.featureOrderDesc},{icon:Ie,title:t.featureIntegrationTitle,desc:t.featureIntegrationDesc}].map(({icon:a,title:g,desc:V})=>e.jsxs("div",{className:"rounded-xl border border-[#ebe6df] bg-white p-4 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-md bg-[#fff3ed]",children:e.jsx(a,{className:"h-4 w-4 text-[#ea580c]"})}),e.jsx("span",{className:"text-sm font-medium text-[#1f1a17]",children:g})]}),e.jsx("p",{className:"text-xs text-[#8d7d71] leading-relaxed",children:V})]},g))}),e.jsxs(G,{className:"border-[#ebe6df] shadow-none",children:[e.jsx(B,{className:"pb-4 border-b border-[#ebe6df]",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(L,{className:"text-base font-semibold text-[#1f1a17]",children:t.yourApiKeys}),e.jsx(z,{className:"text-xs text-[#8d7d71] mt-0.5",children:t.keySecurityDesc})]}),x.length>0&&e.jsx(A,{variant:"outline",className:"text-xs border-[#ebe6df] text-[#8d7d71]",children:t.keyCount(x.length)})]})}),e.jsx(H,{className:"p-0",children:Q?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(C,{className:"h-5 w-5 animate-spin text-[#ea580c]"})}):x.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-3",children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-[#f5ede6]",children:e.jsx(je,{className:"h-5 w-5 text-[#ea580c] opacity-60"})}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-medium text-[#1f1a17]",children:t.noApiKeys}),e.jsx("p",{className:"text-xs text-[#8d7d71] mt-0.5",children:t.noApiKeysDesc})]}),e.jsxs(n,{size:"sm",onClick:()=>h(!0),className:"mt-1 gap-1.5 bg-[#ea580c] hover:bg-[#c2410c] text-white",children:[e.jsx(Z,{className:"h-3.5 w-3.5"}),t.createApiKey]})]}):e.jsxs(F,{children:[e.jsx($,{children:e.jsxs(y,{className:"border-[#ebe6df] hover:bg-transparent",children:[e.jsx(r,{className:"text-xs font-medium text-[#8d7d71] pl-6",children:t.name}),e.jsx(r,{className:"text-xs font-medium text-[#8d7d71]",children:t.key}),e.jsx(r,{className:"text-xs font-medium text-[#8d7d71]",children:t.status}),e.jsx(r,{className:"text-xs font-medium text-[#8d7d71]",children:t.lastUsed}),e.jsx(r,{className:"text-xs font-medium text-[#8d7d71]",children:t.created}),e.jsx(r,{className:"text-xs font-medium text-[#8d7d71] text-right pr-6",children:t.actions})]})}),e.jsx(U,{children:x.map(a=>e.jsxs(y,{className:"border-[#ebe6df] hover:bg-[#faf8f6]",children:[e.jsx(i,{className:"font-medium text-sm text-[#1f1a17] pl-6",children:a.name}),e.jsx(i,{children:e.jsxs("code",{className:"text-xs bg-[#f5ede6] text-[#7a3c1a] px-2 py-1 rounded font-mono",children:[a.keyPrefix,"••••••••"]})}),e.jsx(i,{children:a.isActive?e.jsx(A,{className:"bg-green-50 text-green-700 border border-green-200 text-xs font-normal",children:t.active}):e.jsx(A,{className:"bg-gray-50 text-gray-500 border border-gray-200 text-xs font-normal",children:t.revoked})}),e.jsx(i,{className:"text-xs text-[#8d7d71]",children:Y(a.lastUsedAt,d)}),e.jsx(i,{className:"text-xs text-[#8d7d71]",children:Y(a.createdAt,d)}),e.jsx(i,{className:"text-right pr-6",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[a.isActive&&e.jsxs(n,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-[#8d7d71] hover:text-[#ea580c] hover:bg-[#fff3ed]",onClick:()=>R.mutate({id:a.id}),disabled:R.isPending,children:[e.jsx(Se,{className:"h-3.5 w-3.5 mr-1"}),t.revoke]}),e.jsx(n,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-[#8d7d71] hover:text-red-500 hover:bg-red-50",onClick:()=>v(a.id),children:e.jsx(be,{className:"h-3.5 w-3.5"})})]})})]},a.id))})]})})]}),e.jsxs(G,{className:"border-[#ebe6df] shadow-none",children:[e.jsxs(B,{className:"pb-4 border-b border-[#ebe6df]",children:[e.jsx(L,{className:"text-base font-semibold text-[#1f1a17]",children:t.apiReference}),e.jsxs(z,{className:"text-xs text-[#8d7d71] mt-0.5",children:[t.apiReferenceDesc," ",e.jsx("code",{className:"bg-[#f5ede6] text-[#7a3c1a] px-1.5 py-0.5 rounded text-xs font-mono",children:"Authorization: Bearer sk_live_..."})," ",t.headerSuffix]})]}
16),e.jsxs(H,{className:"pt-4 space-y-4",children:[e.jsxs("div",{className:"relative rounded-lg bg-[#1a1a1a] p-4 font-mono text-xs overflow-x-auto",children:[e.jsx("button",{className:"absolute top-3 right-3 text-[#555] hover:text-[#aaa] transition-colors",onClick:()=>q(`curl https://your-domain.com/api/v1/orders \\
17  -H "Authorization: Bearer sk_live_your_key_here"`,t.exampleCopied),children:e.jsx(M,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"text-[#d4d4d4] leading-relaxed",children:[e.jsx("span",{className:"text-[#569cd6]",children:"curl"})," ",e.jsx("span",{className:"text-[#ce9178]",children:"https://your-domain.com/api/v1/orders"})," ",e.jsx("span",{className:"text-[#808080]",children:"\\"}),e.jsx("br",{}),"  ",e.jsx("span",{className:"text-[#9cdcfe]",children:"-H"})," ",e.jsx("span",{className:"text-[#ce9178]",children:'"Authorization: Bearer sk_live_your_key_here"'})]})]}),e.jsx("div",{className:"rounded-lg border border-[#ebe6df] overflow-hidden",children:e.jsxs(F,{children:[e.jsx($,{children:e.jsxs(y,{className:"bg-[#faf8f6] border-[#ebe6df] hover:bg-[#faf8f6]",children:[e.jsx(r,{className:"text-xs font-medium text-[#8d7d71] w-20 pl-4",children:t.method}),e.jsx(r,{className:"text-xs font-medium text-[#8d7d71] w-64",children:t.endpoint}),e.jsx(r,{className:"text-xs font-medium text-[#8d7d71]",children:t.description})]})}),e.jsx(U,{children:t.endpoints.map((a,g)=>e.jsxs(y,{className:`border-[#ebe6df] hover:bg-[#faf8f6] ${g===t.endpoints.length-1?"border-b-0":""}`,children:[e.jsx(i,{className:"pl-4 py-2.5",children:e.jsx("span",{className:`inline-block text-xs font-semibold font-mono px-2 py-0.5 rounded ${Ke[a.method]??"bg-gray-100 text-gray-700"}`,children:a.method})}),e.jsx(i,{className:"py-2.5",children:e.jsx("code",{className:"text-xs text-[#7a3c1a] font-mono",children:a.path})}),e.jsx(i,{className:"text-xs text-[#8d7d71] py-2.5",children:a.desc})]},a.path))})]})})]})]})]}),e.jsx(ee,{open:J,onOpenChange:a=>{a?h(!0):w()},children:e.jsxs(se,{className:"sm:max-w-md",children:[e.jsxs(te,{children:[e.jsx(ae,{children:t.dialogTitle}),e.jsx(re,{children:t.dialogDesc})]}),u?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-green-600",children:[e.jsx(Ne,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm font-medium",children:t.createSuccess})]}),e.jsxs("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-amber-700 font-medium",children:t.copyNow}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 text-xs font-mono bg-white border border-amber-200 rounded px-2 py-1.5 break-all",children:S?u:u.replace(/./g,"•")}),e.jsx("button",{className:"text-[#8d7d71] hover:text-[#ea580c] shrink-0",onClick:()=>K(a=>!a),children:S?e.jsx(Ce,{className:"h-4 w-4"}):e.jsx(ve,{className:"h-4 w-4"})}),e.jsx("button",{className:"text-[#8d7d71] hover:text-[#ea580c] shrink-0",onClick:()=>q(u,t.keyCopied),children:e.jsx(M,{className:"h-4 w-4"})})]})]}),e.jsx(_,{children:e.jsx(n,{onClick:w,className:"bg-[#ea580c] hover:bg-[#c2410c] text-white",children:t.done})})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{htmlFor:"key-name",className:"text-sm font-medium",children:t.keyName}),e.jsx(de,{id:"key-name",placeholder:t.keyNamePlaceholder,value:p,onChange:a=>{b(a.target.value),f&&l(null)},onKeyDown:a=>{a.key==="Enter"&&O()},className:ie("border-[#ebe6df] focus-visible:ring-[#ea580c]",f&&"border-destructive focus-visible:ring-destructive/30")}),f&&e.jsx("p",{className:"text-xs text-destructive",children:f})]}),e.jsx("div",{className:"rounded-lg bg-[#f5f5f5] px-3 py-2.5",children:e.jsxs("p",{className:"text-xs text-[#8d7d71]",children:[e.jsxs("span",{className:"font-medium text-[#1f1a17]",children:[t.scopes,":"]})," ","order:read, order:write"]})}),e.jsxs(_,{children:[e.jsx(n,{variant:"outline",onClick:w,className:"border-[#ebe6df]",children:t.cancel}),e.jsxs(n,{onClick:O,disabled:k.isPending||!p.trim(),className:"bg-[#ea580c] hover:bg-[#c2410c] text-white",children:[k.isPending&&e.jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}),t.createKey]})]})]})]})}),e.jsx(ce,{open:N!==null,onOpenChange:a=>{a||v(null)},children:e.jsxs(oe,{children:[e.jsxs(le,{children:[e.jsx(me,{children:t.deleteConfirmTitle}),e.jsx(xe,{children:t.deleteConfirmDesc})]}),e.jsxs(he,{children:[e.jsx(pe,{className:"border-[#ebe6df]",children:t.cancel}),e.jsx(fe,{onClick:()=>N!==null&&E.mutate({id:N}),className:"bg-red-500 hover:bg-red-600 text-white",children:E.isPending?e.jsx(C,{className:"h-4 w-4 animate-spin"}):t.delete})]})]})})]})}export{ss as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.