메인 콘텐츠로 건너뛰기

소개

hCaptcha는 Ace Data Cloud에서 제공하는 캡차 서비스 솔루션입니다. Ace Data Cloud 통합 API를 통해 JavaScript로 hCaptcha를 빠르게 통합하여 hCaptcha 토큰 획득, hCaptcha 이미지 인식 등의 기능을 구현할 수 있습니다.

전제 조건

  • Ace Data Cloud 계정을 보유하고 API 토큰을 획득
  • Node.js 18+ 또는 최신 브라우저 환경

기본 사용법

hCaptcha API의 주요 엔드포인트는 다음과 같습니다:
POST https://api.acedata.cloud/captcha/token/hcaptcha
전체 JavaScript 코드 예제:
const response = await fetch("https://api.acedata.cloud/captcha/token/hcaptcha", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
  "website_key": "a5f74b19-9e45-40e0-b45d-47ff91b7a6c2",
  "website_url": "https://accounts.hcaptcha.com/demo"
}),
});

const result = await response.json();
console.log(result);
YOUR_API_TOKEN을 Ace Data Cloud 플랫폼에서 획득한 실제 토큰으로 교체하세요.

응답 처리

응답 상태 코드를 확인하고 오류를 처리하는 것을 권장합니다:
if (response.ok) {
  const result = await response.json();
  console.log("호출 성공:", result);
} else {
  console.error(`호출 실패, 상태 코드: ${response.status}`);
  const error = await response.text();
  console.error(error);
}

Node.js 래핑

재사용 가능한 함수로 래핑하는 것을 권장합니다:
async function callhCaptcha(data) {
  const response = await fetch("https://api.acedata.cloud/captcha/token/hcaptcha", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${process.env.ACE_API_TOKEN}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify(data),
  });
  if (!response.ok) throw new Error(`API error: ${response.status}`);
  return response.json();
}

오류 처리

일반적인 오류 코드:
상태 코드설명
401인증 실패, API 토큰을 확인하세요
403잔액 부족 또는 접근 권한 없음
429요청 빈도 초과
500서버 내부 오류

다음 단계